[PR #698] [MERGED] Proactively expire peers' login per account #12885

Closed
opened 2026-08-05 02:06:55 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/698
Author: @braginini
Created: 2/20/2023
Status: Merged
Merged: 2/27/2023
Merged by: @braginini

Base: mainHead: feature/force_peer_expiration


📝 Commits (10+)

  • 5a3993a Enable peer login expiration by default when adding a peer
  • 7176f73 Force peer expiration
  • 153452f Check expiration on peer update and connect
  • 36dc28e Fix test
  • c5f9ce5 Fix lint and codacy issues
  • 6078c2b Optimize scheduler routines
  • 44b3a85 Add scheduler test
  • 51a756a Add scheduler performance test
  • 07a26cf Refactor to use nil duration in GetNextPeerExpiration
  • 52cdccf Skip already expired peers when cleaning up.

📊 Changes

9 files changed (+814 additions, -21 deletions)

View changed files

📝 management/server/account.go (+108 -2)
📝 management/server/account_test.go (+435 -0)
📝 management/server/grpcserver.go (+5 -2)
📝 management/server/peer.go (+39 -12)
📝 management/server/peer_test.go (+1 -1)
management/server/scheduler.go (+114 -0)
management/server/scheduler_test.go (+94 -0)
📝 management/server/turncredentials.go (+1 -0)
📝 management/server/updatechannel.go (+17 -4)

📄 Description

Describe your changes

Goals:

  • Enable peer login expiration when adding new peer
  • Expire peer's login when the time comes

The account manager triggers peer expiration routine in future if the
following conditions are true:

  • peer expiration is enabled for the account
  • there is at least one peer that has expiration enabled and is connected

The time of the next expiration check is based on the nearest peer expiration.
Account manager finds a peer with the oldest last login (auth) timestamp and
calculates the time when it has to run the routine as a sum of the configured
peer login expiration duration and the peer's last login time.

When triggered, the expiration routine checks whether there are expired peers.
The management server closes the update channel of these peers and updates
network map of other peers to exclude expired peers so that the expired peers
are not able to connect anywhere.

The account manager can reschedule or cancel peer expiration in the following cases:

  • when admin changes account setting (peer expiration enable/disable)
  • when admin updates the expiration duration of the account
  • when admin updates peer expiration (enable/disable)
  • when peer connects (Sync)

P.S. The network map calculation was updated to exclude peers that have login expired.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/698 **Author:** [@braginini](https://github.com/braginini) **Created:** 2/20/2023 **Status:** ✅ Merged **Merged:** 2/27/2023 **Merged by:** [@braginini](https://github.com/braginini) **Base:** `main` ← **Head:** `feature/force_peer_expiration` --- ### 📝 Commits (10+) - [`5a3993a`](https://github.com/netbirdio/netbird/commit/5a3993a8b29c5ce7647ce9209e37e8f8a0a5f5f8) Enable peer login expiration by default when adding a peer - [`7176f73`](https://github.com/netbirdio/netbird/commit/7176f735beefa5b27716ed44b39cb9f2b2f9db71) Force peer expiration - [`153452f`](https://github.com/netbirdio/netbird/commit/153452f1cb40359a6ed67b522d747176f2b3939d) Check expiration on peer update and connect - [`36dc28e`](https://github.com/netbirdio/netbird/commit/36dc28e559b3646c938238b81ab02c567c943685) Fix test - [`c5f9ce5`](https://github.com/netbirdio/netbird/commit/c5f9ce5bc809d063d8a280331d0441c744cffbc9) Fix lint and codacy issues - [`6078c2b`](https://github.com/netbirdio/netbird/commit/6078c2bb03d0ef97744bf75cc987e931c472b93a) Optimize scheduler routines - [`44b3a85`](https://github.com/netbirdio/netbird/commit/44b3a857109e43ca608e24065fb8f34c7dd7f86b) Add scheduler test - [`51a756a`](https://github.com/netbirdio/netbird/commit/51a756a4396421404af3d3c9895721c6fbaa813a) Add scheduler performance test - [`07a26cf`](https://github.com/netbirdio/netbird/commit/07a26cfdfa9e71b0fcfedd84ae1eab933aae02ff) Refactor to use nil duration in GetNextPeerExpiration - [`52cdccf`](https://github.com/netbirdio/netbird/commit/52cdccff7b57dd9e306949b88b2541daa4a8c565) Skip already expired peers when cleaning up. ### 📊 Changes **9 files changed** (+814 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `management/server/account.go` (+108 -2) 📝 `management/server/account_test.go` (+435 -0) 📝 `management/server/grpcserver.go` (+5 -2) 📝 `management/server/peer.go` (+39 -12) 📝 `management/server/peer_test.go` (+1 -1) ➕ `management/server/scheduler.go` (+114 -0) ➕ `management/server/scheduler_test.go` (+94 -0) 📝 `management/server/turncredentials.go` (+1 -0) 📝 `management/server/updatechannel.go` (+17 -4) </details> ### 📄 Description ## Describe your changes Goals: - Enable peer login expiration when adding new peer - Expire peer's login when the time comes The account manager triggers peer expiration routine in future if the following conditions are true: - peer expiration is enabled for the account - there is at least one peer that has expiration enabled and is connected The time of the next expiration check is based on the nearest peer expiration. Account manager finds a peer with the oldest last login (auth) timestamp and calculates the time when it has to run the routine as a sum of the configured peer login expiration duration and the peer's last login time. When triggered, the expiration routine checks whether there are expired peers. The management server closes the update channel of these peers and updates network map of other peers to exclude expired peers so that the expired peers are not able to connect anywhere. The account manager can reschedule or cancel peer expiration in the following cases: - when admin changes account setting (peer expiration enable/disable) - when admin updates the expiration duration of the account - when admin updates peer expiration (enable/disable) - when peer connects (Sync) P.S. The network map calculation was updated to exclude peers that have login expired. ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 02:06:55 -04:00
saavagebueno changed title from [PR #698] [MERGED] Proactively expire peers' login per account to [PR #698] [MERGED] Proactively expire peers' login per account 2026-08-05 03:07:21 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#12885