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
|
peerCount int
|
||||||
apiPath string
|
apiPath string
|
||||||
peers []string
|
peers []string
|
||||||
|
noDNS bool
|
||||||
dnsDomain string
|
dnsDomain string
|
||||||
dnsPort int
|
dnsPort int
|
||||||
dnsTTL 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.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.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.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.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(&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")
|
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")
|
Log.Fatal("--init-peer-count flag specified without --ipalloc-range")
|
||||||
}
|
}
|
||||||
|
|
||||||
ns := nameserver.New(router.Ourself.Peer.Name, router.Peers, dockerCli, dnsDomain)
|
var (
|
||||||
ns.SetGossip(router.NewGossip("nameserver", ns))
|
ns *nameserver.Nameserver
|
||||||
if err = dockerCli.AddObserver(ns); err != nil {
|
dnsserver *nameserver.DNSServer
|
||||||
Log.Fatal("Unable to start watcher", err)
|
)
|
||||||
|
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()
|
router.Start()
|
||||||
if errors := router.ConnectionMaker.InitiateConnections(peers, false); len(errors) > 0 {
|
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)
|
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) {
|
muxRouter.Methods("GET").Path("/status").Headers("Accept", "application/json").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
json, _ := router.StatusJSON(version)
|
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, "Allocator default subnet:", defaultSubnet)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, "")
|
fmt.Fprintln(w, "")
|
||||||
fmt.Fprintln(w, dnsserver.String())
|
if dnsserver == nil {
|
||||||
fmt.Fprintln(w, ns.String())
|
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) {
|
muxRouter.Methods("POST").Path("/connect").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -1028,6 +1028,7 @@ launch_router() {
|
|||||||
ARGS=""
|
ARGS=""
|
||||||
IPRANGE=
|
IPRANGE=
|
||||||
IPRANGE_SPECIFIED=
|
IPRANGE_SPECIFIED=
|
||||||
|
DNS_PORT_MAPPING="-p $DOCKER_BRIDGE_IP:53:53/udp -p $DOCKER_BRIDGE_IP:53:53/tcp"
|
||||||
while [ $# -gt 0 ] ; do
|
while [ $# -gt 0 ] ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-password|--password)
|
-password|--password)
|
||||||
@@ -1058,6 +1059,10 @@ launch_router() {
|
|||||||
IPRANGE="${1#*=}"
|
IPRANGE="${1#*=}"
|
||||||
IPRANGE_SPECIFIED=1
|
IPRANGE_SPECIFIED=1
|
||||||
;;
|
;;
|
||||||
|
--no-dns)
|
||||||
|
DNS_PORT_MAPPING=
|
||||||
|
ARGS="$ARGS $1"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
ARGS="$ARGS '$(echo "$1" | sed "s|'|'\"'\"'|g")'"
|
ARGS="$ARGS '$(echo "$1" | sed "s|'|'\"'\"'|g")'"
|
||||||
;;
|
;;
|
||||||
@@ -1077,8 +1082,7 @@ launch_router() {
|
|||||||
# additional parameters, such as resource limits, to docker
|
# additional parameters, such as resource limits, to docker
|
||||||
# when launching the weave container.
|
# when launching the weave container.
|
||||||
ROUTER_CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME \
|
ROUTER_CONTAINER=$(docker run --privileged -d --name=$CONTAINER_NAME \
|
||||||
-p $PORT:$CONTAINER_PORT/tcp -p $PORT:$CONTAINER_PORT/udp \
|
-p $PORT:$CONTAINER_PORT/tcp -p $PORT:$CONTAINER_PORT/udp $DNS_PORT_MAPPING \
|
||||||
-p $DOCKER_BRIDGE_IP:53:53/udp -p $DOCKER_BRIDGE_IP:53:53/tcp \
|
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
-e WEAVE_PASSWORD \
|
-e WEAVE_PASSWORD \
|
||||||
-e WEAVE_CIDR=none \
|
-e WEAVE_CIDR=none \
|
||||||
@@ -1089,12 +1093,14 @@ launch_router() {
|
|||||||
# Tell the newly-started weave IP allocator about existing weave IPs
|
# Tell the newly-started weave IP allocator about existing weave IPs
|
||||||
with_container_addresses ipam_claim weave:expose $(docker ps -q --no-trunc)
|
with_container_addresses ipam_claim weave:expose $(docker ps -q --no-trunc)
|
||||||
fi
|
fi
|
||||||
# Tell the newly-started weaveDNS about existing weave IPs
|
if [ -n "$DNS_PORT_MAPPING" ] ; then
|
||||||
for CONTAINER in $(docker ps -q --no-trunc) ; do
|
# Tell the newly-started weaveDNS about existing weave IPs
|
||||||
if CONTAINER_IPS=$(with_container_netns $CONTAINER container_weave_addrs 2>&1 | sed -n -e 's/inet \([^/]*\)\/\(.*\)/\1/p') ; then
|
for CONTAINER in $(docker ps -q --no-trunc) ; do
|
||||||
with_container_fqdn $CONTAINER put_dns_fqdn $CONTAINER_IPS
|
if CONTAINER_IPS=$(with_container_netns $CONTAINER container_weave_addrs 2>&1 | sed -n -e 's/inet \([^/]*\)\/\(.*\)/\1/p') ; then
|
||||||
fi
|
with_container_fqdn $CONTAINER put_dns_fqdn $CONTAINER_IPS
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
launch_proxy() {
|
launch_proxy() {
|
||||||
|
|||||||
Reference in new issue
Block a user