Skip to content

Commit c9638f3

Browse files
committed
Merge torrust#1175: Udpate dependencies
76329d7 chore: fix format (Jose Celano) ce12fe7 test: fix test should_fail_getting_torrents_when_the_offset_query_parameter_cannot_be_parsed (Jose Celano) cb40687 test: should_fail_getting_torrents_when_the_limit_query_parameter_cannot_be_parsed (Jose Celano) f4a7399 test: fix should_fail_generating_a_new_auth_key_when_the_key_duration_is_invalid (Jose Celano) bfab30f fix: update axum routes captures (Jose Celano) 366ef1c fix: lifetime parameters on function `from_request_parts` do not match the trait (Jose Celano) 3337948 chore(deps): udpate dependencies (Jose Celano) Pull request description: ```output cargo update Updating crates.io index Locking 26 packages to latest compatible versions Removing async-trait v0.1.83 Updating axum v0.7.9 -> v0.8.1 Updating axum-client-ip v0.6.1 -> v0.7.0 Updating axum-core v0.4.5 -> v0.5.0 Updating axum-extra v0.9.6 -> v0.10.0 Updating axum-macros v0.4.2 -> v0.5.0 Updating btoi v0.4.3 -> v0.4.4 Updating cc v1.2.6 -> v1.2.7 Updating glob v0.3.1 -> v0.3.2 Updating matchit v0.7.3 -> v0.8.4 (available: v0.8.6) Removing multer v3.1.0 Updating phf v0.11.2 -> v0.11.3 Updating phf_codegen v0.11.2 -> v0.11.3 Updating phf_generator v0.11.2 -> v0.11.3 Updating phf_shared v0.11.2 -> v0.11.3 Updating pin-project v1.1.7 -> v1.1.8 Updating pin-project-internal v1.1.7 -> v1.1.8 Updating pin-project-lite v0.2.15 -> v0.2.16 Updating reqwest v0.12.10 -> v0.12.12 Updating rstest v0.23.0 -> v0.24.0 Updating rstest_macros v0.23.0 -> v0.24.0 Updating serde v1.0.216 -> v1.0.217 Updating serde_derive v1.0.216 -> v1.0.217 Updating serde_json v1.0.134 -> v1.0.135 Updating siphasher v0.3.11 -> v1.0.1 Updating syn v2.0.92 -> v2.0.95 Updating tempfile v3.14.0 -> v3.15.0 Updating winnow v0.6.20 -> v0.6.22 ``` Some fixes were needed after updating Axum. For example, The `:` and `*` are now prohibited in routes to define segment variables: ``` let app = Router::<()>::new() .without_v07_checks() .route("/:colon", get(|| async {})) .route("/*asterisk", get(|| async {})); ``` You have to use `{variable}`: ``` let app = Router::<()>::new() .without_v07_checks() .route("/{apture}", get(|| async {})); ``` https://docs.rs/axum/latest/axum/routing/struct.Router.html#method.without_v07_checks ACKs for top commit: josecelano: ACK 76329d7 Tree-SHA512: 8885be12db9c71d35ebd09926285ca7ae0e4f20580e7652c7af430169d34ebee28ab9808c909664d8ed65be4294300ad4991c848868c9a9ae57c2556c985add0
2 parents dd8fecc + 76329d7 commit c9638f3

File tree

11 files changed

+123
-181
lines changed

11 files changed

+123
-181
lines changed

Cargo.lock

