diff options
author | bt90 <btom1990@googlemail.com> | 2023-09-12 14:34:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-12 12:34:30 +0000 |
commit | e860d3b974513956c562d0eb34aef0ea120c6b06 (patch) | |
tree | 6dcab697289f17ff23dbba6cba13c6fdfdb62c8b | |
parent | ed66fba42b0673487260d4219084df198a505975 (diff) |
lib/connections: Make assumptions about isLAN when interface address listing fails (#9093)
-rw-r--r-- | lib/connections/service.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/connections/service.go b/lib/connections/service.go index 23968fc806..c08a47c95d 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 |