Skip to content

feat(tracker-client): add optional announce params to HTTP client#1739

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1532-http-tracker-client-add-optional-announce-params
May 7, 2026
Merged

feat(tracker-client): add optional announce params to HTTP client#1739
josecelano merged 3 commits into
torrust:developfrom
josecelano:1532-http-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 http_tracker_client: --event, --uploaded, --downloaded, --left, --port, --peer-addr, --peer-id, --compact
  • thread optional CLI values into the HTTP announce query builder while preserving existing defaults
  • add CLI-facing enums for announce event and compact mode
  • add missing QueryBuilder setters for event, uploaded, downloaded, left, and port
  • support both dictionary and compact announce response decoding when compact=1 is used
  • update the issue spec with manual verification results and implementation learnings
  • reject --port 0 with a clear CLI validation error after manual edge-case testing exposed the gap

Feature Example

Command:

cargo run -p torrust-tracker-client --bin http_tracker_client announce \
  http://127.0.0.1:7070 2222222222222222222222222222222222222222 \
  --event completed \
  --uploaded 1000 \
  --downloaded 1000 \
  --left 0 \
  --port 6881 \
  --peer-addr 10.0.0.1 \
  '--peer-id=-RC00000000000000001' \
  --compact 1

Observed output:

{"complete":1,"incomplete":0,"interval":120,"min interval":120,"peers":[]}

Observed follow-up verification:

  • scrape changed from {"complete":0,"downloaded":0,"incomplete":1} to {"complete":1,"downloaded":1,"incomplete":0}
  • global stats changed from seeders=0, completed=1, leechers=1 to seeders=1, completed=2, leechers=0

Edge-Case Checks

  • invalid peer-id length fails with peer-id must be exactly 20 bytes
  • invalid event fails and lists the allowed values: started, stopped, completed
  • invalid compact fails and lists the allowed values: 0, 1
  • invalid peer-addr fails with invalid IP address syntax
  • --port 0 now fails with port must be greater than zero
  • dash-prefixed peer IDs require the documented --peer-id=-RC... form to avoid clap parsing -R as another flag

Validation

  • cargo test -p torrust-tracker-client passes
  • cargo machete passes
  • linter all passes
  • manual started -> completed HTTP verification completed against local tracker
  • manual negative-path verification completed for peer-id, event, compact, peer-addr, and zero port

Related

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 HTTP tracker client’s announce command to accept optional announce parameters (event/counters/peer identity/compact mode) and threads them into the HTTP announce query builder while keeping existing defaults. It also updates response handling to decode both dictionary and compact announce responses, and documents manual verification and learnings for issue #1532.

Changes:

  • Add missing QueryBuilder setters for event, uploaded, downloaded, left, and port.
  • Extend the HTTP tracker client CLI to accept optional announce flags (including CLI-facing enums for event and compact) and apply them to the query.
  • Support decoding both dictionary and compact announce responses, and update the issue spec with verification notes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/tracker-client/src/http/client/requests/announce.rs Adds additional QueryBuilder setters for optional announce parameters.
console/tracker-client/src/console/clients/http/app.rs Adds optional CLI flags for announce, maps them into the request builder, and decodes compact vs dictionary responses.
docs/issues/1532-http-tracker-client-add-optional-announce-params.md Updates the issue spec with completed checklist items, corrected examples, and manual verification/learnings.

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

Comment thread console/tracker-client/src/console/clients/http/app.rs
@josecelano

Copy link
Copy Markdown
Member Author

ACK 40e9b65

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.45%. Comparing base (2712b75) to head (40e9b65).

Files with missing lines Patch % Lines
...racker-client/src/http/client/requests/announce.rs 0.00% 20 Missing ⚠️
...ole/tracker-client/src/console/clients/http/app.rs 0.00% 19 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1739      +/-   ##
===========================================
- Coverage    79.57%   79.45%   -0.13%     
===========================================
  Files          368      368              
  Lines        27078    27117      +39     
  Branches     27078    27117      +39     
===========================================
- Hits         21548    21546       -2     
- Misses        5248     5290      +42     
+ 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 josecelano merged commit 20fca49 into torrust:develop May 7, 2026
27 of 29 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.

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

2 participants