浏览代码

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

Sean Baildon 4 年之前
父节点
当前提交
9ec155b843
共有 1 个文件被更改,包括 4 次插入0 次删除
  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{}{}
 			ignore[oneAddressCIDR(ip.IP).String()] = struct{}{}
 		}
 		}
 	}
 	}
+
 	var hostPriv, hostPub []*net.IPNet
 	var hostPriv, hostPub []*net.IPNet
 	{
 	{
 		// Check IPs to which hostname resolves first.
 		// Check IPs to which hostname resolves first.
@@ -71,6 +72,9 @@ func getIP(hostname string, ignoreIfaces ...int) (*net.IPNet, *net.IPNet, error)
 			if !ok {
 			if !ok {
 				continue
 				continue
 			}
 			}
+			if isLocal(ip.IP) {
+				continue
+			}
 			ip.Mask = mask
 			ip.Mask = mask
 			if isPublic(ip.IP) {
 			if isPublic(ip.IP) {
 				hostPub = append(hostPub, ip)
 				hostPub = append(hostPub, ip)