From 4b44b8c46c8699659ac6ec887a2b67dec021a948 Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Thu, 19 Jun 2025 12:14:26 +0200 Subject: [PATCH] increment network serial --- management/server/account.go | 4 ++++ management/server/peer.go | 9 +++++++++ management/server/user.go | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/management/server/account.go b/management/server/account.go index 82f5ee4a3..ac99dc93f 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -1615,6 +1615,10 @@ func (am *DefaultAccountManager) GetDNSDomain(settings *types.Settings) string { func (am *DefaultAccountManager) onPeersInvalidated(ctx context.Context, accountID string) { 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) } diff --git a/management/server/peer.go b/management/server/peer.go index 4a468a6cd..02f77c453 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -144,6 +144,10 @@ func (am *DefaultAccountManager) MarkPeerConnected(ctx context.Context, peerPubK if expired { // 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. + 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) } @@ -270,6 +274,11 @@ func (am *DefaultAccountManager) UpdatePeer(ctx context.Context, accountID, user inactivityExpirationChanged = true } + err = transaction.IncrementNetworkSerial(ctx, store.LockingStrengthUpdate, accountID) + if err != nil { + return err + } + return transaction.SavePeer(ctx, store.LockingStrengthUpdate, accountID, peer) }) if err != nil { diff --git a/management/server/user.go b/management/server/user.go index a1f1c46d5..8fb1aa446 100644 --- a/management/server/user.go +++ b/management/server/user.go @@ -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 { // this will trigger peer disconnect from the management service am.peersUpdateManager.CloseChannels(ctx, peerIDs)