agent: Disallow :: or [::] as advertise or advertise-wan address

This commit is contained in:
Frank Schroeder 2017-05-09 09:37:21 +02:00
parent 8821793358
commit c1cbecfe18
No known key found for this signature in database
GPG Key ID: 4D65C6EAEC87DECD
2 changed files with 20 additions and 4 deletions

View File

@ -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
}

View File

@ -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 {