From ce29ce5b533d7748ed3a8d7998b34b47d2ade03a Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Fri, 18 Mar 2016 22:26:13 -0700 Subject: [PATCH] Setting the ip from the network interface to Addresses --- command/agent/agent.go | 1 + command/agent/util.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index a8088325e..fb6f549e8 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -220,6 +220,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) { if err != nil { return nil, fmt.Errorf("error finding ip address from interface %q: %v", a.config.Interfaces.HTTP, err) } + a.config.Addresses.HTTP = ip.String() httpAddr = fmt.Sprintf("%s:%d", ip.String(), a.config.Ports.HTTP) } else if a.config.AdvertiseAddrs.HTTP != "" { addr, err := net.ResolveTCPAddr("tcp", a.config.AdvertiseAddrs.HTTP) diff --git a/command/agent/util.go b/command/agent/util.go index 6645a0af9..fc9186728 100644 --- a/command/agent/util.go +++ b/command/agent/util.go @@ -31,8 +31,6 @@ func ipOfDevice(name string) (net.IP, error) { var ip net.IP switch v := (addr).(type) { case *net.IPNet: - continue - case *net.IPAddr: ip = v.IP if ip.To4() != nil { ipv4Addrs = append(ipv4Addrs, ip) @@ -42,6 +40,8 @@ func ipOfDevice(name string) (net.IP, error) { ipv6Addrs = append(ipv6Addrs, ip) continue } + case *net.IPAddr: + continue } } if len(ipv4Addrs) > 0 {