Enforce a valid port for the Serf WAN since it can't be disabled.
Fixes #3817
This commit is contained in:
parent
dac4367fb2
commit
f191eb2df3
|
@ -369,6 +369,9 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
|
||||||
if ipaddr.IsAny(b.stringVal(c.AdvertiseAddrWAN)) {
|
if ipaddr.IsAny(b.stringVal(c.AdvertiseAddrWAN)) {
|
||||||
return RuntimeConfig{}, fmt.Errorf("Advertise WAN address cannot be 0.0.0.0, :: or [::]")
|
return RuntimeConfig{}, fmt.Errorf("Advertise WAN address cannot be 0.0.0.0, :: or [::]")
|
||||||
}
|
}
|
||||||
|
if serfPortWAN < 0 {
|
||||||
|
return RuntimeConfig{}, fmt.Errorf("ports.serf_wan must be a valid port from 1 to 65535")
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -1064,6 +1064,23 @@ func TestConfigFlagsAndEdgecases(t *testing.T) {
|
||||||
rt.DataDir = dataDir
|
rt.DataDir = dataDir
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "serf wan port > 0",
|
||||||
|
args: []string{`-data-dir=` + dataDir},
|
||||||
|
json: []string{`{
|
||||||
|
"ports": {
|
||||||
|
"serf_wan": -1
|
||||||
|
},
|
||||||
|
"advertise_addr_wan": "1.2.3.4"
|
||||||
|
}`},
|
||||||
|
hcl: []string{`
|
||||||
|
ports {
|
||||||
|
serf_wan = -1
|
||||||
|
}
|
||||||
|
advertise_addr_wan = "1.2.3.4"
|
||||||
|
`},
|
||||||
|
err: "ports.serf_wan must be a valid port from 1 to 65535",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "serf bind address lan template",
|
desc: "serf bind address lan template",
|
||||||
args: []string{`-data-dir=` + dataDir},
|
args: []string{`-data-dir=` + dataDir},
|
||||||
|
|
Loading…
Reference in New Issue