Skip to content

feat(tracker-client): change default peer ID prefix from qB to RC#1761

Merged
josecelano merged 2 commits into
torrust:developfrom
josecelano:1564-change-default-peer-id
May 12, 2026
Merged

feat(tracker-client): change default peer ID prefix from qB to RC#1761
josecelano merged 2 commits into
torrust:developfrom
josecelano:1564-change-default-peer-id

Conversation

@josecelano
Copy link
Copy Markdown
Member

Summary

Replaces the hard-coded qBittorrent peer ID (-qB00000000000000001) used
in all tracker-client defaults with a Torrust-specific Azureus-style peer ID
using the RC (Rust Client) prefix.

Changes:

  • Add packages/tracker-client/src/peer_id.rs with:
    • DEFAULT_TEST_PEER_ID — deterministic constant for tests and fixtures
    • default_production_peer_id() — once-per-process randomized suffix via OnceLock
  • Wire production helper into QueryBuilder::with_default_values (HTTP client) and UDP checker
  • Update protocol doc examples and test fixtures to use -RC3000- convention
  • Update top-level doc example announce URL
  • Add ADR 20260512102000 documenting the RC prefix, version field convention (3000 for v3.0.0),
    test determinism policy, and package-decoupling rule

Issue spec: docs/issues/open/1564-tracker-client-change-default-peer-id.md

Closes: #1564
Parent EPIC: #669

Validation

  • linter all passes
  • cargo machete — no unused dependencies
  • cargo test -p bittorrent-tracker-client
  • cargo test -p torrust-tracker-client
  • cargo test -p bittorrent-http-tracker-protocol
  • ./contrib/dev-tools/git/hooks/pre-commit.sh — all checks pass

Replace the hard-coded qBittorrent peer ID (`-qB00000000000000001`) in all
tracker-client defaults with a Torrust-specific Azureus-style peer ID:

- Add `packages/tracker-client/src/peer_id.rs` with:
  - `DEFAULT_TEST_PEER_ID` — deterministic constant for tests/fixtures
  - `default_production_peer_id()` — once-per-process randomized suffix via OnceLock
- Wire production helper into HTTP QueryBuilder and UDP checker defaults
- Update protocol doc examples and test fixtures to use `-RC3000-` convention
- Update top-level doc example announce URL
- Add ADR 20260512102000 documenting the RC prefix, version field convention,
  test determinism policy, and package-decoupling rule

Closes torrust#1564
Copy link
Copy Markdown

Copilot AI left a 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 updates bittorrent-tracker-client defaults to stop advertising a qBittorrent-style peer ID and instead use a Torrust-specific Azureus-style peer ID with the -RC3000- prefix, updating affected docs and fixtures across the workspace.

Changes:

  • Added packages/tracker-client/src/peer_id.rs to centralize deterministic test peer IDs and a cached per-process production default.
  • Wired the new production peer ID generator into the HTTP announce default query builder and the UDP checker client.
  • Updated protocol docs/tests and repository documentation/ADR to reflect the new -RC3000-... convention.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib.rs Updates top-level announce URL documentation example to use -RC3000-....
packages/tracker-client/src/peer_id.rs Introduces peer ID constants and per-process default peer ID generation.
packages/tracker-client/src/lib.rs Exposes the new peer_id module.
packages/tracker-client/src/http/client/requests/announce.rs Uses the production default peer ID in QueryBuilder::with_default_values.
packages/http-protocol/src/v1/responses/announce.rs Updates doc/test fixtures to the new -RC3000-... peer IDs.
packages/http-protocol/src/v1/requests/announce.rs Updates doc/test fixtures to the new -RC3000-... peer IDs.
packages/http-protocol/src/v1/query.rs Updates query parsing tests to the new peer ID string.
docs/issues/open/1564-tracker-client-change-default-peer-id.md Marks implementation tasks as completed and adds evidence.
docs/adrs/index.md Adds ADR index entry for the peer ID convention.
docs/adrs/20260512102000_define_tracker_client_peer_id_convention.md Documents the new peer ID convention and policies.
console/tracker-client/src/console/clients/udp/checker.rs Uses the production default peer ID when none is provided.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/tracker-client/src/peer_id.rs Outdated
Comment thread packages/tracker-client/src/peer_id.rs Outdated
Comment thread packages/tracker-client/src/peer_id.rs
…onvention

Address Copilot PR review suggestions on torrust#1761:

- Fix doc comments in `peer_id.rs`: 'random-12-bytes' and '12-byte suffix'
  changed to '12-digit' to match the actual ASCII decimal implementation.
- Fix ADR layout field: '12-byte-suffix' changed to '12-digit-suffix'.
- Replace `.expect()` panic in `random_suffix_12_digits()` with
  `.unwrap_or_default()` so a misconfigured system clock (before UNIX_EPOCH)
  falls back to 0 nanoseconds rather than crashing the process.
@josecelano
Copy link
Copy Markdown
Member Author

ACK 49b1e5a

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.44%. Comparing base (5473ef3) to head (49b1e5a).

Files with missing lines Patch % Lines
.../tracker-client/src/console/clients/udp/checker.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1761   +/-   ##
========================================
  Coverage    79.44%   79.44%           
========================================
  Files          368      369    +1     
  Lines        27302    27328   +26     
  Branches     27302    27328   +26     
========================================
+ Hits         21689    21711   +22     
- Misses        5333     5337    +4     
  Partials       280      280           

☔ View full report in Codecov by Sentry.
📢 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.

@josecelano josecelano merged commit 7561d58 into torrust:develop May 12, 2026
18 checks passed
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.

2 participants