-
-
Notifications
You must be signed in to change notification settings - Fork 855
[management] login filter to fix multiple peers connected with the same pub key #3986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a login filter to enforce only one active connection per public key, integrates it into the account manager and gRPC server, and adds metrics and error handling for blocked requests.
- Introduce
loginFilter
with in-memory cache to track and block duplicate logins - Wire
loginFilter
intoDefaultAccountManager
and gRPCSync
/Login
handlers with metrics and logging - Add new blocked-request counters and
ErrPeerAlreadyLoggedIn
error type
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
management/server/telemetry/grpc_metrics.go | Added metrics/counters and methods for blocked sync and login requests |
management/server/status/error.go | Replaced ErrExtraSettingsNotFound creation and added ErrPeerAlreadyLoggedIn |
management/server/mock_server/account_mock.go | Added AllowSyncFunc stub and default AllowSync implementation |
management/server/loginfilter.go | Implemented loginFilter , allowLogin , addLogin , removeLogin |
management/server/loginfilter_test.go | Unit tests covering filter behaviors |
management/server/peer_test.go | Removed unused wireGuardPubKey field in test struct |
management/server/grpcserver.go | Integrated filter checks into Sync and Login , with logging & metrics |
management/server/account/manager.go | Exposed AllowSync in Manager interface |
management/server/account.go | Added loginFilter field and invoked filter in SyncAndMarkPeer & OnPeerDisconnected |
Comments suppressed due to low confidence (2)
management/server/grpcserver.go:472
- [nitpick] Using
AllowSync
for both sync and login flows can be confusing. Consider renaming to a more generic term (e.g.AllowConnection
) or splitting intoAllowSync
andAllowLogin
for clarity.
if !s.accountManager.AllowSync(peerKey.String(), metahashed) {
management/server/loginfilter_test.go:119
- Add a test verifying that repeated calls to
allowLogin
with the samemetaHash
within thefilterTimeout
window returntrue
as long as the peer isn’t banned.
s.True(s.filter.allowLogin(pubKey, meta2))
|
Describe your changes
We discovered that multiple machines using the same public key caused continuous reconnections. This PR introduces a login filter cache to allow only one connection per public key at a time.
Issue ticket number and link
Stack
Checklist