introduce --no-dns option
undocumented, since it is mainly meant for testing
This commit is contained in:
1 parent
5b62b8c1e3
commit
fafaeef07d
2 files changed
+43
-25
No files matched your search
+29
-17
@@ -55,6 +55,7 @@ func main() {
|
||||
peerCount int
|
||||
apiPath string
|
||||
peers []string
|
||||
noDNS bool
|
||||
dnsDomain string
|
||||
dnsPort int
|
||||
dnsTTL int
|
||||
@@ -80,6 +81,7 @@ func main() {
|
||||
mflag.StringVar(&ipsubnetCIDR, []string{"#ipsubnet", "#-ipsubnet", "-ipalloc-default-subnet"}, "", "subnet to allocate within by default, in CIDR notation")
|
||||
mflag.IntVar(&peerCount, []string{"#initpeercount", "#-initpeercount", "-init-peer-count"}, 0, "number of peers in network (for IP address allocation)")
|
||||
mflag.StringVar(&apiPath, []string{"#api", "-api"}, "unix:///var/run/docker.sock", "Path to Docker API socket")
|
||||
mflag.BoolVar(&noDNS, []string{"-no-dns"}, false, "disable DNS server")
|
||||
mflag.StringVar(&dnsDomain, []string{"-dns-domain"}, nameserver.DefaultDomain, "local domain to server requests for")
|
||||
mflag.IntVar(&dnsPort, []string{"-dns-port"}, nameserver.DefaultPort, "port to listen on for DNS requests")
|
||||
mflag.IntVar(&dnsTTL, []string{"-dns-ttl"}, nameserver.DefaultTTL, "TTL for DNS request from our domain")
|
||||
@@ -169,21 +171,25 @@ func main() {
|
||||
Log.Fatal("--init-peer-count flag specified without --ipalloc-range")
|
||||
}
|
||||
|
||||
ns := nameserver.New(router.Ourself.Peer.Name, router.Peers, dockerCli, dnsDomain)
|
||||
ns.SetGossip(router.NewGossip("nameserver", ns))
|
||||
if err = dockerCli.AddObserver(ns); err != nil {
|
||||
Log.Fatal("Unable to start watcher", err)
|
||||
var (
|
||||
ns *nameserver.Nameserver
|
||||
dnsserver *nameserver.DNSServer
|
||||
)
|
||||
if !noDNS {
|
||||
ns = nameserver.New(router.Ourself.Peer.Name, router.Peers, dockerCli, dnsDomain)
|
||||
ns.SetGossip(router.NewGossip("nameserver", ns))
|
||||
if err = dockerCli.AddObserver(ns); err != nil {
|
||||
Log.Fatal("Unable to start watcher", err)
|
||||
}
|
||||
ns.Start()
|
||||
defer ns.Stop()
|
||||
dnsserver, err = nameserver.NewDNSServer(ns, dnsDomain, dnsPort, uint32(dnsTTL), dnsClientTimeout)
|
||||
if err != nil {
|
||||
Log.Fatal("Unable to start dns server: ", err)
|
||||
}
|
||||
dnsserver.ActivateAndServe()
|
||||
defer dnsserver.Stop()
|
||||
}
|
||||
ns.Start()
|
||||
defer ns.Stop()
|
||||
|
||||
dnsserver, err := nameserver.NewDNSServer(ns, dnsDomain, dnsPort,
|
||||
uint32(dnsTTL), dnsClientTimeout)
|
||||
if err != nil {
|
||||
Log.Fatal("Unable to start dns server: ", err)
|
||||
}
|
||||
dnsserver.ActivateAndServe()
|
||||
defer dnsserver.Stop()
|
||||
|
||||
router.Start()
|
||||
if errors := router.ConnectionMaker.InitiateConnections(peers, false); len(errors) > 0 {
|
||||
@@ -305,7 +311,9 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
|
||||
allocator.HandleHTTP(muxRouter, defaultSubnet, docker)
|
||||
}
|
||||
|
||||
ns.HandleHTTP(muxRouter)
|
||||
if ns != nil {
|
||||
ns.HandleHTTP(muxRouter)
|
||||
}
|
||||
|
||||
muxRouter.Methods("GET").Path("/status").Headers("Accept", "application/json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
json, _ := router.StatusJSON(version)
|
||||
@@ -321,8 +329,12 @@ func handleHTTP(router *weave.Router, httpAddr string, allocator *ipam.Allocator
|
||||
fmt.Fprintln(w, "Allocator default subnet:", defaultSubnet)
|
||||
}
|
||||
fmt.Fprintln(w, "")
|
||||
fmt.Fprintln(w, dnsserver.String())
|
||||
fmt.Fprintln(w, ns.String())
|
||||
if dnsserver == nil {
|
||||
fmt.Fprintln(w, "WeaveDNS is disabled")
|
||||
} else {
|
||||
fmt.Fprintln(w, dnsserver.String())
|
||||
fmt.Fprintln(w, ns.String())
|
||||
}
|
||||
})
|
||||
|
||||
muxRouter.Methods("POST").Path("/connect").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -1028,6 +1028,7 @@ launch_router() {
|
||||
ARGS=""
|
||||
IPRANGE=
|
||||
IPRANGE_SPECIFIED=
|
||||
DNS_PORT_MAPPING="-p $DOCKER_BRIDGE_IP:53:53/udp -p $DOCKER_BRIDGE_IP:53:53/tcp"
|
||||
while [ $# -gt 0 ] ; do
|
||||
case "$1" in
|
||||
-password|--password)
|
||||
@@ -1058,6 +1059,10 @@ launch_router() {
|
||||
IPRANGE="${1#*=}"
|
||||
IPRANGE_SPECIFIED=1
|
||||
;;
|
||||
--no-dns)
|
||||
DNS_PORT_MAPPING=
|
||||
ARGS="$ARGS $1"
|
||||
;;
|
||||
*)
|
||||
ARGS="$ARGS '$(echo "$1" | sed "s|'|'\"'\"'|g")'"
|
||||
;;
|
||||
@@ -1077,8 +1082,7 @@ launch_router() {
|
||||
# additional parameters, such as resource limits, to docker
|
||||
# when launching the weave container.
|
||||
ROUTER_CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME \
|
||||
-p $PORT:$CONTAINER_PORT/tcp -p $PORT:$CONTAINER_PORT/udp \
|
||||
-p $DOCKER_BRIDGE_IP:53:53/udp -p $DOCKER_BRIDGE_IP:53:53/tcp \
|
||||
-p $PORT:$CONTAINER_PORT/tcp -p $PORT:$CONTAINER_PORT/udp $DNS_PORT_MAPPING \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-e WEAVE_PASSWORD \
|
||||
-e WEAVE_CIDR=none \
|
||||
@@ -1089,12 +1093,14 @@ launch_router() {
|
||||
# Tell the newly-started weave IP allocator about existing weave IPs
|
||||
with_container_addresses ipam_claim weave:expose $(docker ps -q --no-trunc)
|
||||
fi
|
||||
# Tell the newly-started weaveDNS about existing weave IPs
|
||||
for CONTAINER in $(docker ps -q --no-trunc) ; do
|
||||
if CONTAINER_IPS=$(with_container_netns $CONTAINER container_weave_addrs 2>&1 | sed -n -e 's/inet \([^/]*\)\/\(.*\)/\1/p') ; then
|
||||
with_container_fqdn $CONTAINER put_dns_fqdn $CONTAINER_IPS
|
||||
fi
|
||||
done
|
||||
if [ -n "$DNS_PORT_MAPPING" ] ; then
|
||||
# Tell the newly-started weaveDNS about existing weave IPs
|
||||
for CONTAINER in $(docker ps -q --no-trunc) ; do
|
||||
if CONTAINER_IPS=$(with_container_netns $CONTAINER container_weave_addrs 2>&1 | sed -n -e 's/inet \([^/]*\)\/\(.*\)/\1/p') ; then
|
||||
with_container_fqdn $CONTAINER put_dns_fqdn $CONTAINER_IPS
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
launch_proxy() {
|
||||
|
||||
Reference in new issue
Block a user