summaryrefslogtreecommitdiff
path: root/registry/registry.go
diff options
context:
space:
mode:
authorBrett Higgins <brhiggins@arbor.net>2016-04-25 07:54:48 -0400
committerBrett Higgins <brhiggins@arbor.net>2016-04-25 15:08:30 -0400
commit207027087e71f5587ca407e20cc252f7958bc1b3 (patch)
tree9577c3bd12407e2687c908559c7d802d01b27c58 /registry/registry.go
parente974eadd949c5d7cb91a7d4406c2e0da8b1db677 (diff)
downloaddocker-207027087e71f5587ca407e20cc252f7958bc1b3.tar.gz
Respect ALL_PROXY during registry operations
Use sockets.DialerFromEnvironment, as is done in other places, to transparently support SOCKS proxy config from ALL_PROXY environment variable. Requires the *engine* have the ALL_PROXY env var set, which doesn't seem ideal. Maybe it should be a CLI option somehow? Only tested with push and a v2 registry so far. I'm happy to look further into testing more broadly, but I wanted to get feedback on the general idea first. Signed-off-by: Brett Higgins <brhiggins@arbor.net>
Diffstat (limited to 'registry/registry.go')
-rw-r--r--registry/registry.go24
1 files changed, 17 insertions, 7 deletions
diff --git a/registry/registry.go b/registry/registry.go
index 8fdfe3b0a4..0b5a070e32 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -16,6 +16,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/distribution/registry/client/transport"
+ "github.com/docker/go-connections/sockets"
"github.com/docker/go-connections/tlsconfig"
)
@@ -165,16 +166,25 @@ func NewTransport(tlsConfig *tls.Config) *http.Transport {
var cfg = tlsconfig.ServerDefault
tlsConfig = &cfg
}
- return &http.Transport{
- Proxy: http.ProxyFromEnvironment,
- Dial: (&net.Dialer{
- Timeout: 30 * time.Second,
- KeepAlive: 30 * time.Second,
- DualStack: true,
- }).Dial,
+
+ direct := &net.Dialer{
+ Timeout: 30 * time.Second,
+ KeepAlive: 30 * time.Second,
+ DualStack: true,
+ }
+
+ base := &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ Dial: direct.Dial,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: tlsConfig,
// TODO(dmcgowan): Call close idle connections when complete and use keep alive
DisableKeepAlives: true,
}
+
+ proxyDialer, err := sockets.DialerFromEnvironment(direct)
+ if err == nil {
+ base.Dial = proxyDialer.Dial
+ }
+ return base
}