Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 6243539

Browse files
committed
[integration-test] update go-connections in vendor
1 parent 677964f commit 6243539

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

vendor/src/github.com/docker/go-connections/sockets/tcp_socket.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ package sockets
44
import (
55
"crypto/tls"
66
"net"
7+
"net/http"
8+
"time"
79
)
810

911
// NewTCPSocket creates a TCP socket listener with the specified address and
@@ -20,3 +22,23 @@ func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) {
2022
}
2123
return l, nil
2224
}
25+
26+
// ConfigureTCPTransport configures the specified Transport according to the
27+
// specified proto and addr.
28+
// If the proto is unix (using a unix socket to communicate) the compression
29+
// is disabled.
30+
func ConfigureTCPTransport(tr *http.Transport, proto, addr string) {
31+
// Why 32? See https://github.com/docker/docker/pull/8035.
32+
timeout := 32 * time.Second
33+
if proto == "unix" {
34+
// No need for compression in local communications.
35+
tr.DisableCompression = true
36+
tr.Dial = func(_, _ string) (net.Conn, error) {
37+
return net.DialTimeout(proto, addr, timeout)
38+
}
39+
} else {
40+
tr.Proxy = http.ProxyFromEnvironment
41+
tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
42+
}
43+
}
44+

0 commit comments

Comments
 (0)