зеркало из https://github.com/docker/engine-api.git
Windows: add support for named pipe transport
This does not yet change the default to use named pipes. Signed-off-by: John Starks <jostarks@microsoft.com>
This commit is contained in:
Родитель
b49ecf0e6c
Коммит
bb91ebe407
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/engine-api/client/transport"
|
||||||
"github.com/docker/engine-api/types"
|
"github.com/docker/engine-api/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -156,9 +157,12 @@ func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Con
|
||||||
}
|
}
|
||||||
|
|
||||||
func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) {
|
func dial(proto, addr string, tlsConfig *tls.Config) (net.Conn, error) {
|
||||||
if tlsConfig != nil && proto != "unix" {
|
if tlsConfig != nil && proto != "unix" && proto != "npipe" {
|
||||||
// Notice this isn't Go standard's tls.Dial function
|
// Notice this isn't Go standard's tls.Dial function
|
||||||
return tlsDial(proto, addr, tlsConfig)
|
return tlsDial(proto, addr, tlsConfig)
|
||||||
}
|
}
|
||||||
|
if proto == "npipe" {
|
||||||
|
return transport.DialPipe(addr, 32*time.Second)
|
||||||
|
}
|
||||||
return net.Dial(proto, addr)
|
return net.Dial(proto, addr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package transport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DialPipe connects to a Windows named pipe. This is not supported on other OSes.
|
||||||
|
func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
|
||||||
|
return nil, syscall.EAFNOSUPPORT
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package transport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Microsoft/go-winio"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DialPipe connects to a Windows named pipe.
|
||||||
|
func DialPipe(addr string, timeout time.Duration) (net.Conn, error) {
|
||||||
|
return winio.DialPipe(addr, &timeout)
|
||||||
|
}
|
|
@ -52,6 +52,10 @@ func defaultTransport(proto, addr string) *http.Transport {
|
||||||
tr.Dial = func(_, _ string) (net.Conn, error) {
|
tr.Dial = func(_, _ string) (net.Conn, error) {
|
||||||
return net.DialTimeout(proto, addr, timeout)
|
return net.DialTimeout(proto, addr, timeout)
|
||||||
}
|
}
|
||||||
|
} else if proto == "npipe" {
|
||||||
|
tr.Dial = func(_, _ string) (net.Conn, error) {
|
||||||
|
return DialPipe(addr, timeout)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tr.Proxy = http.ProxyFromEnvironment
|
tr.Proxy = http.ProxyFromEnvironment
|
||||||
tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
|
tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
|
||||||
|
|
Загрузка…
Ссылка в новой задаче