...

Source file src/github.com/docker/go-connections/sockets/sockets_unix.go

Documentation: github.com/docker/go-connections/sockets

     1  //go:build !windows
     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  	// No need for compression in local communications.
    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  // DialPipe connects to a Windows named pipe.
    36  // This is not supported on other OSes.
    37  func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
    38  	return nil, syscall.EAFNOSUPPORT
    39  }
    40  

View as plain text