aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbt90 <btom1990@googlemail.com>2023-09-12 14:34:30 +0200
committerGitHub <noreply@github.com>2023-09-12 12:34:30 +0000
commite860d3b974513956c562d0eb34aef0ea120c6b06 (patch)
tree6dcab697289f17ff23dbba6cba13c6fdfdb62c8b
parented66fba42b0673487260d4219084df198a505975 (diff)
downloadsyncthing-e860d3b974513956c562d0eb34aef0ea120c6b06.tar.gz
syncthing-e860d3b974513956c562d0eb34aef0ea120c6b06.zip
lib/connections: Make assumptions about isLAN when interface address listing fails (#9093)
-rw-r--r--lib/connections/service.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/connections/service.go b/lib/connections/service.go
index 23968fc80..c08a47c95 100644
--- a/lib/connections/service.go
+++ b/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