mirror of
https://github.com/safing/portmaster
synced 2025-09-04 11:39:29 +00:00
Reset device locations when network changes
This commit is contained in:
parent
650c272301
commit
014eb95eac
1 changed files with 11 additions and 0 deletions
|
@ -216,6 +216,10 @@ func SetInternetLocation(ip net.IP, source DeviceLocationSource) (dl *DeviceLoca
|
||||||
log.Warningf("netenv: failed to get geolocation data of %s (from %s): %s", ip, source, err)
|
log.Warningf("netenv: failed to get geolocation data of %s (from %s): %s", ip, source, err)
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
// Only use location if there is data for it.
|
||||||
|
if geoLoc.Country.ISOCode == "" {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
loc.Location = geoLoc
|
loc.Location = geoLoc
|
||||||
|
|
||||||
addLocation(loc)
|
addLocation(loc)
|
||||||
|
@ -271,6 +275,13 @@ func GetInternetLocation() (deviceLocations *DeviceLocations, ok bool) {
|
||||||
}
|
}
|
||||||
locationNetworkChangedFlag.Refresh()
|
locationNetworkChangedFlag.Refresh()
|
||||||
|
|
||||||
|
// Reset locations.
|
||||||
|
func() {
|
||||||
|
locationsLock.Lock()
|
||||||
|
defer locationsLock.Unlock()
|
||||||
|
locations = &DeviceLocations{}
|
||||||
|
}()
|
||||||
|
|
||||||
// Get all assigned addresses.
|
// Get all assigned addresses.
|
||||||
v4s, v6s, err := GetAssignedAddresses()
|
v4s, v6s, err := GetAssignedAddresses()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Add table
Reference in a new issue