github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/swarmkit/xnet/xnet_windows.go (about)

     1  // +build windows
     2  
     3  package xnet
     4  
     5  import (
     6  	"net"
     7  	"time"
     8  
     9  	"github.com/Microsoft/go-winio"
    10  )
    11  
    12  // ListenLocal opens a local socket for control communication
    13  func ListenLocal(socket string) (net.Listener, error) {
    14  	// set up ACL for the named pipe
    15  	// allow Administrators and SYSTEM
    16  	sddl := "D:P(A;;GA;;;BA)(A;;GA;;;SY)"
    17  	c := winio.PipeConfig{
    18  		SecurityDescriptor: sddl,
    19  		MessageMode:        true,  // Use message mode so that CloseWrite() is supported
    20  		InputBufferSize:    65536, // Use 64KB buffers to improve performance
    21  		OutputBufferSize:   65536,
    22  	}
    23  	// on windows, our socket is actually a named pipe
    24  	return winio.ListenPipe(socket, &c)
    25  }
    26  
    27  // DialTimeoutLocal is a DialTimeout function for local sockets
    28  func DialTimeoutLocal(socket string, timeout time.Duration) (net.Conn, error) {
    29  	// On windows, we dial a named pipe
    30  	return winio.DialPipe(socket, &timeout)
    31  }