Permalink
Browse files

IPv6: Validation of proxy addresses.

Accept IPv6 addresses during validation process.
  • Loading branch information...
pmichali committed Mar 5, 2018
1 parent 18a20f9 commit a5451cda964987e35ceb9e2661e924f5d1993f93
Showing with 7 additions and 8 deletions.
  1. +7 −8 pilot/pkg/model/validation.go
@@ -548,6 +548,7 @@ func ValidateIPv4Address(addr string) error {
if ip == nil {
return fmt.Errorf("%v is not a valid IP", addr)
}
return nil // Temp HACK
// The current implementation only supports IP v4 addresses
if ip.To4() == nil {
@@ -1221,19 +1222,17 @@ func ValidateDestinationPolicy(msg proto.Message) error {
// ValidateProxyAddress checks that a network address is well-formed
func ValidateProxyAddress(hostAddr string) error {
colon := strings.Index(hostAddr, ":")
if colon < 0 {
return fmt.Errorf("':' separator not found in %q, host address must be of the form <DNS name>:<port> or <IP>:<port>",
hostAddr)
host, p, err := net.SplitHostPort(hostAddr)
if err != nil {
return fmt.Errorf("Unable to split %q: %s", hostAddr, err.Error())
}
port, err := strconv.Atoi(hostAddr[colon+1:])
port, err := strconv.Atoi(p)
if err != nil {
return err
return fmt.Errorf("Atoi parsing of %s: %s", p, err.Error())
}
if err = ValidatePort(port); err != nil {
return err
}
host := hostAddr[:colon]
if err = ValidateFQDN(host); err != nil {
if err = ValidateIPv4Address(host); err != nil {
return fmt.Errorf("%q is not a valid hostname or an IPv4 address", host)
@@ -1424,7 +1423,7 @@ func ValidateProxyConfig(config *meshconfig.ProxyConfig) (errs error) {
if config.StatsdUdpAddress != "" {
if err := ValidateProxyAddress(config.StatsdUdpAddress); err != nil {
errs = multierror.Append(errs, multierror.Prefix(err, "invalid statsd udp address:"))
errs = multierror.Append(errs, multierror.Prefix(err, fmt.Sprintf("invalid statsd udp address %q:", config.StatsdUdpAddress)))
}
}

0 comments on commit a5451cd

Please sign in to comment.