mirror of
https://github.com/status-im/consul.git
synced 2025-02-02 08:56:43 +00:00
agent: Disallow :: or [::] as advertise or advertise-wan address
This commit is contained in:
parent
8ad52ee9b5
commit
6fa76fd90f
@ -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…
x
Reference in New Issue
Block a user