github.com/45cali/docker@v1.11.1/docker/listeners/listeners_windows.go (about)

     1  package listeners
     2  
     3  import (
     4  	"crypto/tls"
     5  	"errors"
     6  	"fmt"
     7  	"net"
     8  	"strings"
     9  
    10  	"github.com/Microsoft/go-winio"
    11  )
    12  
    13  // Init creates new listeners for the server.
    14  func Init(proto, addr, socketGroup string, tlsConfig *tls.Config) (ls []net.Listener, err error) {
    15  	switch proto {
    16  	case "tcp":
    17  		l, err := initTCPSocket(addr, tlsConfig)
    18  		if err != nil {
    19  			return nil, err
    20  		}
    21  		ls = append(ls, l)
    22  
    23  	case "npipe":
    24  		// allow Administrators and SYSTEM, plus whatever additional users or groups were specified
    25  		sddl := "D:P(A;;GA;;;BA)(A;;GA;;;SY)"
    26  		if socketGroup != "" {
    27  			for _, g := range strings.Split(socketGroup, ",") {
    28  				sid, err := winio.LookupSidByName(g)
    29  				if err != nil {
    30  					return nil, err
    31  				}
    32  				sddl += fmt.Sprintf("(A;;GRGW;;;%s)", sid)
    33  			}
    34  		}
    35  		c := winio.PipeConfig{
    36  			SecurityDescriptor: sddl,
    37  			MessageMode:        true,  // Use message mode so that CloseWrite() is supported
    38  			InputBufferSize:    65536, // Use 64KB buffers to improve performance
    39  			OutputBufferSize:   65536,
    40  		}
    41  		l, err := winio.ListenPipe(addr, &c)
    42  		if err != nil {
    43  			return nil, err
    44  		}
    45  		ls = append(ls, l)
    46  
    47  	default:
    48  		return nil, errors.New("Invalid protocol format. Windows only supports tcp and npipe.")
    49  	}
    50  
    51  	return
    52  }
    53  
    54  // allocateDaemonPort ensures that there are no containers
    55  // that try to use any port allocated for the docker server.
    56  func allocateDaemonPort(addr string) error {
    57  	return nil
    58  }