Documentation ¶
Overview ¶
Package dnsserver implements a DNS server, that uses the given resolvers to handle requests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCachingResolver ¶
func NewCachingResolver(back Resolver) *cachingResolver
NewCachingResolver returns a new resolver which implements a cache on top of the given one.
Types ¶
type DomainMap ¶
DomainMap maps a DNS name to an arbitrary string.
func DomainMapFromString ¶
DomainMapFromString takes a string in the form of "domain1:addr1,domain2:addr2,..." and returns a dnsserver.DomainMap like {"domain1": "addr1", "domain2": "addr2", ...}.
func (DomainMap) GetExact ¶
GetExact value for the given domain, using an exact lookup (the domain must match exactly what was set).
func (DomainMap) GetMostSpecific ¶
GetMostSpecific value for the given domain, using a most-specific lookup (we pick the map entry that is closest to the domain).
type Resolver ¶
type Resolver interface { // Initialize the resolver. Init() error // Maintain performs resolver maintenance. It's expected to run // indefinitely, but may return early if appropriate. Maintain() // Query responds to a DNS query. Query(r *dns.Msg, tr *trace.Trace) (*dns.Msg, error) }
Resolver is the interface for DNS resolvers that can answer queries.
type Server ¶
type Server struct { Addr string // contains filtered or unexported fields }
Server implements a DNS proxy, which will (mostly) use the given resolver to resolve queries.
func New ¶
New *Server, which will listen on addr, use resolver as the backend resolver, and use unqUpstream to resolve unqualified queries.
func (*Server) Handler ¶
func (s *Server) Handler(w dns.ResponseWriter, r *dns.Msg)
Handler for the incoming DNS queries.
func (*Server) ListenAndServe ¶
func (s *Server) ListenAndServe()
ListenAndServe launches the DNS proxy.