fixing the logic of addr resolution

This commit is contained in:
Diptanu Choudhury 2016-02-16 13:13:40 -08:00
parent ba0dc9bca9
commit 0e7a2d68c1

View file

@ -227,11 +227,10 @@ func (a *Agent) setupClient() error {
conf.Node.NodeClass = a.config.Client.NodeClass
httpAddr := fmt.Sprintf("%s:%d", a.config.BindAddr, a.config.Ports.HTTP)
if a.config.Addresses.HTTP != "" && a.config.AdvertiseAddrs.HTTP == "" {
addr, err := net.ResolveTCPAddr("tcp", a.config.Addresses.HTTP)
if err != nil {
httpAddr = fmt.Sprintf("%s:%d", a.config.Addresses.HTTP, a.config.Ports.HTTP)
if _, err := net.ResolveTCPAddr("tcp", httpAddr); err != nil {
return fmt.Errorf("error resolving http addr: %v:", err)
}
httpAddr = fmt.Sprintf("%s:%d", addr.IP.String(), addr.Port)
} else if a.config.AdvertiseAddrs.HTTP != "" {
addr, err := net.ResolveTCPAddr("tcp", a.config.AdvertiseAddrs.HTTP)
if err != nil {