2016-09-21 08:16:01 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package sockets
|
|
|
|
|
|
|
|
import (
|
2016-11-22 19:32:10 +00:00
|
|
|
"fmt"
|
2016-09-21 08:16:01 +00:00
|
|
|
"net"
|
2016-11-22 19:32:10 +00:00
|
|
|
"net/http"
|
2016-09-21 08:16:01 +00:00
|
|
|
"syscall"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2016-11-22 19:32:10 +00:00
|
|
|
const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path)
|
|
|
|
|
|
|
|
func configureUnixTransport(tr *http.Transport, proto, addr string) error {
|
|
|
|
if len(addr) > maxUnixSocketPathSize {
|
|
|
|
return fmt.Errorf("Unix socket path %q is too long", addr)
|
|
|
|
}
|
|
|
|
// No need for compression in local communications.
|
|
|
|
tr.DisableCompression = true
|
|
|
|
tr.Dial = func(_, _ string) (net.Conn, error) {
|
|
|
|
return net.DialTimeout(proto, addr, defaultTimeout)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
|
|
|
|
return ErrProtocolNotAvailable
|
|
|
|
}
|
|
|
|
|
2016-09-21 08:16:01 +00:00
|
|
|
// 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
|
|
|
|
}
|