Merge pull request #773 from inercia/weave-restore-fallback
Restore the "--fallback" argument in WeaveDNS
This commit is contained in:
commit
ed133dfe0d
1 file changed
+12
-1
+12
-1
@@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/miekg/dns"
|
||||||
. "github.com/weaveworks/weave/common"
|
. "github.com/weaveworks/weave/common"
|
||||||
"github.com/weaveworks/weave/common/updater"
|
"github.com/weaveworks/weave/common/updater"
|
||||||
weavedns "github.com/weaveworks/weave/nameserver"
|
weavedns "github.com/weaveworks/weave/nameserver"
|
||||||
@@ -25,6 +26,7 @@ func main() {
|
|||||||
wait int
|
wait int
|
||||||
timeout int
|
timeout int
|
||||||
udpbuf int
|
udpbuf int
|
||||||
|
fallback string
|
||||||
refreshInterval int
|
refreshInterval int
|
||||||
refreshWorkers int
|
refreshWorkers int
|
||||||
relevantTime int
|
relevantTime int
|
||||||
@@ -54,7 +56,7 @@ func main() {
|
|||||||
flag.IntVar(&udpbuf, "udpbuf", weavedns.DefaultUDPBuflen, "UDP buffer length")
|
flag.IntVar(&udpbuf, "udpbuf", weavedns.DefaultUDPBuflen, "UDP buffer length")
|
||||||
flag.IntVar(&timeout, "timeout", weavedns.DefaultTimeout, "timeout for resolutions (in millisecs)")
|
flag.IntVar(&timeout, "timeout", weavedns.DefaultTimeout, "timeout for resolutions (in millisecs)")
|
||||||
flag.BoolVar(&cacheDisabled, "no-cache", false, "disable the cache")
|
flag.BoolVar(&cacheDisabled, "no-cache", false, "disable the cache")
|
||||||
|
flag.StringVar(&fallback, "fallback", "", "force a fallback server (ie, '8.8.8.8:53') (instead of /etc/resolv.conf values)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if justVersion {
|
if justVersion {
|
||||||
@@ -111,6 +113,15 @@ func main() {
|
|||||||
CacheDisabled: cacheDisabled,
|
CacheDisabled: cacheDisabled,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(fallback) > 0 {
|
||||||
|
fallbackHost, fallbackPort, err := net.SplitHostPort(fallback)
|
||||||
|
if err != nil {
|
||||||
|
Error.Fatal("[main] Could not parse fallback host and port", err)
|
||||||
|
}
|
||||||
|
srvConfig.UpstreamCfg = &dns.ClientConfig{Servers: []string{fallbackHost}, Port: fallbackPort}
|
||||||
|
Debug.Printf("[main] DNS fallback at %s:%s", fallbackHost, fallbackPort)
|
||||||
|
}
|
||||||
|
|
||||||
srv, err := weavedns.NewDNSServer(srvConfig)
|
srv, err := weavedns.NewDNSServer(srvConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Error.Fatal("[main] Failed to initialize the WeaveDNS server", err)
|
Error.Fatal("[main] Failed to initialize the WeaveDNS server", err)
|
||||||
|
|||||||
Reference in new issue
Block a user