Setting the ip from the network interface to Addresses

This commit is contained in:
Diptanu Choudhury
2016-03-18 22:26:13 -07:00
parent fa52d4921c
commit ce29ce5b53
2 changed files with 3 additions and 2 deletions

View File

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

View File

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