torrust-tracker
torrust-tracker copied to clipboard
HTTP Tracker client: Add optional parameters with the rest of the announce params
Parent issue: https://github.com/torrust/torrust-tracker/issues/669 Relates to: https://github.com/torrust/torrust-tracker/issues/1533
Sometimes, when I'm testing, I have to simulate that a peer has completed downloading, as in this PR.
The process is pretty tedious because the client does not accept the event as an argument, so I have to make the request, change the hardcoded event, recompile it, and execute it again.
It would be nice to add a parameter.
How to do it now
- Change the default event from
CompletedtoStarted
In bittorrent_tracker_client::http::client::requests::announce::QueryBuilder
impl QueryBuilder {
/// # Panics
///
/// Will panic if the default info-hash value is not a valid info-hash.
#[must_use]
pub fn with_default_values() -> QueryBuilder {
let default_announce_query = Query {
info_hash: InfoHash::from_str("9c38422213e30bff212b30c360d26f9a02136422").unwrap().0, // DevSkim: ignore DS173237
peer_addr: IpAddr::V4(Ipv4Addr::new(192, 168, 1, 88)),
downloaded: 0,
uploaded: 0,
peer_id: PeerId(*b"-qB00000000000000001").0,
port: 17548,
left: 0,
event: Some(Event::Completed), // <- this
compact: Some(Compact::NotAccepted),
};
Self {
announce_query: default_announce_query,
}
}
}
- Run the client
cargo run -p torrust-tracker-client --bin http_tracker_client announce http://127.0.0.1:7070 443c7602b4fde83d1154d6d9da48808418b181b6 | jq
- Change the default event from
StartedtoCompleted
And rerun the client.
The downloads counter does not increase if the peer does not transition from Started to Completed
Proposal
Add an option parameter to pass the event (and other params):
cargo run -p torrust-tracker-client --bin http_tracker_client announce \
http://127.0.0.1:7070 443c7602b4fde83d1154d6d9da48808418b181b6 \
--event completed --uploaded 1234 --left 5678