fix: separate known-peers index from peer store to fix blocking for shared URLs#477
fix: separate known-peers index from peer store to fix blocking for shared URLs#477
Conversation
…hared URLs Introduce a new `KnownPeers` trait as an append-only index of all ever-seen agent infos. `MemPeerStore::insert` records to `KnownPeers` before any block or expiry filtering so that the URL→agent mapping is always available. `CorePeerAccessState` now uses `KnownPeers::get_by_url` instead of `PeerStore::get_by_url` for access control decisions, ensuring that blocked agents (which are excluded from `PeerStore`) still block incoming connections from a shared URL. Fixes #450 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
✔️ fccc54f - Conventional commits check succeeded. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The following will be added to the changelog [0.4.0-dev.5] - 2026-03-11Bug Fixes
|
Deploying kitsune2 with
|
| Latest commit: |
fccc54f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://717e3c06.kitsune2.pages.dev |
| Branch Preview URL: | https://fix-blocking-peer-store-cont.kitsune2.pages.dev |
Closes #450
Problem
The blocking implementation had a fundamental design contradiction:
PeerStore(not inserted; removed on block) to prevent gossip with themCorePeerAccessStateusedPeerStore::get_by_urlto map peer URLs → agent IDs in order to decide whether to block incoming connectionsThese assumptions are mutually incompatible. When a blocked agent is removed from the peer store, the URL lookup can no longer find them. If a non-blocked agent shares the same peer URL, the lookup finds the non-blocked agent, sees no block, and incorrectly grants access — allowing the blocked agent's traffic through.
Net result: blocking only worked when all agents at a peer URL were blocked, not when any were.
Solution
Introduce a new
KnownPeerstrait in theapicrate: an append-only index of all ever-seen agent infos, including blocked ones, used purely for URL → agent ID resolution by the access control layer.KnownPeers::record— records agent infos without any block filteringKnownPeers::get_by_url— returns all known agents at a URL regardless of block statusCorePeerAccessStatenow usesDynKnownPeersfor URL lookups instead ofDynPeerStore. Agent infos are recorded intoKnownPeersbefore the block filter runs, so blocked agents remain findable for access control purposes even after being removed from the peer store.A new integration test verifies the fixed behaviour: a blocked agent sharing a peer URL with a non-blocked agent is correctly blocked.