mirror of https://github.com/docker/docs.git
fix parsing of hostnames when we actually want IP addresses.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
parent
2dc21af70b
commit
3c49cb17fb
|
@ -5,6 +5,7 @@ package nat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -114,6 +115,9 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
|
||||||
hostPort = parts["hostPort"]
|
hostPort = parts["hostPort"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if rawIp != "" && net.ParseIP(rawIp) == nil {
|
||||||
|
return nil, nil, fmt.Errorf("Invalid ip address: %s", rawIp)
|
||||||
|
}
|
||||||
if containerPort == "" {
|
if containerPort == "" {
|
||||||
return nil, nil, fmt.Errorf("No port specified: %s<empty>", rawPort)
|
return nil, nil, fmt.Errorf("No port specified: %s<empty>", rawPort)
|
||||||
}
|
}
|
||||||
|
@ -123,6 +127,7 @@ func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding,
|
||||||
if _, err := strconv.ParseUint(hostPort, 10, 16); hostPort != "" && err != nil {
|
if _, err := strconv.ParseUint(hostPort, 10, 16); hostPort != "" && err != nil {
|
||||||
return nil, nil, fmt.Errorf("Invalid hostPort: %s", hostPort)
|
return nil, nil, fmt.Errorf("Invalid hostPort: %s", hostPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !validateProto(proto) {
|
if !validateProto(proto) {
|
||||||
return nil, nil, fmt.Errorf("Invalid proto: %s", proto)
|
return nil, nil, fmt.Errorf("Invalid proto: %s", proto)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue