diff --git a/components/engine/hack/vendor.sh b/components/engine/hack/vendor.sh index f3927343cd..daeaa80bbd 100755 --- a/components/engine/hack/vendor.sh +++ b/components/engine/hack/vendor.sh @@ -64,7 +64,7 @@ clone git github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3 clone git golang.org/x/net 2beffdc2e92c8a3027590f898fe88f69af48a3f8 https://github.com/tonistiigi/net.git clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git clone git github.com/docker/go-units 8a7beacffa3009a9ac66bad506b18ffdd110cf97 -clone git github.com/docker/go-connections 988efe982fdecb46f01d53465878ff1f2ff411ce +clone git github.com/docker/go-connections 1494b6df4050e60923d68cd8cc6a19e7af9f1c01 clone git github.com/RackSec/srslog 365bf33cd9acc21ae1c355209865f17228ca534e clone git github.com/imdario/mergo 0.2.1 diff --git a/components/engine/vendor/src/github.com/docker/go-connections/nat/nat.go b/components/engine/vendor/src/github.com/docker/go-connections/nat/nat.go index e19c73c378..4d5f5ae63a 100644 --- a/components/engine/vendor/src/github.com/docker/go-connections/nat/nat.go +++ b/components/engine/vendor/src/github.com/docker/go-connections/nat/nat.go @@ -155,33 +155,36 @@ type PortMapping struct { Binding PortBinding } +func splitParts(rawport string) (string, string, string) { + parts := strings.Split(rawport, ":") + n := len(parts) + containerport := parts[n-1] + + switch n { + case 1: + return "", "", containerport + case 2: + return "", parts[0], containerport + case 3: + return parts[0], parts[1], containerport + default: + return strings.Join(parts[:n-2], ":"), parts[n-2], containerport + } +} + // ParsePortSpec parses a port specification string into a slice of PortMappings func ParsePortSpec(rawPort string) ([]PortMapping, error) { - proto := "tcp" + var proto string + rawIP, hostPort, containerPort := splitParts(rawPort) + proto, containerPort = SplitProtoPort(containerPort) - if i := strings.LastIndex(rawPort, "/"); i != -1 { - proto = rawPort[i+1:] - rawPort = rawPort[:i] - } - if !strings.Contains(rawPort, ":") { - rawPort = fmt.Sprintf("::%s", rawPort) - } else if len(strings.Split(rawPort, ":")) == 2 { - rawPort = fmt.Sprintf(":%s", rawPort) - } - - parts, err := PartParser(portSpecTemplate, rawPort) + // Strip [] from IPV6 addresses + ip, _, err := net.SplitHostPort(rawIP + ":") if err != nil { - return nil, err + return nil, fmt.Errorf("Invalid ip address %v: %s", rawIP, err) } - - var ( - containerPort = parts["containerPort"] - rawIP = parts["ip"] - hostPort = parts["hostPort"] - ) - - if rawIP != "" && net.ParseIP(rawIP) == nil { - return nil, fmt.Errorf("Invalid ip address: %s", rawIP) + if ip != "" && net.ParseIP(ip) == nil { + return nil, fmt.Errorf("Invalid ip address: %s", ip) } if containerPort == "" { return nil, fmt.Errorf("No port specified: %s", rawPort) @@ -230,7 +233,7 @@ func ParsePortSpec(rawPort string) ([]PortMapping, error) { } binding := PortBinding{ - HostIP: rawIP, + HostIP: ip, HostPort: hostPort, } ports = append(ports, PortMapping{Port: port, Binding: binding}) diff --git a/components/engine/vendor/src/github.com/docker/go-connections/nat/parse.go b/components/engine/vendor/src/github.com/docker/go-connections/nat/parse.go index 872050205f..892adf8c66 100644 --- a/components/engine/vendor/src/github.com/docker/go-connections/nat/parse.go +++ b/components/engine/vendor/src/github.com/docker/go-connections/nat/parse.go @@ -8,6 +8,7 @@ import ( // PartParser parses and validates the specified string (data) using the specified template // e.g. ip:public:private -> 192.168.0.1:80:8000 +// DEPRECATED: do not use, this function may be removed in a future version func PartParser(template, data string) (map[string]string, error) { // ip:public:private var ( diff --git a/components/engine/vendor/src/github.com/docker/go-connections/sockets/tcp_socket.go b/components/engine/vendor/src/github.com/docker/go-connections/sockets/tcp_socket.go index 8a82727df0..53cbb6c79e 100644 --- a/components/engine/vendor/src/github.com/docker/go-connections/sockets/tcp_socket.go +++ b/components/engine/vendor/src/github.com/docker/go-connections/sockets/tcp_socket.go @@ -7,7 +7,7 @@ import ( ) // NewTCPSocket creates a TCP socket listener with the specified address and -// and the specified tls configuration. If TLSConfig is set, will encapsulate the +// the specified tls configuration. If TLSConfig is set, will encapsulate the // TCP listener inside a TLS one. func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { l, err := net.Listen("tcp", addr)