Documentation
¶
Index ¶
- Constants
- func LinkLocalMulticastListener(ifi *net.Interface) (net.PacketConn, error)
- func ListenHTTP(version string, server *DNSServer, domain string, db Zone, port int)
- type Cache
- func (c *Cache) Capacity() int
- func (c *Cache) Clear()
- func (c *Cache) Get(request *dns.Msg, maxLen int) (reply *dns.Msg, err error)
- func (c *Cache) Len() int
- func (c *Cache) Purge()
- func (c *Cache) Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8) int
- func (c *Cache) Remove(question *dns.Question)
- func (c *Cache) String() string
- type DNSServer
- type DNSServerConfig
- type DuplicateError
- type IPv4
- type LookupError
- type LookupFunc
- type MDNSAction
- type MDNSClient
- func (client *MDNSClient) InsistentLookupInaddr(inaddr string) ([]ZoneRecord, error)
- func (client *MDNSClient) InsistentLookupName(name string) ([]ZoneRecord, error)
- func (client *MDNSClient) LookupInaddr(inaddr string) ([]ZoneRecord, error)
- func (client *MDNSClient) LookupName(name string) ([]ZoneRecord, error)
- func (c *MDNSClient) ResponseCallback(r *dns.Msg)
- func (c *MDNSClient) SendQuery(name string, querytype uint16, insistent bool, responseCh chan<- *Response)
- func (c *MDNSClient) Start(ifi *net.Interface) (err error)
- func (c *MDNSClient) Stop() error
- type MDNSServer
- type Record
- type Response
- type Zone
- type ZoneCache
- type ZoneDb
- func (zone *ZoneDb) AddRecord(ident string, name string, ip net.IP) error
- func (zone *ZoneDb) ContainerDied(ident string) error
- func (zone *ZoneDb) DeleteRecord(ident string, ip net.IP) error
- func (zone *ZoneDb) DeleteRecordsFor(ident string) error
- func (zone *ZoneDb) Domain() string
- func (zone *ZoneDb) LookupInaddr(inaddr string) ([]ZoneRecord, error)
- func (zone *ZoneDb) LookupName(name string) ([]ZoneRecord, error)
- func (zone *ZoneDb) String() string
- type ZoneLookup
- type ZoneObserver
- type ZoneRecord
- type ZoneRecordObserver
Constants ¶
const ( MaxDuration = time.Duration(math.MaxInt64) MailboxSize = 16 )
const ( DefaultLocalDomain = "weave.local." // The default name used for the local domain DefaultServerPort = 53 // The default server port DefaultCLICfgFile = "/etc/resolv.conf" // default "resolv.conf" file to try to load DefaultUDPBuflen = 4096 // bigger than the default 512 DefaultCacheLen = 8192 // default cache capacity DefaultResolvWorkers = 8 // default number of resolution workers DefaultTimeout = 5 // default timeout for DNS resolutions )
const (
CacheNoLocalReplies uint8 = 1 << iota // not found in local network (stored in the cache so we skip another local lookup or some time)
)
const (
RDNSDomain = "in-addr.arpa."
)
Variables ¶
This section is empty.
Functions ¶
func LinkLocalMulticastListener ¶
func LinkLocalMulticastListener(ifi *net.Interface) (net.PacketConn, error)
Types ¶
type Cache ¶ added in v0.10.0
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe fixed capacity LRU cache.
func (*Cache) Clear ¶ added in v0.10.0
func (c *Cache) Clear()
Clear removes all the entries in the cache
func (*Cache) Get ¶ added in v0.10.0
Look up for a question's reply from the cache. If no reply is stored in the cache, it returns a `nil` reply and no error.
func (*Cache) Purge ¶ added in v0.10.0
func (c *Cache) Purge()
Purge removes the old elements in the cache
func (*Cache) Put ¶ added in v0.10.0
Add adds a reply to the cache. When `ttl` is equal to `nullTTL`, the cache entry will be valid until the closest TTL in the `reply`
type DNSServer ¶ added in v0.10.0
type DNSServer struct {
Zone Zone
Iface *net.Interface
Upstream *dns.ClientConfig
Domain string // the local domain
ListenAddr string // the address the server is listening at
// contains filtered or unexported fields
}
func NewDNSServer ¶ added in v0.10.0
func NewDNSServer(config DNSServerConfig, zone Zone, iface *net.Interface) (s *DNSServer, err error)
Creates a new DNS server
type DNSServerConfig ¶ added in v0.10.0
type DNSServerConfig struct {
// (Optional) client config file for resolving upstream servers
UpstreamCfgFile string
// (Optional) DNS client config for the fallback server(s)
UpstreamCfg *dns.ClientConfig
// (Optional) port number (for TCP and UDP)
Port int
// (Optional) local domain (ie, "weave.local.")
LocalDomain string
// (Optional) cache size
CacheLen int
// (Optional) timeout for DNS queries
Timeout int
// (Optional) UDP buffer length
UDPBufLen int
}
type DuplicateError ¶
type DuplicateError struct {
}
func (DuplicateError) Error ¶
func (dup DuplicateError) Error() string
type IPv4 ¶ added in v0.11.0
type IPv4 [4]byte
simple IPv4 type that can be used as a key in a map (in contrast with net.IP), used for sets of IPs, etc...
type LookupError ¶
type LookupError string
func (LookupError) Error ¶
func (ops LookupError) Error() string
type LookupFunc ¶ added in v0.9.0
type MDNSAction ¶ added in v0.10.0
type MDNSAction func()
type MDNSClient ¶
type MDNSClient struct {
// contains filtered or unexported fields
}
func NewMDNSClient ¶
func NewMDNSClient() (*MDNSClient, error)
func (*MDNSClient) InsistentLookupInaddr ¶ added in v0.11.0
func (client *MDNSClient) InsistentLookupInaddr(inaddr string) ([]ZoneRecord, error)
Perform an insistent lookup for an IP address, returning either a list of names or an error Insistent queries will wait up to `mDNSTimeout` milliseconds for responses
func (*MDNSClient) InsistentLookupName ¶ added in v0.11.0
func (client *MDNSClient) InsistentLookupName(name string) ([]ZoneRecord, error)
Perform lookup for a name, returning either a list of IP addresses or an error Insistent queries will wait up to `mDNSTimeout` milliseconds for responses
func (*MDNSClient) LookupInaddr ¶ added in v0.9.0
func (client *MDNSClient) LookupInaddr(inaddr string) ([]ZoneRecord, error)
Perform a lookup for an IP address, returning either a name or an error
func (*MDNSClient) LookupName ¶ added in v0.9.0
func (client *MDNSClient) LookupName(name string) ([]ZoneRecord, error)
Perform a lookup for a name, returning either an IP address or an error
func (*MDNSClient) ResponseCallback ¶
func (c *MDNSClient) ResponseCallback(r *dns.Msg)
Async - called from dns library multiplexer
func (*MDNSClient) SendQuery ¶
func (c *MDNSClient) SendQuery(name string, querytype uint16, insistent bool, responseCh chan<- *Response)
Async
func (*MDNSClient) Stop ¶ added in v0.11.0
func (c *MDNSClient) Stop() error
type MDNSServer ¶
type MDNSServer struct {
// contains filtered or unexported fields
}
func NewMDNSServer ¶
func NewMDNSServer(zone Zone) (*MDNSServer, error)
Create a new mDNS server Nothing will be done (including port bindings) until you `Start()` the server
func (*MDNSServer) Start ¶
func (s *MDNSServer) Start(ifi *net.Interface) (err error)
Start the mDNS server
func (*MDNSServer) Zone ¶ added in v0.11.0
func (s *MDNSServer) Zone() Zone
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
A basic record struct (satisfying the ZoneRecord interface)
type ZoneCache ¶ added in v0.11.0
type ZoneCache interface {
// Get from the cache
Get(request *dns.Msg, maxLen int) (reply *dns.Msg, err error)
// Put in the cache
Put(request *dns.Msg, reply *dns.Msg, ttl int, flags uint8) int
// Remove from the cache
Remove(question *dns.Question)
// Purge all expired entries from the cache
Purge()
// Remove all entries
Clear()
// Return the cache length
Len() int
// Return the max capacity
Capacity() int
}
The cache interface
type ZoneDb ¶
type ZoneDb struct {
// contains filtered or unexported fields
}
Very simple data structure for now, with linear searching. TODO: make more sophisticated to improve performance.
func (*ZoneDb) ContainerDied ¶ added in v0.10.0
func (*ZoneDb) DeleteRecordsFor ¶
func (*ZoneDb) LookupInaddr ¶ added in v0.9.0
func (zone *ZoneDb) LookupInaddr(inaddr string) ([]ZoneRecord, error)
func (*ZoneDb) LookupName ¶ added in v0.9.0
func (zone *ZoneDb) LookupName(name string) ([]ZoneRecord, error)
type ZoneLookup ¶ added in v0.11.0
type ZoneLookup interface {
// Lookup for a name
LookupName(name string) ([]ZoneRecord, error)
// Lookup for an address
LookupInaddr(inaddr string) ([]ZoneRecord, error)
}
type ZoneObserver ¶ added in v0.11.0
type ZoneObserver interface {
// Observe anything that affects a particular name in the zone
ObserveName(name string, observer ZoneRecordObserver) error
// Observe anything that affects a particular IP in the zone
ObserveInaddr(inaddr string, observer ZoneRecordObserver) error
}
type ZoneRecord ¶ added in v0.11.0
type ZoneRecord interface {
Name() string // The name for this IP
IP() net.IP // The IP (v4) address
Priority() int // The priority
Weight() int // The weight
TTL() int // TTL
}
A zone record Note: we will try to keep all the zone records information is concentrated here. Maybe not all queries will
use things like priorities or weights, but we do not want to create a hierarchy for dealing with all possible queries...
type ZoneRecordObserver ¶ added in v0.11.0
type ZoneRecordObserver func()