Skip to content

feat(tracker-client): add optional announce parameters to UDP tracker client#1738

Merged
josecelano merged 9 commits into
torrust:developfrom
josecelano:1533-udp-tracker-client-add-optional-announce-params
May 7, 2026
Merged

feat(tracker-client): add optional announce parameters to UDP tracker client#1738
josecelano merged 9 commits into
torrust:developfrom
josecelano:1533-udp-tracker-client-add-optional-announce-params

Conversation

@josecelano

@josecelano josecelano commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

  • add optional announce flags to udp_tracker_client: --event, --uploaded, --downloaded, --left, --port, --ip-address, --peer-id, --key, --peers-wanted
  • thread optional values from CLI through handle_announce into send_announce_request
  • add CliAnnounceEvent (clap::ValueEnum) and map it to protocol AnnounceEvent
  • keep defaults unchanged when flags are omitted
  • add peer-id length validation (20 bytes) and explicit manual verification docs
  • add repo docs for deferred JSON/stdin request-input proposal

Feature Example

Command:

cargo run -p torrust-tracker-client --bin udp_tracker_client announce \
  127.0.0.1:6969 443c7602b4fde83d1154d6d9da48808418b181b6 \
  --event completed \
  --uploaded 1234 \
  --downloaded 5678 \
  --left 0 \
  --port 6881 \
  --ip-address 10.0.0.1 \
  '--peer-id=-RC00000000000000001' \
  --key 42 \
  --peers-wanted 50

Example output:

{
  "AnnounceIpv4": {
    "transaction_id": -888840697,
    "announce_interval": 120,
    "leechers": 0,
    "seeders": 1,
    "peers": []
  }
}

Validation

Related

josecelano added 6 commits May 7, 2026 16:32
… client

Add optional CLI flags to the UDP tracker client's announce command:
- --event (none|completed|started|stopped)
- --uploaded (bytes)
- --downloaded (bytes)
- --left (bytes)
- --port (number)
- --ip-address (IPv4)
- --peer-id (20 bytes)
- --key (integer)
- --peers-wanted (integer)

When flags are omitted, hard-coded defaults are preserved (backward compatible).

Implementation:
- Add CliAnnounceEvent wrapper enum for clap parsing (ValueEnum)
- Add AnnounceParams struct to thread optional values through layers
- Update send_announce_request() to accept and apply parameter overrides
- Add parse_peer_id() validator for 20-byte requirement
- Thread params from CLI through handle_announce() to client
- Update module doc with extended usage examples

Validation:
- Uploaded/downloaded/left typed as u64 (clap rejects negatives)
- Peer-id validated as exactly 20 bytes at CLI layer
- Event values validated against enum

Fixes torrust#1533
@josecelano josecelano requested a review from a team as a code owner May 7, 2026 15:52
@josecelano josecelano self-assigned this May 7, 2026
@josecelano josecelano requested a review from Copilot May 7, 2026 15:52

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

This PR extends the UDP tracker client CLI so developers can override announce request fields (event and other announce parameters) without recompiling, while keeping existing defaults when flags are omitted.

Changes:

  • Add optional announce CLI flags (event/uploaded/downloaded/left/port/ip/peer-id/key/peers-wanted) and thread them into the UDP announce request builder.
  • Introduce a CLI-only CliAnnounceEvent (clap::ValueEnum) mapped to the protocol AnnounceEvent, plus peer-id length (20 bytes) validation.
  • Add/update supporting documentation (manual verification steps, deferred JSON-input proposal, and a “run tracker locally” skill), and update the project word list.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
project-words.txt Adds spellchecker allow-list entries for new docs/terms.
docs/issues/1533-udp-tracker-client-add-optional-announce-params.md Marks goals as completed and adds a manual verification section for UDP announce params.
docs/issues/1532-http-tracker-client-add-optional-announce-params.md Adds a manual verification test plan section for the HTTP client (future work).
console/tracker-client/src/console/clients/udp/checker.rs Adds AnnounceParams and applies optional overrides when building UDP announce requests.
console/tracker-client/src/console/clients/udp/app.rs Extends UDP client CLI parsing to accept optional announce params and validates peer-id length.
console/tracker-client/src/console/clients/checker/checks/udp.rs Updates checker to call the new announce API with default params.
console/tracker-client/docs/features/json-request-input/README.md Adds deferred proposal doc for JSON/file/stdin request input mode.
.github/skills/dev/environment-setup/run-tracker-locally/SKILL.md Adds a skill doc describing how to run and verify the tracker locally.

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

Comment thread project-words.txt Outdated
Comment thread console/tracker-client/src/console/clients/udp/app.rs Outdated
Comment thread console/tracker-client/src/console/clients/udp/checker.rs Outdated
Comment thread console/tracker-client/src/console/clients/udp/checker.rs
Comment thread console/tracker-client/src/console/clients/udp/checker.rs Outdated
@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.58%. Comparing base (ed3e156) to head (e8d5edd).
⚠️ Report is 10 commits behind head on develop.

Files with missing lines Patch % Lines
...sole/tracker-client/src/console/clients/udp/app.rs 0.00% 19 Missing ⚠️
.../tracker-client/src/console/clients/udp/checker.rs 0.00% 12 Missing ⚠️
...r-client/src/console/clients/checker/checks/udp.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1738      +/-   ##
===========================================
- Coverage    79.63%   79.58%   -0.06%     
===========================================
  Files          368      368              
  Lines        27057    27078      +21     
  Branches     27057    27078      +21     
===========================================
+ Hits         21548    21549       +1     
- Misses        5227     5248      +21     
+ Partials       282      281       -1     

☔ 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

Copy link
Copy Markdown
Member Author

ACK e8d5edd

@josecelano josecelano merged commit 2712b75 into torrust:develop May 7, 2026
21 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.

UDP Tracker client: Add optional parameters with the rest of the announce params

2 participants