Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
IPv6: Validation of proxy addresses.
Accept IPv6 addresses during validation process.
- Loading branch information
Showing
with
7 additions
and
8 deletions.
-
+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))) |
|
|
} |
|
|
} |
|
|
|
|
|