Feat/i2p peer support - #2050
Conversation
|
Hi @Frigyes06, than your for you contribution. I was on holiday and I have just seen the PR. I did not know i2p, so it would take me a while to review the PR. It look good! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2050 +/- ##
===========================================
+ Coverage 82.01% 82.25% +0.24%
===========================================
Files 348 349 +1
Lines 24795 25072 +277
Branches 24795 25072 +277
===========================================
+ Hits 20336 20624 +288
+ Misses 4148 4141 -7
+ Partials 311 307 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds HTTP-based I2P peer announcing, network-isolated matchmaking, and I2P response encoding.
Changes:
- Introduces validated I2P destinations and generalized peer addresses.
- Adds I2P HTTP announce parsing and compact/non-compact responses.
- Updates dependent services, tests, benchmarks, and documentation.
Reviewed changes
Copilot reviewed 44 out of 45 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
README.md |
Advertises I2P support. |
project-words.txt |
Adds I2P spelling. |
packages/udp-server/src/lib.rs |
Adapts UDP fixtures. |
packages/udp-server/src/handlers/announce.rs |
Handles optional clearnet IPs. |
packages/udp-core/src/peer_builder.rs |
Wraps UDP addresses. |
packages/tracker-core/tests/common/test_env.rs |
Clones non-Copy peers. |
packages/tracker-core/tests/common/fixtures.rs |
Adapts peer fixtures. |
packages/tracker-core/src/torrent/services.rs |
Clones generalized peers. |
packages/tracker-core/src/test_helpers.rs |
Updates test peers. |
packages/tracker-core/src/peer_tests.rs |
Updates serialization fixture. |
packages/tracker-core/src/announce_handler.rs |
Preserves I2P addresses. |
packages/torrent-repository-benchmarking/tests/repository/mod.rs |
Updates ownership handling. |
packages/torrent-repository-benchmarking/tests/entry/mod.rs |
Adapts address comparisons. |
packages/torrent-repository-benchmarking/src/entry/single.rs |
Uses generalized addresses. |
packages/torrent-repository-benchmarking/src/entry/peer_list.rs |
Generalizes exclusion logic. |
packages/torrent-repository-benchmarking/benches/helpers/utils.rs |
Updates benchmark peer. |
packages/swarm-coordination-registry/src/swarm/registry.rs |
Clones non-Copy peers. |
packages/swarm-coordination-registry/src/swarm/coordinator.rs |
Stores and isolates I2P peers. |
packages/swarm-coordination-registry/src/statistics/event/handler.rs |
Updates event ownership. |
packages/swarm-coordination-registry/src/lib.rs |
Updates fixtures. |
packages/swarm-coordination-registry/examples/bench_peers.rs |
Adapts benchmark addresses. |
packages/rest-api-runtime-adapter/src/v1/conversion.rs |
Converts peers by reference. |
packages/rest-api-runtime-adapter/src/v1/adapters/torrent.rs |
Adapts torrent conversion. |
packages/primitives/src/peer.rs |
Introduces PeerAddress. |
packages/primitives/src/lib.rs |
Exports I2P primitives. |
packages/primitives/src/i2p.rs |
Validates and hashes destinations. |
packages/primitives/Cargo.toml |
Adds Base64 and SHA-256 dependencies. |
packages/http-protocol/src/v1/responses/announce/mod.rs |
Exports response addresses. |
packages/http-protocol/src/v1/responses/announce/encoding.rs |
Encodes I2P responses. |
packages/http-protocol/src/v1/responses/announce/data.rs |
Generalizes response peers. |
packages/http-protocol/src/v1/requests/announce.rs |
Parses I2P announce addresses. |
packages/http-protocol/src/v1/query.rs |
Preserves = in values. |
packages/http-protocol/Cargo.toml |
Adds primitives dependency. |
packages/http-core/src/services/scrape.rs |
Adapts optional IP access. |
packages/http-core/src/services/announce.rs |
Coordinates I2P announcements. |
packages/http-core/src/lib.rs |
Updates fixtures. |
packages/http-core/benches/helpers/util.rs |
Adapts benchmark helpers. |
packages/http-core/benches/helpers/sync.rs |
Updates borrowed peer usage. |
packages/axum-rest-api-server/tests/server/v1/contract/context/torrent.rs |
Updates conversion test. |
packages/axum-http-server/tests/server/v1/contract/for_all_config_modes/receiving_an_announce_request.rs |
Adds I2P contract coverage. |
packages/axum-http-server/src/v1/handlers/announce.rs |
Maps domain I2P responses. |
packages/axum-http-server/src/v1/extractors/announce_request.rs |
Updates request expectations. |
docs/packages.md |
Documents I2P wire behavior. |
cspell.json |
Excludes runtime storage. |
Cargo.lock |
Locks new dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| .filter(|peer| peer::ReadInfo::get_address(peer.as_ref()) != peer_addr) | ||
| .filter(|peer| peer.peer_addr.is_i2p() == peer_addr.is_i2p()); |
| Err(_) => {} | ||
| } | ||
|
|
||
| Ok(None) |
| /// The SHA-256 hash of an I2P Destination. | ||
| I2p([u8; 32]), |
josecelano
left a comment
There was a problem hiding this comment.
Hi @Frigyes06 — thanks again for the I2P implementation.
I prepared a rebased, GPG-signed draft PR that supersedes this one: #2059. It preserves your authorship for the implementation commits and includes the full review report plus reproducible manual-test evidence in docs/pr-reviews-manual/pr-2050/.
The main items to address before merge are:
- Percent-decode I2P Destination query values so valid
%3D%3DBase64 padding is accepted (a disabled regression test is prepared). - Add I2P-aware compact-response deserialization; do not parse 32-byte Destination hashes as IPv4 peer entries.
- Preserve structured I2P parsing errors instead of returning only generic
InvalidParam. - Bound and structurally validate untrusted Destination input before decoding, and avoid reflecting the full value in error responses.
Please use the #2059 branch as the base for follow-up fixes. The report also records planned follow-up work for the tracker client and the REST API redesign.
|
@da2ce7 in general, we should consider if we want to support the protocol. There are some edge cases that can mislead "clearnet" peers (for example, reusing the I don't see any major issue to not support it. I think it could even make the code a little bit more generic to accept other types of peers in the future. |
|
Hi @Frigyes06 — the signed replacement draft, PR #2059, now includes a dedicated Destination spoofing analysis. This identifies a merge-blocking trust-boundary problem: a normal HTTP announce does not prove that a client owns the I2P Destination supplied in The unverified-identity model also permits fabricated-Destination spam: many announces using distinct but attacker-unowned Destinations can pollute swarms and consume registry, CPU, persistence, cleanup, metrics, and response resources. Before the final I2P-support PR can merge, please choose and implement one safe policy:
For Policy 1, also document and test the trust boundary: configured trusted source, loopback-only forwarding listener, missing or malformed identity context, matching and mismatching query Destinations, direct-listener access, and attempted peer-record takeover. Identity enforcement must be complemented by bounded input, rate limits keyed by trusted identity/source, peer-admission and response limits, expiry/cleanup, and privacy-aware abuse metrics. Please use PR #2059 as the base for follow-up work. Its updated description and the review documents list all mandatory actions A1–A7. The REST representation remains deferred to epic #144 and an ADR. |
No description provided.