Browse code

Add support for forwarding Docker client through SOCKS proxy

Signed-off-by: Alexander Morozov <lk4d4@docker.com>

Alexander Morozov authored on 2016/02/17 03:05:05
Showing 3 changed files
... ...
@@ -20,6 +20,7 @@ import (
20 20
 	"github.com/docker/docker/utils"
21 21
 	"github.com/docker/docker/volume/drivers"
22 22
 	"github.com/docker/engine-api/types"
23
+	"github.com/docker/go-connections/sockets"
23 24
 )
24 25
 
25 26
 // SystemInfo returns information about the host server the daemon is running on.
... ...
@@ -97,9 +98,9 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
97 97
 		ServerVersion:      dockerversion.Version,
98 98
 		ClusterStore:       daemon.configStore.ClusterStore,
99 99
 		ClusterAdvertise:   daemon.configStore.ClusterAdvertise,
100
-		HTTPProxy:          getProxyEnv("http_proxy"),
101
-		HTTPSProxy:         getProxyEnv("https_proxy"),
102
-		NoProxy:            getProxyEnv("no_proxy"),
100
+		HTTPProxy:          sockets.GetProxyEnv("http_proxy"),
101
+		HTTPSProxy:         sockets.GetProxyEnv("https_proxy"),
102
+		NoProxy:            sockets.GetProxyEnv("no_proxy"),
103 103
 	}
104 104
 
105 105
 	// TODO Windows. Refactor this more once sysinfo is refactored into
... ...
@@ -196,7 +196,7 @@ func (d *Daemon) getClientConfig() (*clientConfig, error) {
196 196
 		transport = &http.Transport{}
197 197
 	}
198 198
 
199
-	sockets.ConfigureTransport(transport, proto, addr)
199
+	d.c.Assert(sockets.ConfigureTransport(transport, proto, addr), check.IsNil)
200 200
 
201 201
 	return &clientConfig{
202 202
 		transport: transport,
... ...
@@ -30,7 +30,9 @@ func NewClient(addr string, tlsConfig tlsconfig.Options) (*Client, error) {
30 30
 	tr.TLSClientConfig = c
31 31
 
32 32
 	protoAndAddr := strings.Split(addr, "://")
33
-	sockets.ConfigureTransport(tr, protoAndAddr[0], protoAndAddr[1])
33
+	if err := sockets.ConfigureTransport(tr, protoAndAddr[0], protoAndAddr[1]); err != nil {
34
+		return nil, err
35
+	}
34 36
 
35 37
 	scheme := protoAndAddr[0]
36 38
 	if scheme != "https" {