From 69a17e2a299173cd108999a956a781cac4d8d0d1 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Wed, 27 Jan 2016 10:44:25 -0800 Subject: [PATCH] Added the advertise http option to the client --- command/agent/agent.go | 13 ++++++++++++- command/agent/config.go | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 3b995363d..7ca4a6b9b 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -224,7 +224,18 @@ func (a *Agent) setupClient() error { conf.Node.NodeClass = a.config.Client.NodeClass httpAddr := a.config.BindAddr if a.config.Addresses.HTTP != "" { - httpAddr = a.config.Addresses.HTTP + addr, err := net.ResolveTCPAddr("tcp", a.config.Addresses.HTTP) + if err != nil { + return fmt.Errorf("error resolving http addr: %v:", err) + } + httpAddr = fmt.Sprintf("%s:%d", addr.IP.String(), addr.Port) + } + if a.config.AdvertiseAddrs.HTTP != "" { + addr, err := net.ResolveTCPAddr("tcp", a.config.AdvertiseAddrs.HTTP) + if err != nil { + return fmt.Errorf("error resolving advertise http addr: %v", err) + } + httpAddr = fmt.Sprintf("%s:%d", addr.IP.String(), addr.Port) } conf.Node.HTTPAddr = fmt.Sprintf("%s:%d", httpAddr, a.config.Ports.HTTP) diff --git a/command/agent/config.go b/command/agent/config.go index 7982dcbe5..6d9219f96 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -243,6 +243,7 @@ type Addresses struct { // different network services. Not all network services support an // advertise address. All are optional and default to BindAddr. type AdvertiseAddrs struct { + HTTP string `hcl:"http"` RPC string `hcl:"rpc"` Serf string `hcl:"serf"` }