agent: allow "::" as IPv6 bind address

Fixes #2285
This commit is contained in:
Frank Schroeder 2017-05-15 11:11:27 +02:00 committed by Frank Schröder
parent b7929b8bce
commit e350b7aafa
2 changed files with 10 additions and 2 deletions

View File

@ -310,7 +310,7 @@ func (a *Agent) consulConfig() (*consul.Config, error) {
default:
ip, err := consul.GetPrivateIP()
if a.config.BindAddr == "[::]" {
if isIPv6ANY(a.config.BindAddr) {
ip, err = consul.GetPublicIPv6()
}
if err != nil {

View File

@ -1986,5 +1986,13 @@ func isAddrANY(ip interface{}) bool {
default:
panic(fmt.Sprintf("invalid type: %T", ip))
}
return ips == "0.0.0.0" || ips == "::" || ips == "[::]"
return isIPv4Any(ips) || isIPv6ANY(ips)
}
func isIPv4Any(ip string) bool {
return ip == "0.0.0.0"
}
func isIPv6ANY(ip string) bool {
return ip == "::" || ip == "[::]"
}