dns

package
v0.0.0-...-bed98e0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DomainRegistry

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

DomainRegistry is a thread-safe domain to address map, it also handles creation of domains through getDomain method

func NewDomainRegistry

func NewDomainRegistry(logger *log.Logger, domainSuffix string) *DomainRegistry

NewDomainRegistry creates new registry using provided domainSuffix for domain creation

func (*DomainRegistry) AddRecord

func (r *DomainRegistry) AddRecord(c container.Container)

AddRecord constructs a domain and adds a domain record for it, blocks until all current reads are done

func (*DomainRegistry) HandleEvent

func (r *DomainRegistry) HandleEvent(event container.Event)

HandleEvent translates container events into appropriate actions e.g. adding or removing domain record for container

func (*DomainRegistry) RemoveRecord

func (r *DomainRegistry) RemoveRecord(c container.Container)

RemoveRecord constructs a domain and removes corresponding domain record, blocks until all current reads are done

func (*DomainRegistry) ResolveDomain

func (r *DomainRegistry) ResolveDomain(domain string) string

ResolveDomain resolves domain address, if not present returns an empty string

type Server

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

Server is the DNS server wrapper object for dependency isolation, also implements dns.Handler for convenience

func NewServer

func NewServer(logger *log.Logger, host string, port int, protocol string, registry *DomainRegistry) *Server

NewServer creates new server on specified host protocol and port and using provided DomainRegistry for domain resolution

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe blocks and listens to requests

func (*Server) ServeDNS

func (s *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS is part of dns.Handler interface implementation, handles all DNS requests

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown blocks and shutdowns internal dns.Server

Jump to

Keyboard shortcuts

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