|
@@ -46,8 +46,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
|
|
|
req.Header.Set("Connection", "Upgrade")
|
|
|
req.Header.Set("Upgrade", "tcp")
|
|
|
|
|
|
- tlsConfig := cli.transport.TLSConfig()
|
|
|
- conn, err := dial(cli.proto, cli.addr, tlsConfig)
|
|
|
+ conn, err := dial(cli.proto, cli.addr, cli.transport.TLSConfig())
|
|
|
if err != nil {
|
|
|
if strings.Contains(err.Error(), "connection refused") {
|
|
|
return types.HijackedResponse{}, fmt.Errorf("Cannot connect to the Docker daemon. Is 'docker daemon' running on this host?")
|
|
@@ -126,6 +125,21 @@ func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Con
|
|
|
tcpConn.SetKeepAlivePeriod(30 * time.Second)
|
|
|
}
|
|
|
|
|
|
+ colonPos := strings.LastIndex(addr, ":")
|
|
|
+ if colonPos == -1 {
|
|
|
+ colonPos = len(addr)
|
|
|
+ }
|
|
|
+ hostname := addr[:colonPos]
|
|
|
+
|
|
|
+ // If no ServerName is set, infer the ServerName
|
|
|
+ // from the hostname we're connecting to.
|
|
|
+ if config.ServerName == "" {
|
|
|
+ // Make a copy to avoid polluting argument or default.
|
|
|
+ c := *config
|
|
|
+ c.ServerName = hostname
|
|
|
+ config = &c
|
|
|
+ }
|
|
|
+
|
|
|
conn := tls.Client(rawConn, config)
|
|
|
|
|
|
if timeout == 0 {
|