Skip to content

id(abuse): enforce operator IP blocks at connection admission (#2245) - #4972

Merged
dezren39 merged 1 commit into
mainfrom
queue/8075-2245-ip-block-listener
Nov 3, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/8075-2245-ip-block-listener

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

What

Phase 1 follow-up for #2245 (queue task 8075): the persisted operator block list landed in PR #4874 with peer-key enforcement at session admission, but the BlockList::ip_blocked seam had no admission call site — AbuseEvaluator::open_connection took no IP. This wires it.

  • pkgs/id/src/abuse.rs: new AbuseEvaluator::open_connection_with_direct_ip(endpoint, direct_ip, now_ms). When direct_ip is Some and the attached block list blocks that IP, the connection is refused with Refusal::blocked_by_operator() before any bucket or cap is consulted. open_connection delegates with None, so every existing caller behaves exactly as before; relayed connections (no observed IP) are never refused by an IP block.
  • pkgs/id/src/world_net.rs: accept supplies the direct IP via direct_ip_of — the selected path's TransportAddr::Ip address; a relay or custom-transport selected path yields None. Best-effort at the listener, exactly as id(comms): operator block list by public key, with one-button block in the web UI (P0 of #2032) #2245 scopes IP enforcement ("a relayed peer has no visible IP"); a direct path that opens after admission is not re-judged.
  • pkgs/id/src/pull_policy.rs (+ one literal in log_sync.rs): the shared StubBlocks test double gains an IP arm and a stub_blocks_with_ips constructor (it previously answered false for every IP).

Tests

On the laptop, against this branch:

  • cargo test --lib block in pkgs/id — 21 passed, including the new targeted test abuse::tests::a_blocked_direct_ip_is_refused_a_new_connection (blocked direct IP refused at admission with no connection registered; unblocked direct IP admitted; relayed None admitted) and all pre-existing block tests.
  • cargo test --lib abuse:: — 22 passed (no regression in the evaluator).

Scope notes

In scope only: no change to block storage, no web UI (Phase 2), no author muting. Issue #2245 stays open — the web-UI phase remains; this closes the last unwired Phase 1 admission seam named by task 5848's packet.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

AbuseEvaluator::open_connection consulted only peer_blocked; the BlockList ip_blocked seam landed in Phase 1 (PR #4874) had no admission call site. Add open_connection_with_direct_ip: when a listener directly observed the remote IP and the block list blocks it, the connection is refused with Refusal::blocked_by_operator() before any bucket or cap; relayed connections (no IP) are judged exactly as before. open_connection delegates with None, so existing callers are unchanged.

world_net accept now supplies the selected paths direct IP (TransportAddr::Ip) via direct_ip_of; relay/custom selected paths yield None. The shared StubBlocks test double gains an IP arm (stub_blocks_with_ips).

Tests (laptop): cargo test --lib block — 21 passed incl. new abuse::tests::a_blocked_direct_ip_is_refused_a_new_connection; cargo test --lib abuse:: — 22 passed.
@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 14:55
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-11-03T14:55:32.395452Z
We couldn’t complete this review. Comment @codex review to try again.
968226d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8162178d-961e-44ca-8668-40189ed040b3
Commits

Reviewing files that changed from the base of the PR and between 91c3b19 and 968226d.

Files selected for processing: 4
  • pkgs/id/src/abuse.rs
  • pkgs/id/src/log_sync.rs
  • pkgs/id/src/pull_policy.rs
  • pkgs/id/src/world_net.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39
dezren39 merged commit d3476bc into main Nov 3, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/8075-2245-ip-block-listener branch November 3, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant