From a6ab4d7b4b89673e301c35905e8677270b902a10 Mon Sep 17 00:00:00 2001 From: huanghaoyan Date: Tue, 27 Aug 2019 23:33:30 +0800 Subject: [PATCH] check last for the address bind in lo interface. --- util/addr/addr.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/addr/addr.go b/util/addr/addr.go index 36a78f92..911dacb0 100644 --- a/util/addr/addr.go +++ b/util/addr/addr.go @@ -40,6 +40,7 @@ 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 { @@ -47,10 +48,12 @@ func Extract(addr string) (string, error) { 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