Revert "First pass at Proxy SSL Support"

This commit is contained in:
Paul Bellamy committed 2015-06-02 12:48:38 +01:00
1 parent 3586ddcd63
commit 91375a1095
8 files changed
+19 -265

No files matched your search

+7 -30
View File
@@ -2,7 +2,6 @@ package proxy
import (
"bytes"
"crypto/tls"
"fmt"
"net"
"net/http"
@@ -14,12 +13,6 @@ import (
. "github.com/weaveworks/weave/common"
)
const (
defaultCaFile = "ca.pem"
defaultKeyFile = "key.pem"
defaultCertFile = "cert.pem"
)
var (
containerCreateRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/create$")
containerStartRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/(re)?start$")
@@ -31,14 +24,13 @@ type Proxy struct {
version string
client *docker.Client
dockerAddr string
dockerBridgeIP string
listenAddr string
tlsConfig *TLSConfig
withDNS bool
dockerBridgeIP string
withIPAM bool
}
func NewProxy(version, dockerAddr, listenAddr string, withDNS, withIPAM bool, tlsConfig *TLSConfig) (*Proxy, error) {
func NewProxy(version, dockerAddr, listenAddr string, withDNS, withIPAM bool) (*Proxy, error) {
u, err := url.Parse(dockerAddr)
if err != nil {
return nil, err
@@ -52,10 +44,6 @@ func NewProxy(version, dockerAddr, listenAddr string, withDNS, withIPAM bool, tl
}
}
if err := tlsConfig.loadCerts(); err != nil {
Error.Fatalf("Could not configure tls for proxy: %s", err)
}
client, err := docker.NewClient(dockerAddr)
if err != nil {
return nil, err
@@ -77,9 +65,8 @@ func NewProxy(version, dockerAddr, listenAddr string, withDNS, withIPAM bool, tl
client: client,
dockerAddr: dockerAddr,
listenAddr: listenAddr,
dockerBridgeIP: string(dockerBridgeIP),
tlsConfig: tlsConfig,
withDNS: withDNS,
dockerBridgeIP: string(dockerBridgeIP),
withIPAM: withIPAM,
}, nil
}
@@ -125,18 +112,8 @@ func (proxy *Proxy) Status() string {
}
func (proxy *Proxy) ListenAndServe() error {
listener, err := net.Listen("tcp", proxy.listenAddr)
if err != nil {
return err
}
if proxy.tlsConfig.enabled() {
listener = tls.NewListener(listener, proxy.tlsConfig.Config)
Info.Println("TLS Enabled")
}
Info.Printf("Listening on %s", proxy.listenAddr)
Info.Printf("Proxying %s", proxy.dockerAddr)
return (&http.Server{Handler: proxy}).Serve(listener)
return (&http.Server{
Addr: proxy.listenAddr,
Handler: proxy,
}).ListenAndServe()
}