Improve peer location update logic and posture check condition handling

This commit is contained in:
mlsmaycon
2026-06-23 14:19:20 +02:00
parent 58cd0eae4e
commit b4c1db17e4
2 changed files with 12 additions and 4 deletions

View File

@@ -201,14 +201,14 @@ func (am *DefaultAccountManager) resolvePeerLocation(ctx context.Context, peer *
if am.geo == nil || realIP == nil {
return nil
}
if peer.Location.ConnectionIP != nil && peer.Location.ConnectionIP.Equal(realIP) {
return nil
}
location, err := am.geo.Lookup(realIP)
if err != nil {
log.WithContext(ctx).Warnf("failed to get location for peer %s realip: [%s]: %v", peer.ID, realIP.String(), err)
return nil
}
if peer.Location.ConnectionIP != nil && peer.Location.ConnectionIP.Equal(realIP) && peer.Location.GeoNameID == location.City.GeonameID {
return nil
}
return &nbpeer.Location{
ConnectionIP: realIP,
CountryCode: location.Country.ISOCode,

View File

@@ -74,7 +74,15 @@ func AffectsPosture(diff *nbpeer.MetaDiff, checks []*Checks) bool {
return true
}
if c.Checks.PeerNetworkRangeCheck != nil && diff.NetworkAddresses {
return true
if diff.LocationChanged {
return true
}
for _, r := range c.Checks.PeerNetworkRangeCheck.Ranges {
if r.Addr().IsPrivate() {
return true
}
}
return false
}
}
return false