Skip to content

Feat/i2p peer support - #2050

Closed
Frigyes06 wants to merge 2 commits into
torrust:developfrom
Frigyes06:feat/i2p-peer-support
Closed

Frigyes06 wants to merge 2 commits into
torrust:developfrom
Frigyes06:feat/i2p-peer-support

Conversation

@Frigyes06

Copy link
Copy Markdown

No description provided.

@josecelano

josecelano commented Aug 17, 2026 •

Copy link
Copy Markdown
Member

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!

@josecelano
josecelano requested review from da2ce7 and a balanced review from Copilot August 17, 2026 09:01
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.48428% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.25%. Comparing base (c1ea423) to head (ca3006f).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
packages/primitives/src/peer.rs 86.04% 6 Missing ⚠️
packages/http-protocol/src/v1/requests/announce.rs 97.01% 0 Missing and 2 partials ⚠️
packages/udp-server/src/handlers/announce.rs 85.71% 0 Missing and 2 partials ⚠️
packages/http-core/src/services/announce.rs 98.03% 0 Missing and 1 partial ⚠️
...ent-repository-benchmarking/src/entry/peer_list.rs 90.90% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +71 to +72
.filter(|peer| peer::ReadInfo::get_address(peer.as_ref()) != peer_addr)
.filter(|peer| peer.peer_addr.is_i2p() == peer_addr.is_i2p());
Comment on lines +609 to +612
Err(_) => {}
}

Ok(None)
Comment on lines +220 to +221
/// The SHA-256 hash of an I2P Destination.
I2p([u8; 32]),

@josecelano josecelano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Percent-decode I2P Destination query values so valid %3D%3D Base64 padding is accepted (a disabled regression test is prepared).
  2. Add I2P-aware compact-response deserialization; do not parse 32-byte Destination hashes as IPv4 peer entries.
  3. Preserve structured I2P parsing errors instead of returning only generic InvalidParam.
  4. 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.

@josecelano

Copy link
Copy Markdown
Member

@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 ip announce GET param to provide the peer destination in the I2P network). We also have to decide how the API should handle this new type of peers.

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.

@josecelano

Copy link
Copy Markdown
Member

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 ip. A client can claim a victim Destination, obtain I2P swarm information, and update or remove that peer record.

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:

  1. Trusted transport-derived identity: Support I2P announces only through a dedicated trusted listener. Derive the peer Destination from validated I2P transport context—for example, a trusted server-tunnel identity header or a SAMv3/I2CP adapter—and reject direct/untrusted requests and query/header mismatches.
  2. Disable I2P announces: Reject I2P Destinations until transport-derived identity enforcement is available.

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.

@josecelano

Copy link
Copy Markdown
Member

i2p support is delay until we release version 4.0.0. We are focused on releasing that new version.

@josecelano
josecelano marked this pull request as draft September 10, 2026 09:39
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 8, 2026
Track I2P peer support as an EPIC so the proposal in PRs torrust#2050 and
torrust#2059 survives closing them. The EPIC is blocked until v4.0.0 (torrust#1659)
ships; its first phase is a design discussion.

Co-authored-by: Copilot <[email protected]>
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 8, 2026
…scussion

Keep what was learned from PR torrust#2050 and its maintainer review in draft
PR torrust#2059 before both PRs are closed. The discussion summarizes the
proposal, the review actions, and what changed on develop since, and
lists the open design questions for after v4.0.0.

The four review documents from the PR torrust#2059 branch are kept as source
material. Their frontmatter, which the validator rejects, is preserved
verbatim in each file, and one link to the archived torrust#1987 spec is
repointed.

This commit also links the EPIC to the discussion and records the opening
round in the EPIC progress log.

Co-authored-by: Copilot <[email protected]>
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 8, 2026
Attribute the recorded review and positions only to Jose. Cameron has no
review or position in PRs torrust#2050 or torrust#2059 and can add his own discussion
round later.

Co-authored-by: Copilot <[email protected]>
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Oct 8, 2026
PR torrust#2050 dates from July 2026; only the rebased draft PR torrust#2059 dates
from August.

Co-authored-by: Copilot <[email protected]>
josecelano added a commit that referenced this pull request Oct 8, 2026
…ign discussion

