cosmetic: more linting
This commit is contained in:
1 parent
1ad950f177
commit
2500bc210a
5 files changed
+25
-25
No files matched your search
@@ -69,7 +69,7 @@ func (s *MDNSServer) Start(ifi *net.Interface, localDomain string) error {
|
|||||||
|
|
||||||
mux := dns.NewServeMux()
|
mux := dns.NewServeMux()
|
||||||
mux.HandleFunc(localDomain, handleLocal)
|
mux.HandleFunc(localDomain, handleLocal)
|
||||||
mux.HandleFunc(RDNS_DOMAIN, handleReverse)
|
mux.HandleFunc(RDNSDomain, handleReverse)
|
||||||
|
|
||||||
s.srv = &dns.Server{
|
s.srv = &dns.Server{
|
||||||
Listener: nil,
|
Listener: nil,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func TestServerSimpleQuery(t *testing.T) {
|
|||||||
|
|
||||||
mdnsServer, err := NewMDNSServer(zone)
|
mdnsServer, err := NewMDNSServer(zone)
|
||||||
wt.AssertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
err = mdnsServer.Start(nil, DEFAULT_LOCAL_DOMAIN)
|
err = mdnsServer.Start(nil, DefaultLocalDomain)
|
||||||
wt.AssertNoErr(t, err)
|
wt.AssertNoErr(t, err)
|
||||||
|
|
||||||
var receivedAddr net.IP
|
var receivedAddr net.IP
|
||||||
|
|||||||
+16
-16
@@ -11,15 +11,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEFAULT_LOCAL_DOMAIN = "weave.local." // The default name used for the local domain
|
DefaultLocalDomain = "weave.local." // The default name used for the local domain
|
||||||
DEFAULT_SERVER_PORT = 53 // The default server port
|
DefaultServerPort = 53 // The default server port
|
||||||
DEFAULT_CLI_CFG_FILE = "/etc/resolv.conf" // default "resolv.conf" file to try to load
|
DefaultCLICfgFile = "/etc/resolv.conf" // default "resolv.conf" file to try to load
|
||||||
DEFAULT_UDP_BUFLEN = 4096 // bigger than the default 512
|
DefaultUDPBuflen = 4096 // bigger than the default 512
|
||||||
DEFAULT_CACHE_LEN = 8192 // default cache capacity
|
DefaultCacheLen = 8192 // default cache capacity
|
||||||
DEFAULT_RESOLV_WORKERS = 8 // default number of resolution workers
|
DefaultResolvWorkers = 8 // default number of resolution workers
|
||||||
DEFAULT_TIMEOUT = 5 // default timeout for DNS resolutions
|
DefaultTimeout = 5 // default timeout for DNS resolutions
|
||||||
DEFAULT_IFACE_NAME = "default interface"
|
DefaultIfaceName = "default interface"
|
||||||
DEFAULT_RESOLV_TRIES = 3 // max # of times a worker tries to resolve a query
|
DefaultResolvTries = 3 // max # of times a worker tries to resolve a query
|
||||||
)
|
)
|
||||||
|
|
||||||
type DNSServerConfig struct {
|
type DNSServerConfig struct {
|
||||||
@@ -92,9 +92,9 @@ func NewDNSServer(config DNSServerConfig, zone Zone, iface *net.Interface) (s *D
|
|||||||
iface: iface,
|
iface: iface,
|
||||||
listenersWg: new(sync.WaitGroup),
|
listenersWg: new(sync.WaitGroup),
|
||||||
|
|
||||||
Domain: DEFAULT_LOCAL_DOMAIN,
|
Domain: DefaultLocalDomain,
|
||||||
IfaceName: DEFAULT_IFACE_NAME,
|
IfaceName: DefaultIfaceName,
|
||||||
ListenAddr: fmt.Sprintf(":%d", DEFAULT_SERVER_PORT),
|
ListenAddr: fmt.Sprintf(":%d", DefaultServerPort),
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill empty parameters with defaults...
|
// fill empty parameters with defaults...
|
||||||
@@ -107,7 +107,7 @@ func NewDNSServer(config DNSServerConfig, zone Zone, iface *net.Interface) (s *D
|
|||||||
if config.UpstreamCfg != nil {
|
if config.UpstreamCfg != nil {
|
||||||
s.upstream = config.UpstreamCfg
|
s.upstream = config.UpstreamCfg
|
||||||
} else {
|
} else {
|
||||||
cfgFile := DEFAULT_CLI_CFG_FILE
|
cfgFile := DefaultCLICfgFile
|
||||||
if len(config.UpstreamCfgFile) > 0 {
|
if len(config.UpstreamCfgFile) > 0 {
|
||||||
cfgFile = config.UpstreamCfgFile
|
cfgFile = config.UpstreamCfgFile
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ func NewDNSServer(config DNSServerConfig, zone Zone, iface *net.Interface) (s *D
|
|||||||
if iface != nil {
|
if iface != nil {
|
||||||
s.IfaceName = iface.Name
|
s.IfaceName = iface.Name
|
||||||
}
|
}
|
||||||
cacheLen := DEFAULT_CACHE_LEN
|
cacheLen := DefaultCacheLen
|
||||||
if config.CacheLen > 0 {
|
if config.CacheLen > 0 {
|
||||||
cacheLen = config.CacheLen
|
cacheLen = config.CacheLen
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ func NewDNSServer(config DNSServerConfig, zone Zone, iface *net.Interface) (s *D
|
|||||||
mux := func(proto dnsProtocol) *dns.ServeMux {
|
mux := func(proto dnsProtocol) *dns.ServeMux {
|
||||||
m := dns.NewServeMux()
|
m := dns.NewServeMux()
|
||||||
m.HandleFunc(s.Domain, s.queryHandler([]Lookup{s.zone, s.mdnsCli}, proto))
|
m.HandleFunc(s.Domain, s.queryHandler([]Lookup{s.zone, s.mdnsCli}, proto))
|
||||||
m.HandleFunc(RDNS_DOMAIN, s.rdnsHandler([]Lookup{s.zone, s.mdnsCli}, proto))
|
m.HandleFunc(RDNSDomain, s.rdnsHandler([]Lookup{s.zone, s.mdnsCli}, proto))
|
||||||
m.HandleFunc(".", s.notUsHandler(proto))
|
m.HandleFunc(".", s.notUsHandler(proto))
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
@@ -323,7 +323,7 @@ func (s *DNSServer) rdnsHandler(lookups []Lookup, proto dnsProtocol) dns.Handler
|
|||||||
// When we receive a request for a name outside of our '.weave.local.'
|
// When we receive a request for a name outside of our '.weave.local.'
|
||||||
// domain, ask the configured DNS server as a fallback.
|
// domain, ask the configured DNS server as a fallback.
|
||||||
func (s *DNSServer) notUsHandler(proto dnsProtocol) dns.HandlerFunc {
|
func (s *DNSServer) notUsHandler(proto dnsProtocol) dns.HandlerFunc {
|
||||||
dnsClient := proto.GetNewClient(DEFAULT_UDP_BUFLEN)
|
dnsClient := proto.GetNewClient(DefaultUDPBuflen)
|
||||||
|
|
||||||
return func(w dns.ResponseWriter, r *dns.Msg) {
|
return func(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
maxLen := getMaxReplyLen(r, proto)
|
maxLen := getMaxReplyLen(r, proto)
|
||||||
|
|||||||
+2
-2
@@ -10,11 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RDNS_DOMAIN = "in-addr.arpa."
|
RDNSDomain = "in-addr.arpa."
|
||||||
)
|
)
|
||||||
|
|
||||||
// +1 to also exclude a dot
|
// +1 to also exclude a dot
|
||||||
var rdnsDomainLen = len(RDNS_DOMAIN) + 1
|
var rdnsDomainLen = len(RDNSDomain) + 1
|
||||||
|
|
||||||
type Lookup interface {
|
type Lookup interface {
|
||||||
LookupName(name string) (net.IP, error)
|
LookupName(name string) (net.IP, error)
|
||||||
|
|||||||
+5
-5
@@ -38,14 +38,14 @@ func main() {
|
|||||||
flag.BoolVar(&justVersion, "version", false, "print version and exit")
|
flag.BoolVar(&justVersion, "version", false, "print version and exit")
|
||||||
flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast")
|
flag.StringVar(&ifaceName, "iface", "", "name of interface to use for multicast")
|
||||||
flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "path to Docker API socket")
|
flag.StringVar(&apiPath, "api", "unix:///var/run/docker.sock", "path to Docker API socket")
|
||||||
flag.StringVar(&localDomain, "localDomain", weavedns.DEFAULT_LOCAL_DOMAIN, "local domain (ie, 'weave.local.')")
|
flag.StringVar(&localDomain, "localDomain", weavedns.DefaultLocalDomain, "local domain (ie, 'weave.local.')")
|
||||||
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up")
|
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up")
|
||||||
flag.IntVar(&dnsPort, "dnsport", weavedns.DEFAULT_SERVER_PORT, "port to listen to DNS requests")
|
flag.IntVar(&dnsPort, "dnsport", weavedns.DefaultServerPort, "port to listen to DNS requests")
|
||||||
flag.IntVar(&httpPort, "httpport", 6785, "port to listen to HTTP requests")
|
flag.IntVar(&httpPort, "httpport", 6785, "port to listen to HTTP requests")
|
||||||
flag.StringVar(&fallback, "fallback", "", "force a fallback (ie, '8.8.8.8:53') instead of /etc/resolv.conf values")
|
flag.StringVar(&fallback, "fallback", "", "force a fallback (ie, '8.8.8.8:53') instead of /etc/resolv.conf values")
|
||||||
flag.IntVar(&timeout, "timeout", weavedns.DEFAULT_TIMEOUT, "timeout for resolutions")
|
flag.IntVar(&timeout, "timeout", weavedns.DefaultTimeout, "timeout for resolutions")
|
||||||
flag.IntVar(&udpbuf, "udpbuf", weavedns.DEFAULT_UDP_BUFLEN, "UDP buffer length")
|
flag.IntVar(&udpbuf, "udpbuf", weavedns.DefaultUDPBuflen, "UDP buffer length")
|
||||||
flag.IntVar(&cacheLen, "cache", weavedns.DEFAULT_CACHE_LEN, "cache length")
|
flag.IntVar(&cacheLen, "cache", weavedns.DefaultCacheLen, "cache length")
|
||||||
flag.BoolVar(&watch, "watch", true, "watch the docker socket for container events")
|
flag.BoolVar(&watch, "watch", true, "watch the docker socket for container events")
|
||||||
flag.BoolVar(&debug, "debug", false, "output debugging info to stderr")
|
flag.BoolVar(&debug, "debug", false, "output debugging info to stderr")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|||||||
Reference in new issue
Block a user