...
1
2
3 package sockets
4
5 import (
6 "context"
7 "fmt"
8 "net"
9 "net/http"
10 "syscall"
11 "time"
12 )
13
14 const maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path)
15
16 func configureUnixTransport(tr *http.Transport, proto, addr string) error {
17 if len(addr) > maxUnixSocketPathSize {
18 return fmt.Errorf("unix socket path %q is too long", addr)
19 }
20
21 tr.DisableCompression = true
22 dialer := &net.Dialer{
23 Timeout: defaultTimeout,
24 }
25 tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
26 return dialer.DialContext(ctx, proto, addr)
27 }
28 return nil
29 }
30
31 func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
32 return ErrProtocolNotAvailable
33 }
34
35
36
37 func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
38 return nil, syscall.EAFNOSUPPORT
39 }
40
View as plain text