ddns

package module
v0.0.0-...-1fa6447 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2019 License: MIT Imports: 12 Imported by: 0

README

dnsp: A DNS Proxy

Forked from: https://github.com/gophergala/dnsp

INSTALL

go get github.com/stutiredboy/ddns
cd ${GOPATH}/stutiredboy/ddns/cmd/ddns
go build

Configurations

{
	"ConnectTimeout": 500,
	"Debug": true,
	"Backends": {
		"0": "127.0.0.1:6379",
		"1": "127.0.0.1:6379"
	},
	"StatsPeriod": 60,
	"StatsFile": "/home/tiredboy/ddns.stats",
	"NameServers": ["8.8.8.8", "8.8.4.4"],
	"ReadTimeout": 500,
	"ChanNum": 4,
	"PoolNum": 5,
	"Listen": "127.0.0.1:5353"
}
Configuration Description
NameServers name servers the DNS query forward to, format: address:port, default port is 53
Listen UDP Listen address:port, default: 0.0.0.0:53
StatsFile stats file, absolute path
StatsPeriod ddns dump stats periodically(seconds)
Backends redis server, ddns will log to backend by Backends[crc32(domain)%len(Backends)]
ConnectTimeout timeout for connecting to redis server, Millisecond
ReadTimeout timeout for read/write to redis server, Millisecond
ChanNum concurrency numbers for writing to redis
PoolNum redis connection pool, must little greater than ChanNum
Debug verbose output

Documentation

Overview

Package ddns implements a simple DNS proxy for [D]etect DNS settings.

Index

Constants

This section is empty.

Variables

View Source
var BackendCrc32Tab = crc32.MakeTable(0xEDB88320)

BackendCrc32Tab Python use 0xEDB88320

View Source
var ChannelCrc32Tab = crc32.MakeTable(0xD5828281)

ChannelCrc32Tab different to BackendCrc32Tab

Functions

func GetEdns0Subnet

func GetEdns0Subnet(query *dns.Msg) net.IP

GetEdns0Subnet get ecs from query msg

Types

type Configurations

type Configurations struct {
	// host:port
	Listen string
	// [host1:port1, host2:port2]
	NameServers []string
	// Seconds, dump stats to StatsFile periodically
	StatsPeriod int
	StatsFile   string
	Backends    map[int]string
	// backend connection pool numbers
	PoolNum int
	// channel numbers, must little than PoolNum
	ChanNum int
	// millseconds
	ConnectTimeout int
	// millseconds
	ReadTimeout int
	ExpiresIn   int
	Debug       bool
}

Configurations for server

type Server

type Server struct {
	ExpiresIn int
	// contains filtered or unexported fields
}

Server implements a DNS server.

func NewServer

func NewServer(c Configurations) (*Server, error)

NewServer creates a new Server with the given options.

func (*Server) Dump

func (s *Server) Dump(period int, saveto string)

Dump the stats of ddns

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe runs the server

func (*Server) Log2b

func (s *Server) Log2b(backendIndex int, chanIndex int)

Log2b log quureies to backend by different channel/backend

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown stops the server, closing its connection.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL