Added the advertise http option to the client

This commit is contained in:
Diptanu Choudhury 2016-01-27 10:44:25 -08:00
parent e83130934d
commit 69a17e2a29
2 changed files with 13 additions and 1 deletions

View file

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

View file

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