diff --git a/client/client.go b/client/client.go index 9b0ba64666..8d7bd6cfa0 100644 --- a/client/client.go +++ b/client/client.go @@ -43,11 +43,13 @@ package client // import "github.com/docker/docker/client" import ( "context" + "crypto/tls" "net" "net/http" "net/url" "path" "strings" + "time" "github.com/docker/docker/api" "github.com/docker/docker/api/types" @@ -357,6 +359,16 @@ func (cli *Client) Dialer() func(context.Context) (net.Conn, error) { return transport.DialContext(ctx, cli.proto, cli.addr) } } - return fallbackDial(cli.proto, cli.addr, resolveTLSConfig(cli.client.Transport)) + switch cli.proto { + case "unix": + return net.Dial(cli.proto, cli.addr) + case "npipe": + return sockets.DialPipe(cli.addr, 32*time.Second) + default: + if tlsConfig := resolveTLSConfig(cli.client.Transport); tlsConfig != nil { + return tls.Dial(cli.proto, cli.addr, tlsConfig) + } + return net.Dial(cli.proto, cli.addr) + } } } diff --git a/client/hijack.go b/client/hijack.go index 7e84865f69..2337a9539b 100644 --- a/client/hijack.go +++ b/client/hijack.go @@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" import ( "bufio" "context" - "crypto/tls" "fmt" "net" "net/http" @@ -13,7 +12,6 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/versions" - "github.com/docker/go-connections/sockets" "github.com/pkg/errors" ) @@ -47,18 +45,6 @@ func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[s return conn, err } -// fallbackDial is used when WithDialer() was not called. -// See cli.Dialer(). -func fallbackDial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) { - if tlsConfig != nil && proto != "unix" && proto != "npipe" { - return tls.Dial(proto, addr, tlsConfig) - } - if proto == "npipe" { - return sockets.DialPipe(addr, 32*time.Second) - } - return net.Dial(proto, addr) -} - func (cli *Client) setupHijackConn(ctx context.Context, req *http.Request, proto string) (net.Conn, string, error) { req.Header.Set("Connection", "Upgrade") req.Header.Set("Upgrade", proto)