agent: Disallow :: or [::] as advertise or advertise-wan address
This commit is contained in:
parent
8821793358
commit
c1cbecfe18
|
@ -361,13 +361,13 @@ func (c *Command) readConfig() *Config {
|
|||
return nil
|
||||
}
|
||||
|
||||
if config.AdvertiseAddr == "0.0.0.0" {
|
||||
c.UI.Error("Advertise address cannot be 0.0.0.0")
|
||||
if config.AdvertiseAddr == "0.0.0.0" || config.AdvertiseAddr == "::" || config.AdvertiseAddr == "[::]" {
|
||||
c.UI.Error("Advertise address cannot be " + config.AdvertiseAddr)
|
||||
return nil
|
||||
}
|
||||
|
||||
if config.AdvertiseAddrWan == "0.0.0.0" {
|
||||
c.UI.Error("Advertise WAN address cannot be 0.0.0.0")
|
||||
if config.AdvertiseAddrWan == "0.0.0.0" || config.AdvertiseAddrWan == "::" || config.AdvertiseAddrWan == "[::]" {
|
||||
c.UI.Error("Advertise WAN address cannot be " + config.AdvertiseAddrWan)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -61,10 +61,26 @@ func TestConfigFail(t *testing.T) {
|
|||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise", "0.0.0.0"},
|
||||
out: "==> Advertise address cannot be 0.0.0.0\n",
|
||||
},
|
||||
{
|
||||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise", "::"},
|
||||
out: "==> Advertise address cannot be ::\n",
|
||||
},
|
||||
{
|
||||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise", "[::]"},
|
||||
out: "==> Advertise address cannot be [::]\n",
|
||||
},
|
||||
{
|
||||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise-wan", "0.0.0.0"},
|
||||
out: "==> Advertise WAN address cannot be 0.0.0.0\n",
|
||||
},
|
||||
{
|
||||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise-wan", "::"},
|
||||
out: "==> Advertise WAN address cannot be ::\n",
|
||||
},
|
||||
{
|
||||
args: []string{"agent", "-server", "-data-dir", "foo", "-advertise-wan", "[::]"},
|
||||
out: "==> Advertise WAN address cannot be [::]\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
Loading…
Reference in New Issue