1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Merge pull request #701 from h-hy/master

Check last for the address binded in lo interface (LVS , DR mode)
This commit is contained in:
Asim Aslam 2019-08-27 18:08:52 +01:00 committed by GitHub
commit 470304ef87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,14 +40,20 @@ func Extract(addr string) (string, error) {
}
var addrs []net.Addr
var loAddrs []net.Addr
for _, iface := range ifaces {
ifaceAddrs, err := iface.Addrs()
if err != nil {
// ignore error, interface can dissapear from system
continue
}
if iface.Flags&net.FlagLoopback != 0 {
loAddrs = append(loAddrs, ifaceAddrs...)
continue
}
addrs = append(addrs, ifaceAddrs...)
}
addrs = append(addrs, loAddrs...)
var ipAddr []byte
var publicIP []byte