mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 10:58:57 +00:00
lib/connections: Make assumptions about isLAN when interface address listing fails (#9093)
This commit is contained in:
parent
ed66fba42b
commit
e860d3b974
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user