add tls to hijack as well

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-01-06 23:17:16 +00:00
parent 6552c7c884
commit 20018ff141
2 changed files with 13 additions and 4 deletions

View File

@ -220,7 +220,7 @@ func proxyContainerAndForceRefresh(c *context, w http.ResponseWriter, r *http.Re
return return
} }
if err := proxy(container, w, r); err != nil { if err := proxy(c.tlsConfig, container, w, r); err != nil {
httpError(w, err.Error(), http.StatusInternalServerError) httpError(w, err.Error(), http.StatusInternalServerError)
} }
@ -249,7 +249,7 @@ func proxyHijack(c *context, w http.ResponseWriter, r *http.Request) {
return return
} }
if err := hijack(container, w, r); err != nil { if err := hijack(c.tlsConfig, container, w, r); err != nil {
httpError(w, err.Error(), http.StatusInternalServerError) httpError(w, err.Error(), http.StatusInternalServerError)
} }
} }

View File

@ -65,7 +65,7 @@ func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseW
return nil return nil
} }
func hijack(container *cluster.Container, w http.ResponseWriter, r *http.Request) error { func hijack(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseWriter, r *http.Request) error {
addr := container.Node().Addr addr := container.Node().Addr
if parts := strings.SplitN(container.Node().Addr, "://", 2); len(parts) == 2 { if parts := strings.SplitN(container.Node().Addr, "://", 2); len(parts) == 2 {
addr = parts[1] addr = parts[1]
@ -73,7 +73,16 @@ func hijack(container *cluster.Container, w http.ResponseWriter, r *http.Request
log.Debugf("[HIJACK PROXY] --> %s", addr) log.Debugf("[HIJACK PROXY] --> %s", addr)
d, err := net.Dial("tcp", addr) var (
d net.Conn
err error
)
if tlsConfig != nil {
d, err = tls.Dial("tcp", addr, tlsConfig)
} else {
d, err = net.Dial("tcp", addr)
}
if err != nil { if err != nil {
return err return err
} }