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

This commit is contained in:
bt90 2023-09-12 14:34:30 +02:00 committed by GitHub
parent ed66fba42b
commit e860d3b974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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