server

package
v2.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: MIT, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HOSTS_PATH = "/etc/hosts"
	HOSTS_TTL  = 600

	RESOLV_CONF     = "/etc/resolv.conf"
	RESOLV_TIMEOUT  = 5
	RESOLV_INTERVAL = 200
	RESOLV_EDNS0_ON = true

	CACHE_EXPIRE   = 600   // 10 minutes
	CACHE_MAXCOUNT = 20000 // If set zero. The Sum of cache itmes will be unlimit.

)
View Source
const ResolvConfFilename = "/etc/resolv.conf"

Variables

This section is empty.

Functions

func HashData

func HashData(src io.Reader) (string, error)

HashData returns the sha256 sum of src.

func KeyGen

func KeyGen(q Question) string

func UnFqdn

func UnFqdn(s string) string

func UpdateResolvConf

func UpdateResolvConf()

Types

type Cache

type Cache interface {
	Get(key string) (Msg *dns.Msg, err error)
	Set(key string, Msg *dns.Msg) error
	Exists(key string) bool
	Remove(key string) error
	Full() bool
}

type CacheIsFull

type CacheIsFull struct {
}

func (CacheIsFull) Error

func (e CacheIsFull) Error() string

type KeyExpired

type KeyExpired struct {
	Key string
}

func (KeyExpired) Error

func (e KeyExpired) Error() string

type KeyNotFound

type KeyNotFound struct {
	// contains filtered or unexported fields
}

func (KeyNotFound) Error

func (e KeyNotFound) Error() string

type LocalData

type LocalData struct {
	// contains filtered or unexported fields
}

func NewLocalData

func NewLocalData() *LocalData

func (*LocalData) DumpConfig

func (d *LocalData) DumpConfig() []byte

func (*LocalData) Get

func (d *LocalData) Get(domain string) ([]string, bool)

func (*LocalData) GetIpList

func (h *LocalData) GetIpList(domain string, family int) ([]net.IP, bool)

func (*LocalData) ReplaceHosts

func (d *LocalData) ReplaceHosts(hosts map[string][]string)

func (*LocalData) ReplaceWildcardHosts

func (d *LocalData) ReplaceWildcardHosts(data map[string][]string)

func (*LocalData) ReplaceWildcardHostsWithBytes

func (d *LocalData) ReplaceWildcardHostsWithBytes(buf []byte)

type MemoryCache

type MemoryCache struct {
	Backend  map[string]Mesg
	Expire   time.Duration
	Maxcount int
	// contains filtered or unexported fields
}

func (*MemoryCache) Exists

func (c *MemoryCache) Exists(key string) bool

func (*MemoryCache) Full

func (c *MemoryCache) Full() bool

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) (*dns.Msg, error)

func (*MemoryCache) Length

func (c *MemoryCache) Length() int

func (*MemoryCache) Remove

func (c *MemoryCache) Remove(key string) error

func (*MemoryCache) Set

func (c *MemoryCache) Set(key string, msg *dns.Msg) error

type Mesg

type Mesg struct {
	Msg    *dns.Msg
	Expire time.Time
}

type Question

type Question struct {
	// contains filtered or unexported fields
}

func (*Question) String

func (q *Question) String() string

type RResp

type RResp struct {
	// contains filtered or unexported fields
}

type ResolvError

type ResolvError struct {
	// contains filtered or unexported fields
}

func (ResolvError) Error

func (e ResolvError) Error() string

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(mainAddr string) *Resolver

func (*Resolver) DumpConfig

func (r *Resolver) DumpConfig() []byte

func (*Resolver) Lookup

func (r *Resolver) Lookup(net string, req *dns.Msg) (message *dns.Msg, err error)

Lookup will ask each nameserver in top-to-bottom fashion, starting a new request in every second, and return as early as possbile (have an answer). It returns an error if no request has succeeded.

func (*Resolver) ReplaceDomainServers

func (r *Resolver) ReplaceDomainServers(data map[string][]string)

func (*Resolver) Timeout

func (r *Resolver) Timeout() time.Duration

func (*Resolver) UpdateResolvServers

func (r *Resolver) UpdateResolvServers()

type SerializerError

type SerializerError struct {
	// contains filtered or unexported fields
}

func (SerializerError) Error

func (e SerializerError) Error() string

type Server

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

func New

func New(addr string, log *logrus.Logger) *Server

func (*Server) DoTCP

func (srv *Server) DoTCP(w dns.ResponseWriter, req *dns.Msg)

func (*Server) DoUDP

func (srv *Server) DoUDP(w dns.ResponseWriter, req *dns.Msg)

func (*Server) DumpAllConfig

func (self *Server) DumpAllConfig() string

func (*Server) InitResolvConf

func (self *Server) InitResolvConf()

func (*Server) ReplaceAddresses

func (self *Server) ReplaceAddresses(data map[string][]string)

func (*Server) ReplaceDomainServers

func (self *Server) ReplaceDomainServers(data map[string][]string)

func (*Server) ReplaceHosts

func (self *Server) ReplaceHosts(data map[string][]string)

func (*Server) Run

func (srv *Server) Run()

func (*Server) RunResolvConf

func (self *Server) RunResolvConf()

func (*Server) Stop

func (srv *Server) Stop()

func (*Server) StopResolvConf

func (self *Server) StopResolvConf()

Jump to

Keyboard shortcuts

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