- Use the ones provided by docker/go-connections, they are a drop in replacement.
- Remove pkg/sockets from docker.
- Keep pkg/tlsconfig because libnetwork still needs it and there is a
circular dependency issue.
Signed-off-by: David Calavera <david.calavera@gmail.com>
| ... | ... |
@@ -15,7 +15,7 @@ import ( |
| 15 | 15 |
"github.com/docker/docker/dockerversion" |
| 16 | 16 |
"github.com/docker/docker/opts" |
| 17 | 17 |
"github.com/docker/docker/pkg/term" |
| 18 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 18 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 19 | 19 |
) |
| 20 | 20 |
|
| 21 | 21 |
// DockerCli represents the docker command line client. |
| ... | ... |
@@ -28,9 +28,9 @@ import ( |
| 28 | 28 |
"github.com/docker/docker/pkg/ansiescape" |
| 29 | 29 |
"github.com/docker/docker/pkg/ioutils" |
| 30 | 30 |
flag "github.com/docker/docker/pkg/mflag" |
| 31 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 32 | 31 |
"github.com/docker/docker/reference" |
| 33 | 32 |
"github.com/docker/docker/registry" |
| 33 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 34 | 34 |
"github.com/docker/notary/client" |
| 35 | 35 |
"github.com/docker/notary/passphrase" |
| 36 | 36 |
"github.com/docker/notary/trustmanager" |
| ... | ... |
@@ -18,8 +18,8 @@ import ( |
| 18 | 18 |
"github.com/docker/docker/api/server/router/volume" |
| 19 | 19 |
"github.com/docker/docker/daemon" |
| 20 | 20 |
"github.com/docker/docker/pkg/authorization" |
| 21 |
- "github.com/docker/docker/pkg/sockets" |
|
| 22 | 21 |
"github.com/docker/docker/utils" |
| 22 |
+ "github.com/docker/go-connections/sockets" |
|
| 23 | 23 |
"github.com/gorilla/mux" |
| 24 | 24 |
"golang.org/x/net/context" |
| 25 | 25 |
) |
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"strconv" |
| 11 | 11 |
|
| 12 | 12 |
"github.com/Sirupsen/logrus" |
| 13 |
- "github.com/docker/docker/pkg/sockets" |
|
| 13 |
+ "github.com/docker/go-connections/sockets" |
|
| 14 | 14 |
"github.com/docker/libnetwork/portallocator" |
| 15 | 15 |
|
| 16 | 16 |
systemdActivation "github.com/coreos/go-systemd/activation" |
| ... | ... |
@@ -25,9 +25,9 @@ import ( |
| 25 | 25 |
"github.com/docker/docker/pkg/pidfile" |
| 26 | 26 |
"github.com/docker/docker/pkg/signal" |
| 27 | 27 |
"github.com/docker/docker/pkg/system" |
| 28 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 29 | 28 |
"github.com/docker/docker/registry" |
| 30 | 29 |
"github.com/docker/docker/utils" |
| 30 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 31 | 31 |
) |
| 32 | 32 |
|
| 33 | 33 |
const daemonUsage = " docker daemon [ --help | ... ]\n" |
| ... | ... |
@@ -27,9 +27,9 @@ import ( |
| 27 | 27 |
"github.com/docker/docker/pkg/httputils" |
| 28 | 28 |
"github.com/docker/docker/pkg/integration" |
| 29 | 29 |
"github.com/docker/docker/pkg/ioutils" |
| 30 |
- "github.com/docker/docker/pkg/sockets" |
|
| 31 | 30 |
"github.com/docker/docker/pkg/stringutils" |
| 32 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 31 |
+ "github.com/docker/go-connections/sockets" |
|
| 32 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 33 | 33 |
"github.com/go-check/check" |
| 34 | 34 |
) |
| 35 | 35 |
|
| ... | ... |
@@ -8,7 +8,7 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
log "github.com/Sirupsen/logrus" |
| 10 | 10 |
"github.com/docker/docker/pkg/discovery" |
| 11 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 11 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 12 | 12 |
"github.com/docker/libkv" |
| 13 | 13 |
"github.com/docker/libkv/store" |
| 14 | 14 |
"github.com/docker/libkv/store/consul" |
| ... | ... |
@@ -11,8 +11,8 @@ import ( |
| 11 | 11 |
"time" |
| 12 | 12 |
|
| 13 | 13 |
"github.com/Sirupsen/logrus" |
| 14 |
- "github.com/docker/docker/pkg/sockets" |
|
| 15 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 14 |
+ "github.com/docker/go-connections/sockets" |
|
| 15 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 | 18 |
const ( |
| 36 | 36 |
deleted file mode 100644 |
| ... | ... |
@@ -1,44 +0,0 @@ |
| 1 |
-// Package sockets provides helper functions to create and configure Unix or TCP |
|
| 2 |
-// sockets. |
|
| 3 |
-package sockets |
|
| 4 |
- |
|
| 5 |
-import ( |
|
| 6 |
- "crypto/tls" |
|
| 7 |
- "net" |
|
| 8 |
- "net/http" |
|
| 9 |
- "time" |
|
| 10 |
-) |
|
| 11 |
- |
|
| 12 |
-// NewTCPSocket creates a TCP socket listener with the specified address and |
|
| 13 |
-// and the specified tls configuration. If TLSConfig is set, will encapsulate the |
|
| 14 |
-// TCP listener inside a TLS one. |
|
| 15 |
-func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) {
|
|
| 16 |
- l, err := net.Listen("tcp", addr)
|
|
| 17 |
- if err != nil {
|
|
| 18 |
- return nil, err |
|
| 19 |
- } |
|
| 20 |
- if tlsConfig != nil {
|
|
| 21 |
- tlsConfig.NextProtos = []string{"http/1.1"}
|
|
| 22 |
- l = tls.NewListener(l, tlsConfig) |
|
| 23 |
- } |
|
| 24 |
- return l, nil |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-// ConfigureTCPTransport configures the specified Transport according to the |
|
| 28 |
-// specified proto and addr. |
|
| 29 |
-// If the proto is unix (using a unix socket to communicate) the compression |
|
| 30 |
-// is disabled. |
|
| 31 |
-func ConfigureTCPTransport(tr *http.Transport, proto, addr string) {
|
|
| 32 |
- // Why 32? See https://github.com/docker/docker/pull/8035. |
|
| 33 |
- timeout := 32 * time.Second |
|
| 34 |
- if proto == "unix" {
|
|
| 35 |
- // No need for compression in local communications. |
|
| 36 |
- tr.DisableCompression = true |
|
| 37 |
- tr.Dial = func(_, _ string) (net.Conn, error) {
|
|
| 38 |
- return net.DialTimeout(proto, addr, timeout) |
|
| 39 |
- } |
|
| 40 |
- } else {
|
|
| 41 |
- tr.Proxy = http.ProxyFromEnvironment |
|
| 42 |
- tr.Dial = (&net.Dialer{Timeout: timeout}).Dial
|
|
| 43 |
- } |
|
| 44 |
-} |
| 45 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,80 +0,0 @@ |
| 1 |
-// +build linux freebsd |
|
| 2 |
- |
|
| 3 |
-package sockets |
|
| 4 |
- |
|
| 5 |
-import ( |
|
| 6 |
- "fmt" |
|
| 7 |
- "net" |
|
| 8 |
- "os" |
|
| 9 |
- "strconv" |
|
| 10 |
- "syscall" |
|
| 11 |
- |
|
| 12 |
- "github.com/Sirupsen/logrus" |
|
| 13 |
- "github.com/opencontainers/runc/libcontainer/user" |
|
| 14 |
-) |
|
| 15 |
- |
|
| 16 |
-// NewUnixSocket creates a unix socket with the specified path and group. |
|
| 17 |
-func NewUnixSocket(path, group string) (net.Listener, error) {
|
|
| 18 |
- if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
|
|
| 19 |
- return nil, err |
|
| 20 |
- } |
|
| 21 |
- mask := syscall.Umask(0777) |
|
| 22 |
- defer syscall.Umask(mask) |
|
| 23 |
- l, err := net.Listen("unix", path)
|
|
| 24 |
- if err != nil {
|
|
| 25 |
- return nil, err |
|
| 26 |
- } |
|
| 27 |
- if err := setSocketGroup(path, group); err != nil {
|
|
| 28 |
- l.Close() |
|
| 29 |
- return nil, err |
|
| 30 |
- } |
|
| 31 |
- if err := os.Chmod(path, 0660); err != nil {
|
|
| 32 |
- l.Close() |
|
| 33 |
- return nil, err |
|
| 34 |
- } |
|
| 35 |
- return l, nil |
|
| 36 |
-} |
|
| 37 |
- |
|
| 38 |
-func setSocketGroup(path, group string) error {
|
|
| 39 |
- if group == "" {
|
|
| 40 |
- return nil |
|
| 41 |
- } |
|
| 42 |
- if err := changeGroup(path, group); err != nil {
|
|
| 43 |
- if group != "docker" {
|
|
| 44 |
- return err |
|
| 45 |
- } |
|
| 46 |
- logrus.Debugf("Warning: could not change group %s to docker: %v", path, err)
|
|
| 47 |
- } |
|
| 48 |
- return nil |
|
| 49 |
-} |
|
| 50 |
- |
|
| 51 |
-func changeGroup(path string, nameOrGid string) error {
|
|
| 52 |
- gid, err := lookupGidByName(nameOrGid) |
|
| 53 |
- if err != nil {
|
|
| 54 |
- return err |
|
| 55 |
- } |
|
| 56 |
- logrus.Debugf("%s group found. gid: %d", nameOrGid, gid)
|
|
| 57 |
- return os.Chown(path, 0, gid) |
|
| 58 |
-} |
|
| 59 |
- |
|
| 60 |
-func lookupGidByName(nameOrGid string) (int, error) {
|
|
| 61 |
- groupFile, err := user.GetGroupPath() |
|
| 62 |
- if err != nil {
|
|
| 63 |
- return -1, err |
|
| 64 |
- } |
|
| 65 |
- groups, err := user.ParseGroupFileFilter(groupFile, func(g user.Group) bool {
|
|
| 66 |
- return g.Name == nameOrGid || strconv.Itoa(g.Gid) == nameOrGid |
|
| 67 |
- }) |
|
| 68 |
- if err != nil {
|
|
| 69 |
- return -1, err |
|
| 70 |
- } |
|
| 71 |
- if groups != nil && len(groups) > 0 {
|
|
| 72 |
- return groups[0].Gid, nil |
|
| 73 |
- } |
|
| 74 |
- gid, err := strconv.Atoi(nameOrGid) |
|
| 75 |
- if err == nil {
|
|
| 76 |
- logrus.Warnf("Could not find GID %d", gid)
|
|
| 77 |
- return gid, nil |
|
| 78 |
- } |
|
| 79 |
- return -1, fmt.Errorf("Group %s not found", nameOrGid)
|
|
| 80 |
-} |
| ... | ... |
@@ -23,8 +23,8 @@ import ( |
| 23 | 23 |
"github.com/docker/distribution/registry/client/transport" |
| 24 | 24 |
"github.com/docker/docker/dockerversion" |
| 25 | 25 |
"github.com/docker/docker/pkg/parsers/kernel" |
| 26 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 27 | 26 |
"github.com/docker/docker/pkg/useragent" |
| 27 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 28 | 28 |
) |
| 29 | 29 |
|
| 30 | 30 |
var ( |
| ... | ... |
@@ -4,8 +4,8 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 8 | 7 |
"github.com/docker/docker/reference" |
| 8 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
func (s *Service) lookupV1Endpoints(repoName reference.Named) (endpoints []APIEndpoint, err error) {
|
| ... | ... |
@@ -4,8 +4,8 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/pkg/tlsconfig" |
|
| 8 | 7 |
"github.com/docker/docker/reference" |
| 8 |
+ "github.com/docker/go-connections/tlsconfig" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
func (s *Service) lookupV2Endpoints(repoName reference.Named) (endpoints []APIEndpoint, err error) {
|