From e860d3b974513956c562d0eb34aef0ea120c6b06 Mon Sep 17 00:00:00 2001 From: bt90 Date: Tue, 12 Sep 2023 14:34:30 +0200 Subject: [PATCH] lib/connections: Make assumptions about isLAN when interface address listing fails (#9093) --- lib/connections/service.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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