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: default:
ip, err := consul.GetPrivateIP() ip, err := consul.GetPrivateIP()
if a.config.BindAddr == "[::]" { if isIPv6ANY(a.config.BindAddr) {
ip, err = consul.GetPublicIPv6() ip, err = consul.GetPublicIPv6()
} }
if err != nil { if err != nil {

View file

@ -1986,5 +1986,13 @@ func isAddrANY(ip interface{}) bool {
default: default:
panic(fmt.Sprintf("invalid type: %T", ip)) 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 == "[::]"
} }