diff --git a/go.sum b/go.sum index 2bcfb4ff..6f7f4267 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,10 @@ github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/sockets/sockets.go b/sockets/sockets.go index 2e9e9006..73ff9fcb 100644 --- a/sockets/sockets.go +++ b/sockets/sockets.go @@ -4,8 +4,11 @@ package sockets import ( "errors" "net/http" + "time" ) +const defaultTimeout = 10 * time.Second + // ErrProtocolNotAvailable is returned when a given transport protocol is not provided by the operating system. var ErrProtocolNotAvailable = errors.New("protocol not available") diff --git a/sockets/sockets_unix.go b/sockets/sockets_unix.go index 10d76342..31b14abd 100644 --- a/sockets/sockets_unix.go +++ b/sockets/sockets_unix.go @@ -11,10 +11,7 @@ import ( "time" ) -const ( - defaultTimeout = 10 * time.Second - maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) -) +const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path) func configureUnixTransport(tr *http.Transport, proto, addr string) error { if len(addr) > maxUnixSocketPathSize { @@ -22,10 +19,10 @@ func configureUnixTransport(tr *http.Transport, proto, addr string) error { } // No need for compression in local communications. tr.DisableCompression = true - dialer := &net.Dialer{ - Timeout: defaultTimeout, - } tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { + dialer := &net.Dialer{ + Timeout: defaultTimeout, + } return dialer.DialContext(ctx, proto, addr) } return nil diff --git a/sockets/sockets_windows.go b/sockets/sockets_windows.go index 7acafc5a..16f8cdbb 100644 --- a/sockets/sockets_windows.go +++ b/sockets/sockets_windows.go @@ -17,7 +17,12 @@ func configureNpipeTransport(tr *http.Transport, proto, addr string) error { // No need for compression in local communications. tr.DisableCompression = true tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) { - return winio.DialPipeContext(ctx, addr) + // DialPipeContext() has been added to winio: + // https://github.com/Microsoft/go-winio/commit/5fdbdcc2ae1c7e1073157fa7cb34a15eab472e1d + // However, a new version of winio with this commit has not been released yet. + // Continue to use DialPipe() until DialPipeContext() becomes available. + //return winio.DialPipeContext(ctx, addr) + return DialPipe(addr, defaultTimeout) } return nil }