Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axum HTTP tracker: basic scaffolding #180

Conversation

josecelano
Copy link
Member

@josecelano josecelano commented Feb 9, 2023

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:

  • Running full Warp implementation in production while enabling new implementation.
  • Running both implementations for testing while implementing the new Axum version.

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:

pub async fn announce_handler(
    State(_tracker): State<Arc<Tracker>>,
    ExtractAnnounceParams(_announce_params): ExtractAnnounceParams,
) -> Json<Ok> {
    todo!()
}

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.

We are going to migrate the HTTP tracker from Warp to Axum.
This is the basic scaffolding for Axum. Tests have been duplicated to
test the new Axum implementation. The setup allows executing both
versions: the Warp version on production and both versions (Warp and
Axum) on testing env.
…params from url query

WIP: only for mandatory params.
…tracker implementations

We are going to start sharing code bettween both implementation (Warp
and Axum). We need to keep common code separated because Warp
implementation will be removed when Axum implementation is finished.
@da2ce7
Copy link
Contributor

da2ce7 commented Feb 9, 2023

ACK 995397e

@josecelano josecelano merged commit 8e85f18 into torrust:develop Feb 9, 2023
@josecelano josecelano deleted the issue-160-http-tracker-with-axum-scaffolding branch February 9, 2023 13:45
Copy link
Contributor

@da2ce7 da2ce7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

@josecelano josecelano changed the title Basic scaffolding for Axum HTTP tracker implementation Axum HTTP tracker: basic scaffolding Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants