From 878a12002c477f1daf1f4aea00e13ed490aec901 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sat, 7 Nov 2015 18:01:12 +0000 Subject: [PATCH] set http listen address solely through the weave script Previously it was set by the script only in fastdp mode; and in the router's main.go otherwise. Yet every interaction of the script with weave assumes the port is the script's HTTP_PORT=6784. By always starting the router with options to listen on that port we ensure that the router is in fact listening where the script expects it to. In doing this get rid of router.HTTPPort. We do need to hard-code the port in the proxy instead, but relying on router.HTTPPort was flawed anyway, for the above reasons. --- prog/weaver/main.go | 2 +- proxy/proxy.go | 3 +-- router/router.go | 1 - weave | 4 +++- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index c12f8e28..6620efcc 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -85,7 +85,7 @@ func main() { mflag.IntVar(&config.ConnLimit, []string{"#connlimit", "#-connlimit", "-conn-limit"}, 30, "connection limit (0 for unlimited)") mflag.BoolVar(&noDiscovery, []string{"#nodiscovery", "#-nodiscovery", "-no-discovery"}, false, "disable peer discovery") mflag.IntVar(&bufSzMB, []string{"#bufsz", "-bufsz"}, 8, "capture buffer size in MB") - mflag.StringVar(&httpAddr, []string{"#httpaddr", "#-httpaddr", "-http-addr"}, fmt.Sprintf(":%d", weave.HTTPPort), "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)") + mflag.StringVar(&httpAddr, []string{"#httpaddr", "#-httpaddr", "-http-addr"}, "", "address to bind HTTP interface to (disabled if blank, absolute path indicates unix domain socket)") mflag.StringVar(&iprangeCIDR, []string{"#iprange", "#-iprange", "-ipalloc-range"}, "", "IP address range reserved for automatic allocation, 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)") diff --git a/proxy/proxy.go b/proxy/proxy.go index 6618fe51..778742d4 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -17,7 +17,6 @@ import ( . "github.com/weaveworks/weave/common" weavedocker "github.com/weaveworks/weave/common/docker" "github.com/weaveworks/weave/nameserver" - "github.com/weaveworks/weave/router" ) const ( @@ -490,7 +489,7 @@ func (proxy *Proxy) getDNSDomain() (domain string) { weaveIP = "127.0.0.1" } - url := fmt.Sprintf("http://%s:%d/domain", weaveIP, router.HTTPPort) + url := fmt.Sprintf("http://%s:6784/domain", weaveIP) resp, err := http.Get(url) if err != nil || resp.StatusCode != http.StatusOK { return diff --git a/router/router.go b/router/router.go index 44c3fbdc..e02036bd 100644 --- a/router/router.go +++ b/router/router.go @@ -12,7 +12,6 @@ import ( const ( Port = 6783 - HTTPPort = Port + 1 MaxUDPPacketSize = 65535 ChannelSize = 16 TCPHeartbeat = 30 * time.Second diff --git a/weave b/weave index 2da34e83..80bcd57a 100755 --- a/weave +++ b/weave @@ -1463,6 +1463,7 @@ launch_router() { if [ "$BRIDGE_TYPE" = fastdp ] ; then NETHOST_OPT="--net=host" + HTTP_IP=127.0.0.1 # In case there is a lingering veth-weave netdev ip link del $ROUTER_HOSTNETNS_IFNAME >/dev/null 2>&1 || true fi @@ -1481,7 +1482,8 @@ launch_router() { $(router_opts_$BRIDGE_TYPE) \ --ipalloc-range "$IPRANGE" \ --dns-effective-listen-address $DOCKER_BRIDGE_IP \ - ${NETHOST_OPT:+$DNS_ROUTER_OPTS --http-addr 127.0.0.1:$HTTP_PORT} $NO_DNS_OPT \ + ${NETHOST_OPT:+$DNS_ROUTER_OPTS} $NO_DNS_OPT \ + --http-addr $HTTP_IP:$HTTP_PORT \ --docker-api "unix:///var/run/docker.sock" "$@") with_container_netns_or_die $CONTAINER_NAME setup_router_iface_$BRIDGE_TYPE attach_router