Skip to content

Commit accbfde

Browse files
committed
client: use go-winio.DialPipe directly
The go-connections package implementation is only a shallow wrapper around go-winio for named pipes; use the go-winio implementation directly. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 829b695 commit accbfde

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

client/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ func (cli *Client) dialer() func(context.Context) (net.Conn, error) {
463463
case "unix":
464464
return net.Dial(cli.proto, cli.addr)
465465
case "npipe":
466-
return sockets.DialPipe(cli.addr, 32*time.Second)
466+
ctx, cancel := context.WithTimeout(ctx, 32*time.Second)
467+
defer cancel()
468+
return dialPipeContext(ctx, cli.addr)
467469
default:
468470
if tlsConfig := cli.tlsConfig(); tlsConfig != nil {
469471
return tls.Dial(cli.proto, cli.addr, tlsConfig)

client/client_unix.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
package client
44

5+
import (
6+
"context"
7+
"net"
8+
"syscall"
9+
)
10+
511
// DefaultDockerHost defines OS-specific default host if the DOCKER_HOST
612
// (EnvOverrideHost) environment variable is unset or empty.
713
const DefaultDockerHost = "unix:///var/run/docker.sock"
14+
15+
// dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows.
16+
func dialPipeContext(_ context.Context, _ string) (net.Conn, error) {
17+
return nil, syscall.EAFNOSUPPORT
18+
}

client/client_windows.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
package client
22

3+
import (
4+
"context"
5+
"net"
6+
7+
"github.com/Microsoft/go-winio"
8+
)
9+
310
// DefaultDockerHost defines OS-specific default host if the DOCKER_HOST
411
// (EnvOverrideHost) environment variable is unset or empty.
512
const DefaultDockerHost = "npipe:////./pipe/docker_engine"
13+
14+
// dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows.
15+
func dialPipeContext(ctx context.Context, addr string) (net.Conn, error) {
16+
return winio.DialPipeContext(ctx, addr)
17+
}

0 commit comments

Comments
 (0)