mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 09:47:49 +02:00
increment network serial
This commit is contained in:
parent
0c7cac81f0
commit
4b44b8c46c
@ -1615,6 +1615,10 @@ func (am *DefaultAccountManager) GetDNSDomain(settings *types.Settings) string {
|
|||||||
|
|
||||||
func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) {
|
func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) {
|
||||||
log.WithContext(ctx).Debugf("validated peers has been invalidated for account %s", accountID)
|
log.WithContext(ctx).Debugf("validated peers has been invalidated for account %s", accountID)
|
||||||
|
err := am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
|
||||||
|
}
|
||||||
am.BufferUpdateAccountPeers(ctx, accountID)
|
am.BufferUpdateAccountPeers(ctx, accountID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +144,10 @@ func (am *DefaultAccountManager) MarkPeerConnected(ctx context.Context, peerPubK
|
|||||||
if expired {
|
if expired {
|
||||||
// we need to update other peers because when peer login expires all other peers are notified to disconnect from
|
// we need to update other peers because when peer login expires all other peers are notified to disconnect from
|
||||||
// the expired one. Here we notify them that connection is now allowed again.
|
// the expired one. Here we notify them that connection is now allowed again.
|
||||||
|
err := am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
|
||||||
|
}
|
||||||
am.BufferUpdateAccountPeers(ctx, accountID)
|
am.BufferUpdateAccountPeers(ctx, accountID)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +274,11 @@ func (am *DefaultAccountManager) UpdatePeer(ctx context.Context, accountID, user
|
|||||||
inactivityExpirationChanged = true
|
inactivityExpirationChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = transaction.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return transaction.SavePeer(ctx, store.LockingStrengthUpdate, accountID, peer)
|
return transaction.SavePeer(ctx, store.LockingStrengthUpdate, accountID, peer)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -960,6 +960,12 @@ func (am *DefaultAccountManager) expireAndUpdatePeers(ctx context.Context, accou
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ideally this should run in a transaction
|
||||||
|
err = am.Store.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to increment network serial number for account %s: %v", accountID, err)
|
||||||
|
}
|
||||||
|
|
||||||
if len(peerIDs) != 0 {
|
if len(peerIDs) != 0 {
|
||||||
// this will trigger peer disconnect from the management service
|
// this will trigger peer disconnect from the management service
|
||||||
am.peersUpdateManager.CloseChannels(ctx, peerIDs)
|
am.peersUpdateManager.CloseChannels(ctx, peerIDs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user