+93-121
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/servers/apis/v1/context/auth_key/routes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn add(prefix: &str, router: Router, tracker: Arc<Tracker>) -> Router {
2727
//
2828
// The POST /key/:seconds_valid has been deprecated and it will removed in the future.
2929
// Use POST /keys
30-
&format!("{prefix}/key/:seconds_valid_or_key"),
30+
&format!("{prefix}/key/{{seconds_valid_or_key}}"),
3131
post(generate_auth_key_handler)
3232
.with_state(tracker.clone())
3333
.delete(delete_auth_key_handler)

src/servers/apis/v1/context/torrent/routes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn add(prefix: &str, router: Router, tracker: Arc<Tracker>) -> Router {
1717
// Torrents
1818
router
1919
.route(
20-
&format!("{prefix}/torrent/:info_hash"),
20+
&format!("{prefix}/torrent/{{info_hash}}"),
2121
get(get_torrent_handler).with_state(tracker.clone()),
2222
)
2323
.route(&format!("{prefix}/torrents"), get(get_torrents_handler).with_state(tracker))

src/servers/apis/v1/context/whitelist/routes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ pub fn add(prefix: &str, router: Router, tracker: Arc<Tracker>) -> Router {
2020
router
2121
// Whitelisted torrents
2222
.route(
23-
&format!("{prefix}/:info_hash"),
23+
&format!("{prefix}/{{info_hash}}"),
2424
post(add_torrent_to_whitelist_handler).with_state(tracker.clone()),
2525
)
2626
.route(
27-
&format!("{prefix}/:info_hash"),
27+
&format!("{prefix}/{{info_hash}}"),
2828
delete(remove_torrent_from_whitelist_handler).with_state(tracker.clone()),
2929
)
3030
// Whitelist commands

src/servers/http/v1/extractors/announce_request.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
//! ```text
2828
//! d14:failure reason240:Bad request. Cannot parse query params for announce request: invalid param value invalid for info_hash in not enough bytes for infohash: got 7 bytes, expected 20 src/shared/bit_torrent/info_hash.rs:240:27, src/servers/http/v1/requests/announce.rs:182:42e
2929
//! ```
30+
use std::future::Future;
3031
use std::panic::Location;
3132

3233
use axum::extract::FromRequestParts;
3334
use axum::http::request::Parts;
3435
use axum::response::{IntoResponse, Response};
35-
use futures::future::BoxFuture;
3636
use futures::FutureExt;
3737

3838
use crate::servers::http::v1::query::Query;
@@ -49,16 +49,7 @@ where
4949
{
5050
type Rejection = Response;
5151

52-
#[must_use]
53-
fn from_request_parts<'life0, 'life1, 'async_trait>(
54-
parts: &'life0 mut Parts,
55-
_state: &'life1 S,
56-
) -> BoxFuture<'async_trait, Result<Self, Self::Rejection>>
57-
where
58-
'life0: 'async_trait,
59-
'life1: 'async_trait,
60-
Self: 'async_trait,
61-
{
52+
fn from_request_parts(parts: &mut Parts, _state: &S) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
6253
async {
6354
match extract_announce_from(parts.uri.query()) {
6455
Ok(announce_request) => Ok(ExtractRequest(announce_request)),

src/servers/http/v1/extractors/authentication_key.rs

+5-15
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@
4242
//! > Neither [The `BitTorrent` Protocol Specification](https://www.bittorrent.org/beps/bep_0003.html)
4343
//! > nor [The Private Torrents](https://www.bittorrent.org/beps/bep_0027.html)
4444
//! > specifications specify any HTTP status code for authentication errors.
45+
use std::future::Future;
4546
use std::panic::Location;
4647

4748
use axum::extract::rejection::PathRejection;
4849
use axum::extract::{FromRequestParts, Path};
4950
use axum::http::request::Parts;
5051
use axum::response::{IntoResponse, Response};
51-
use futures::future::BoxFuture;
52-
use futures::FutureExt;
5352
use serde::Deserialize;
5453

5554
use crate::core::auth::Key;
@@ -71,21 +70,13 @@ impl KeyParam {
7170

7271
impl<S> FromRequestParts<S> for Extract
7372
where
74-
S: Send + Sync,
73+
S: Send + Sync + 'static,
7574
{
7675
type Rejection = Response;
7776

78-
#[must_use]
79-
fn from_request_parts<'life0, 'life1, 'async_trait>(
80-
parts: &'life0 mut Parts,
81-
state: &'life1 S,
82-
) -> BoxFuture<'async_trait, Result<Self, Self::Rejection>>
83-
where
84-
'life0: 'async_trait,
85-
'life1: 'async_trait,
86-
Self: 'async_trait,
87-
{
88-
async {
77+
#[allow(clippy::manual_async_fn)]
78+
fn from_request_parts(parts: &mut Parts, state: &S) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
79+
async move {
8980
// Extract `key` from URL path with Axum `Path` extractor
9081
let maybe_path_with_key = Path::<KeyParam>::from_request_parts(parts, state).await;
9182

@@ -94,7 +85,6 @@ where
9485
Err(error) => Err(error.into_response()),
9586
}
9687
}
97-
.boxed()
9888
}
9989
}
10090

src/servers/http/v1/extractors/client_ip_sources.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@
3535
//! `right_most_x_forwarded_for` = 126.0.0.2
3636
//! `connection_info_ip` = 126.0.0.3
3737
//! ```
38+
use std::future::Future;
3839
use std::net::SocketAddr;
3940

4041
use axum::extract::{ConnectInfo, FromRequestParts};
4142
use axum::http::request::Parts;
4243
use axum::response::Response;
4344
use axum_client_ip::RightmostXForwardedFor;
44-
use futures::future::BoxFuture;
45-
use futures::FutureExt;
4645

4746
use crate::servers::http::v1::services::peer_ip_resolver::ClientIpSources;
4847

@@ -56,17 +55,9 @@ where
5655
{
5756
type Rejection = Response;
5857

59-
#[must_use]
60-
fn from_request_parts<'life0, 'life1, 'async_trait>(
61-
parts: &'life0 mut Parts,
62-
state: &'life1 S,
63-
) -> BoxFuture<'async_trait, Result<Self, Self::Rejection>>
64-
where
65-
'life0: 'async_trait,
66-
'life1: 'async_trait,
67-
Self: 'async_trait,
68-
{
69-
async {
58+
#[allow(clippy::manual_async_fn)]
59+
fn from_request_parts(parts: &mut Parts, state: &S) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
60+
async move {
7061
let right_most_x_forwarded_for = match RightmostXForwardedFor::from_request_parts(parts, state).await {
7162
Ok(right_most_x_forwarded_for) => Some(right_most_x_forwarded_for.0),
7263
Err(_) => None,
@@ -82,6 +73,5 @@ where
8273
connection_info_ip,
8374
}))
8475
}
85-
.boxed()
8676
}
8777
}

src/servers/http/v1/extractors/scrape_request.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
//! ```text
2828
//! d14:failure reason235:Bad request. Cannot parse query params for scrape request: invalid param value invalid for info_hash in not enough bytes for infohash: got 7 bytes, expected 20 src/shared/bit_torrent/info_hash.rs:240:27, src/servers/http/v1/requests/scrape.rs:66:46e
2929
//! ```
30+
use std::future::Future;
3031
use std::panic::Location;
3132

3233
use axum::extract::FromRequestParts;
3334
use axum::http::request::Parts;
3435
use axum::response::{IntoResponse, Response};
35-
use futures::future::BoxFuture;
3636
use futures::FutureExt;
3737

3838
use crate::servers::http::v1::query::Query;
@@ -49,16 +49,7 @@ where
4949
{
5050
type Rejection = Response;
5151

52-
#[must_use]
53-
fn from_request_parts<'life0, 'life1, 'async_trait>(
54-
parts: &'life0 mut Parts,
55-
_state: &'life1 S,
56-
) -> BoxFuture<'async_trait, Result<Self, Self::Rejection>>
57-
where
58-
'life0: 'async_trait,
59-
'life1: 'async_trait,
60-
Self: 'async_trait,
61-
{
52+
fn from_request_parts(parts: &mut Parts, _state: &S) -> impl Future<Output = Result<Self, Self::Rejection>> + Send {
6253
async {
6354
match extract_scrape_from(parts.uri.query()) {
6455
Ok(scrape_request) => Ok(ExtractRequest(scrape_request)),

src/servers/http/v1/routes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ pub fn router(tracker: Arc<Tracker>, server_socket_addr: SocketAddr) -> Router {
3838
.route("/health_check", get(health_check::handler))
3939
// Announce request
4040
.route("/announce", get(announce::handle_without_key).with_state(tracker.clone()))
41-
.route("/announce/:key", get(announce::handle_with_key).with_state(tracker.clone()))
41+
.route("/announce/{key}", get(announce::handle_with_key).with_state(tracker.clone()))
4242
// Scrape request
4343
.route("/scrape", get(scrape::handle_without_key).with_state(tracker.clone()))
44-
.route("/scrape/:key", get(scrape::handle_with_key).with_state(tracker))
44+
.route("/scrape/{key}", get(scrape::handle_with_key).with_state(tracker))
4545
// Add extension to get the client IP from the connection info
4646
.layer(SecureClientIpSource::ConnectInfo.into_extension())
4747
.layer(CompressionLayer::new())

tests/servers/api/v1/asserts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub async fn assert_unprocessable_auth_key_duration_param(response: Response, _i
117117
pub async fn assert_invalid_key_duration_param(response: Response, invalid_key_duration: &str) {
118118
assert_bad_request(
119119
response,
120-
&format!("Invalid URL: Cannot parse `\"{invalid_key_duration}\"` to a `u64`"),
120+
&format!("Invalid URL: Cannot parse `{invalid_key_duration}` to a `u64`"),
121121
)
122122
.await;
123123
}

tests/servers/api/v1/contract/context/torrent.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ async fn should_fail_getting_torrents_when_the_offset_query_parameter_cannot_be_
189189
)
190190
.await;
191191

192-
assert_bad_request(response, "Failed to deserialize query string: invalid digit found in string").await;
192+
assert_bad_request(
193+
response,
194+
"Failed to deserialize query string: offset: invalid digit found in string",
195+
)
196+
.await;
193197
}
194198

195199
env.stop().await;
@@ -213,7 +217,11 @@ async fn should_fail_getting_torrents_when_the_limit_query_parameter_cannot_be_p
213217
)
214218
.await;
215219

216-
assert_bad_request(response, "Failed to deserialize query string: invalid digit found in string").await;
220+
assert_bad_request(
221+
response,
222+
"Failed to deserialize query string: limit: invalid digit found in string",
223+
)
224+
.await;
217225
}
218226

219227
env.stop().await;

0 commit comments

Comments
 (0)