From c1cbecfe181fdb41e6913b2b9e8a18d6e61d3199 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Tue, 9 May 2017 09:37:21 +0200 Subject: [PATCH] agent: Disallow :: or [::] as advertise or advertise-wan address --- command/agent/command.go | 8 ++++---- command/agent/command_test.go | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/command/agent/command.go b/command/agent/command.go index 0db0f0b16..4326ab430 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -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 } diff --git a/command/agent/command_test.go b/command/agent/command_test.go index cd4cfb2f9..676df6b19 100644 --- a/command/agent/command_test.go +++ b/command/agent/command_test.go @@ -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 {