1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/server/server_windows.go
Alexander Morozov d9ed316522 Make API server datastructure
Added daemon field to it, will use it later for acces to daemon from
handlers

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-04-20 08:13:39 -07:00

51 lines
1 KiB
Go

// +build windows
package server
import (
"errors"
"net"
"net/http"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon"
)
// NewServer sets up the required Server and does protocol specific checking.
func (s *Server) newServer(proto, addr string) (Server, error) {
var (
err error
l net.Listener
)
switch proto {
case "tcp":
if !s.cfg.TlsVerify {
logrus.Warn("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
}
if l, err = NewTcpSocket(addr, tlsConfigFromServerConfig(s.cfg)); err != nil {
return nil, err
}
if err := allocateDaemonPort(addr); err != nil {
return nil, err
}
default:
return nil, errors.New("Invalid protocol format. Windows only supports tcp.")
}
return &HttpServer{
&http.Server{
Addr: addr,
Handler: s.router,
},
l,
}, nil
}
func (s *Server) AcceptConnections(d *daemon.Daemon) {
s.daemon = d
// close the lock so the listeners start accepting connections
select {
case <-s.start:
default:
close(s.start)
}
}