Explorar o código

pkg/mesh: filter local IP addresses when scanning for ips resolved by hostname

Sean Baildon %!s(int64=4) %!d(string=hai) anos
pai
achega
9ec155b843
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      pkg/mesh/discoverips.go

+ 4 - 0
pkg/mesh/discoverips.go

@@ -59,6 +59,7 @@ func getIP(hostname string, ignoreIfaces ...int) (*net.IPNet, *net.IPNet, error)
 			ignore[oneAddressCIDR(ip.IP).String()] = struct{}{}
 		}
 	}
+
 	var hostPriv, hostPub []*net.IPNet
 	{
 		// Check IPs to which hostname resolves first.
@@ -71,6 +72,9 @@ func getIP(hostname string, ignoreIfaces ...int) (*net.IPNet, *net.IPNet, error)
 			if !ok {
 				continue
 			}
+			if isLocal(ip.IP) {
+				continue
+			}
 			ip.Mask = mask
 			if isPublic(ip.IP) {
 				hostPub = append(hostPub, ip)