Ver Fonte

lib/connections: Make assumptions about isLAN when interface address listing fails (#9093)

bt90 há 2 anos atrás
pai
commit
e860d3b974
1 ficheiros alterados com 12 adições e 1 exclusões
  1. 12 1
      lib/connections/service.go

+ 12 - 1
lib/connections/service.go

@@ -782,6 +782,10 @@ func (s *lanChecker) isLAN(addr net.Addr) bool {
 		return true
 	}
 
+	if ip.IsLinkLocalUnicast() {
+		return true
+	}
+
 	for _, lan := range s.cfg.Options().AlwaysLocalNets {
 		_, ipnet, err := net.ParseCIDR(lan)
 		if err != nil {
@@ -793,7 +797,14 @@ func (s *lanChecker) isLAN(addr net.Addr) bool {
 		}
 	}
 
-	lans, _ := osutil.GetLans()
+	lans, err := osutil.GetLans()
+	if err != nil {
+		l.Debugln("Failed to retrieve interface IPs:", err)
+		priv := ip.IsPrivate()
+		l.Debugf("Assuming isLAN=%v for IP %v", priv, ip)
+		return priv
+	}
+
 	for _, lan := range lans {
 		if lan.Contains(ip) {
 			return true