Axum HTTP tracker: basic scaffolding #180
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the first of a series of PR associated with the issue #160
We are changing the HTTP tracker to use Axum instead of Warp. This PR allows:
It also allows parsing the URL query params for the announce query. For the time being, only the mandatory params.
The announce request URL has two parameters that contain binary data (20 bytes).
Sample Announce URL:
http://0.0.0.0:7070/announce?info_hash=%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0&peer_id=-qB00000000000000001&port=17548
The "infohash" and "peer id" cannot be extracted using the generic Axum
Query
extractor because it cannot parse binary data. As you can read here.I could have used the RawQuery extractor, but I thought this way would be much cleaner because you can pass the
AnnounceParams
into the handler like this:And you can also handle the errors in the extractor if you have to return a "bad request" response. Alternatively, I could have handled parsing and error handling inside the handler.