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.
This commit is contained in:
1 parent
0c87dcd656
commit
b483be8c4b
4 files changed
+11
-34
No files matched your search
+7
-25
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user