mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
Extract sockets initialization to a package.
Because I just used it somewhere else and it would be nice if I didn't have to copy and paste the code. Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
@ -30,6 +30,7 @@ import (
|
||||
"github.com/docker/docker/pkg/parsers/filters"
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/docker/docker/pkg/sockets"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
@ -1402,6 +1403,26 @@ func (s *Server) ping(version version.Version, w http.ResponseWriter, r *http.Re
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) initTcpSocket(addr string) (l net.Listener, err error) {
|
||||
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 /!\\")
|
||||
}
|
||||
|
||||
var c *sockets.TlsConfig
|
||||
if s.cfg.Tls || s.cfg.TlsVerify {
|
||||
c = sockets.NewTlsConfig(s.cfg.TlsCert, s.cfg.TlsKey, s.cfg.TlsCa, s.cfg.TlsVerify)
|
||||
}
|
||||
|
||||
if l, err = sockets.NewTcpSocket(addr, c, s.start); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := allocateDaemonPort(addr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func makeHttpHandler(logging bool, localMethod string, localRoute string, handlerFunc HttpApiFunc, corsHeaders string, dockerVersion version.Version) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// log the request
|
||||
|
Reference in New Issue
Block a user