fail early when advertise addr is set to ANY (#3507)

This commit is contained in:
Frank Schröder 2017-09-27 22:57:55 +02:00 committed by James Phillips
parent beb803f0d9
commit 5f6d0fd8c5

View file

@ -321,6 +321,12 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
if !isIPAddr(bindAddrs[0]) { if !isIPAddr(bindAddrs[0]) {
return RuntimeConfig{}, fmt.Errorf("bind_addr must be an ip address") return RuntimeConfig{}, fmt.Errorf("bind_addr must be an ip address")
} }
if ipaddr.IsAny(b.stringVal(c.AdvertiseAddrLAN)) {
return RuntimeConfig{}, fmt.Errorf("Advertise address cannot be 0.0.0.0, :: or [::]")
}
if ipaddr.IsAny(b.stringVal(c.AdvertiseAddrWAN)) {
return RuntimeConfig{}, fmt.Errorf("Advertise WAN address cannot be 0.0.0.0, :: or [::]")
}
bindAddr := bindAddrs[0].(*net.IPAddr) bindAddr := bindAddrs[0].(*net.IPAddr)
advertiseAddr := b.makeIPAddr(b.expandFirstIP("advertise_addr", c.AdvertiseAddrLAN), bindAddr) advertiseAddr := b.makeIPAddr(b.expandFirstIP("advertise_addr", c.AdvertiseAddrLAN), bindAddr)