mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-05 00:54:01 -04:00
[management] expire invalid peer (#4275)
This commit is contained in:
@@ -251,8 +251,8 @@ func BuildManager(
|
||||
}()
|
||||
}
|
||||
|
||||
am.integratedPeerValidator.SetPeerInvalidationListener(func(accountID string) {
|
||||
am.onPeersInvalidated(ctx, accountID)
|
||||
am.integratedPeerValidator.SetPeerInvalidationListener(func(accountID string, peerIDs []string) {
|
||||
am.onPeersInvalidated(ctx, accountID, peerIDs)
|
||||
})
|
||||
|
||||
return am, nil
|
||||
@@ -1719,9 +1719,27 @@ func (am *DefaultAccountManager) GetDNSDomain(settings *types.Settings) string {
|
||||
return settings.DNSDomain
|
||||
}
|
||||
|
||||
func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) {
|
||||
log.WithContext(ctx).Debugf("validated peers has been invalidated for account %s", accountID)
|
||||
am.BufferUpdateAccountPeers(ctx, accountID)
|
||||
func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string, peerIDs []string) {
|
||||
peers := []*nbpeer.Peer{}
|
||||
log.WithContext(ctx).Debugf("invalidating peers %v for account %s", peerIDs, accountID)
|
||||
for _, peerID := range peerIDs {
|
||||
peer, err := am.GetPeer(ctx, accountID, peerID, activity.SystemInitiator)
|
||||
if err != nil {
|
||||
log.WithContext(ctx).Errorf("failed to get invalidated peer %s for account %s: %v", peerID, accountID, err)
|
||||
continue
|
||||
}
|
||||
peers = append(peers, peer)
|
||||
}
|
||||
if len(peers) > 0 {
|
||||
err := am.expireAndUpdatePeers(ctx, accountID, peers)
|
||||
if err != nil {
|
||||
log.WithContext(ctx).Errorf("failed to expire and update invalidated peers for account %s: %v", accountID, err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.WithContext(ctx).Debugf("running invalidation with no invalid peers")
|
||||
}
|
||||
log.WithContext(ctx).Debugf("invalidated peers have been expired for account %s", accountID)
|
||||
}
|
||||
|
||||
func (am *DefaultAccountManager) FindExistingPostureCheck(accountID string, checks *posture.ChecksDefinition) (*posture.Checks, error) {
|
||||
|
||||
Reference in New Issue
Block a user