54c665c docs(pr-review): [#2492] audit round 2 review findings (Jose Celano)
cb32a87 docs(pr-review): [#2492] correct the review-log timestamp explanation (Jose Celano)
1069935 docs(pr-review): [#2492] record review completion (Jose Celano)
6ab2281 docs(pr-review): [#2492] audit Cameron's review findings (Jose Celano)
7b1c6c2 docs(issues): [#2491] correct I2P proposal dates (Jose Celano)
1968b14 docs(issues): [#2491] correct I2P EPIC review attribution (Jose Celano)
3317b4d docs(discussions): [#2491] correct I2P review attribution (Jose Celano)
3083870 docs(discussions): [#2491] name the opening round's PR in position headings (Jose Celano)
1caf9e6 docs(discussions): [#2491] open the I2P peer support design discussion (Jose Celano)
28c655d docs(issues): [#2491] add I2P peer support EPIC specification (Jose Celano)

Pull request description:

  Related to #2491

  ## Summary

  Opens EPIC #2491 (I2P peer support) and a design discussion that keeps everything learned from PR #2050 and its maintainer review in draft PR #2059, so that both PRs can be closed without losing it. Jose Celano supports I2P peer support, but it needs a careful design that covers its edge cases, and the work is postponed until v4.0.0 (#1659) is released. Closing the PRs does not reject the feature; they remain reference artifacts.

  This is the opening round of the discussion, under the rules in `docs/discussions/AGENTS.md`. Cameron's concerns are not written in either PR, so they belong in his own contribution round.

  ## Changes

  - `docs/issues/open/2491-i2p-peer-support/EPIC.md`: lightweight EPIC spec, status `blocked` until v4.0.0, no owner yet. Phases: preserve the proposal, design discussion, ADRs and subissues, implementation.
  - `docs/discussions/2491-i2p-peer-support/20261008-i2p-peer-support-design/README.md`: context (timeline, where the material lives, what the proposal does, review actions A1 to A7 and follow-ups, what changed on `develop` since), ten topics (Q1 to Q10), and positions by Jose Celano on Q2, Q4, Q6, and Q8 restated from his PR comments and review. The Outcome is pending.
  - Four review documents copied from `docs/pr-reviews-manual/pr-2050/` on the PR #2059 branch (`883ab677f`) as source material: `review-pass-1.md`, `destination-spoofing-analysis.md`, `i2p-addressing-primer.md`, and `manual-test-evidence.md`. The text is kept as written. The original frontmatter, which the validator rejects, is preserved verbatim in a block in each file, and one link to the archived issue 1987 spec was repointed. Each file says so at its top.
  - `docs/index.md`: discussion entry.
  - `project-words.txt`: six words used by the review documents.

  ## Notable facts recorded in the discussion

  - The PR #2059 branch is 2,455 commits behind `develop` (`23891ad8f`); 28 of its 40 code files changed since its base, and a trial merge conflicts in 14 files. Reusing the code means reworking it.
  - Issue 1987 shipped `use_ip_from_query_string` without the I2P precedence rule that the PR #2059 branch had added to its spec, so that precedence is an open question (Q3).

  ## Validation

  - Pre-commit hook passed on each commit (frontmatter validator, `linter all`, doc tests).
  - Pre-push hook passed (nightly checks and the full stable test suite).

  ## After merge

  Close PRs #2050 and #2059 with a comment linking EPIC #2491 and this discussion.

ACKs for top commit:
  da2ce7:
    ACK 54c665c — F7 and F8 fixed, the audit's round-2 rows and log verified against the capture, and every earlier ruling carried on unchanged bytes
  josecelano:
    ACK 54c665c

Tree-SHA512: b049b87cb0c564f0dbabef76685575683d2c2ad500024b08661f72261fe4e3b41c8536c7cc0c36c63dbab617baa5f3e30217f8b4fc6f257f905941a2407108fa
@josecelano

Copy link
Copy Markdown
Member

Closing this PR for now. This does not reject I2P support, and it is not a judgement on your work, @Frigyes06: thank you for the implementation.

We support adding I2P peer support, but it needs a careful design that covers its edge cases first, especially how the tracker trusts a peer's Destination. We are also focused on releasing v4.0.0 (#1659). The work is postponed until after that release, when we redefine the roadmap.

So that nothing is lost:

When the work resumes, contributions to the discussion are welcome.

@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: This pull request was closed without merging, so none of its changes landed; its I2P peer support was resubmitted as #2059, which was also closed without merging.

This branch was previously deployed

1 inactive deployment
coverage — ca3006f5 Deployed Aug 17, 2026 by Frigyes06 via Generate Coverage Report #1744
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.

4 participants