2015-05-20 19:48:39 -04:00
|
|
|
package sockets
|
2015-03-31 16:37:49 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/listenbuffer"
|
|
|
|
)
|
|
|
|
|
2015-05-07 12:49:07 -04:00
|
|
|
func NewTcpSocket(addr string, tlsConfig *tls.Config, activate <-chan struct{}) (net.Listener, error) {
|
2015-04-17 17:32:18 -04:00
|
|
|
l, err := listenbuffer.NewListenBuffer("tcp", addr, activate)
|
2015-03-31 16:37:49 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-05-07 12:49:07 -04:00
|
|
|
if tlsConfig != nil {
|
|
|
|
tlsConfig.NextProtos = []string{"http/1.1"}
|
|
|
|
l = tls.NewListener(l, tlsConfig)
|
2015-03-31 16:37:49 -04:00
|
|
|
}
|
|
|
|
return l, nil
|
|
|
|
}
|