From b483be8c4b947b5320ab85b741e0840f86b24203 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 22 Jun 2015 11:10:42 +0100 Subject: [PATCH] remove the `-D` proxy option It doesn't do anything useful since the weave script needs to be able to talk to docker on the standard unix socket. Fixes #972. --- prog/weaveproxy/main.go | 7 +------ proxy/proxy.go | 32 +++++++------------------------- proxy/proxy_intercept.go | 2 +- weave | 4 ++-- 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go index c896d872..76466794 100644 --- a/prog/weaveproxy/main.go +++ b/prog/weaveproxy/main.go @@ -12,7 +12,6 @@ import ( var ( version = "(unreleased version)" - defaultDockerAddr = "unix:///var/run/docker.sock" defaultListenAddr = "tcp://0.0.0.0:12375" ) @@ -20,17 +19,13 @@ func main() { var ( debug bool justVersion bool - c = proxy.Config{ - DockerAddr: defaultDockerAddr, - ListenAddr: defaultListenAddr, - } + c = proxy.Config{ListenAddr: defaultListenAddr} ) c.Version = version getopt.BoolVarLong(&debug, "debug", 'd', "log debugging information") getopt.BoolVarLong(&justVersion, "version", 0, "print version and exit") getopt.StringVar(&c.ListenAddr, 'H', fmt.Sprintf("address on which to listen (default %s)", defaultListenAddr)) - getopt.StringVar(&c.DockerAddr, 'D', fmt.Sprintf("docker daemon URL to proxy (default %s)", defaultDockerAddr)) getopt.BoolVarLong(&c.NoDefaultIPAM, "no-default-ipam", 0, "do not automatically allocate addresses for containers without a WEAVE_CIDR") getopt.StringVarLong(&c.TLSConfig.CACert, "tlscacert", 0, "Trust certs signed only by this CA") getopt.StringVarLong(&c.TLSConfig.Cert, "tlscert", 0, "Path to TLS certificate file") diff --git a/proxy/proxy.go b/proxy/proxy.go index d629f221..e04b8824 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -4,7 +4,6 @@ import ( "crypto/tls" "net" "net/http" - "net/url" "regexp" "strings" @@ -25,7 +24,6 @@ var ( ) type Config struct { - DockerAddr string ListenAddr string NoDefaultIPAM bool TLSConfig TLSConfig @@ -36,32 +34,12 @@ type Config struct { type Proxy struct { Config - - dial func() (net.Conn, error) client *docker.Client dockerBridgeIP string } func NewProxy(c Config) (*Proxy, error) { - u, err := url.Parse(c.DockerAddr) - if err != nil { - return nil, err - } - - targetAddr := "" - switch u.Scheme { - case "tcp": - targetAddr = u.Host - case "unix": - targetAddr = u.Path - } - - p := &Proxy{ - Config: c, - dial: func() (net.Conn, error) { - return net.Dial(u.Scheme, targetAddr) - }, - } + p := &Proxy{Config: c} if !p.WithoutDNS { dockerBridgeIP, err := callWeave("docker-bridge-ip") @@ -75,14 +53,18 @@ func NewProxy(c Config) (*Proxy, error) { Error.Fatalf("Could not configure tls for proxy: %s", err) } - p.client, err = docker.NewClient(p.DockerAddr) + client, err := docker.NewClient("unix:///var/run/docker.sock") if err != nil { return nil, err } - + p.client = client return p, nil } +func (proxy *Proxy) Dial() (net.Conn, error) { + return net.Dial("unix", "/var/run/docker.sock") +} + func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { Info.Printf("%s %s", r.Method, r.URL) path := r.URL.Path diff --git a/proxy/proxy_intercept.go b/proxy/proxy_intercept.go index 69f83c83..d936bd16 100644 --- a/proxy/proxy_intercept.go +++ b/proxy/proxy_intercept.go @@ -28,7 +28,7 @@ func (proxy *Proxy) Intercept(i interceptor, w http.ResponseWriter, r *http.Requ return } - conn, err := proxy.dial() + conn, err := proxy.Dial() if err != nil { http.Error(w, "Could not connect to target", http.StatusInternalServerError) Warning.Print(err) diff --git a/weave b/weave index b36721b0..48323451 100755 --- a/weave +++ b/weave @@ -29,8 +29,8 @@ usage() { echo "weave launch [-password ] [-nickname ] [-nodiscovery]" echo " [-iprange [-ipsubnet ]] ..." echo "weave launch-dns []" - echo "weave launch-proxy [-D ] [-H ]" - echo " [--with-dns | --without-dns] [--no-default-ipam]" + echo "weave launch-proxy [-H ] [--with-dns | --without-dns]" + echo " [--no-default-ipam]" echo "weave connect [--replace] [ ...]" echo "weave forget ..." echo "weave run [--with-dns | --without-dns] [ ...] ..."