github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/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  		l, err := winio.ListenPipe(addr, sddl)
    36  		if err != nil {
    37  			return nil, err
    38  		}
    39  		ls = append(ls, l)
    40  
    41  	default:
    42  		return nil, errors.New("Invalid protocol format. Windows only supports tcp and npipe.")
    43  	}
    44  
    45  	return
    46  }
    47  
    48  // allocateDaemonPort ensures that there are no containers
    49  // that try to use any port allocated for the docker server.
    50  func allocateDaemonPort(addr string) error {
    51  	return nil
    52  }