HTTP Tracker client: Print unrecognized responses in JSON #672
Labels
- Admin -
Enjoyable to Install and Setup our Software
- Developer -
Torrust Improvement Experience
Code Cleanup / Refactoring
Tidying and Making Neat
Easy
Good for Newcomers
Enhancement / Feature Request
Something New
good first issue
Good for newcomers
Testing
Checking Torrust
Milestone
Parent issue: #669
Depends on: #673
Not all tracker responses are always the same for the same request. Some trackers can include only mandatory fields. The example below is a wrong response because the scrape request should include the
downloaded
field. However, there could be other cases when the tracker response is valid but is not exactly the same response as in the Torrust Tracker. If we want to support other trackers we should be flexible with valid responses that don't match our resposnses.Announce Request
When you run the HTTP tracker client with a Torrust Tracker:
cargo run --bin http_tracker_client announce http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422
you receive a response like this:
Scrape Request
When you run the HTTP tracker client with a Torrust Tracker:
cargo run --bin http_tracker_client scrape http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422
you receive a response like this:
Compatibility Problem
Alternative Tracker request:
http://open.acgnxtracker.com/scrape?info_hash=%44%3C%76%02%B4%FD%E8%3D%11%54%D6%D9%DA%48%80%84%18%B1%81%B6
Alternative Tracker response:
scrape.zip
Torrust Tracker request:
https://tracker.torrust-demo.com/scrape?info_hash=%44%3C%76%02%B4%FD%E8%3D%11%54%D6%D9%DA%48%80%84%18%B1%81%B6
Torrust Tracker response:
scrape-torrust.zip
NOTICE: the alternative tracker does not include the
downloaded
attribute.In these cases, the client should print the JSON response anyway. But we need a generic serialisation from Becnode to JSON.
Implementation
The implementation requires changing these functions:
We first try to deserialize the encoded response into our data structures:
If that operation fails, then we try to serialize to a generic json.
You can get a list of HTTP trackers from https://newtrackon.com/. The client should print all the responses from all those trackers.
The text was updated successfully, but these errors were encountered: