Skip to content

Commit ec92a4c

Browse files
committedJan 30, 2025
Merge torrust#1227: Udpate dependencies
9fa7b61 fix: clippy errors on nightly (Jose Celano) 8bb376d chore(deps): udpate dependencies (Jose Celano) Pull request description: ``` cargo update Updating crates.io index Locking 22 packages to latest compatible versions Updating bumpalo v3.16.0 -> v3.17.0 Updating cmake v0.1.52 -> v0.1.53 Updating cpufeatures v0.2.16 -> v0.2.17 Adding getrandom v0.3.1 Updating httparse v1.9.5 -> v1.10.0 Updating hyper v1.5.2 -> v1.6.0 Updating native-tls v0.2.12 -> v0.2.13 Updating openssl v0.10.68 -> v0.10.69 Updating openssl-probe v0.1.5 -> v0.1.6 Adding rand v0.9.0 Adding rand_chacha v0.9.0 Adding rand_core v0.9.0 Updating rustls-pki-types v1.10.1 -> v1.11.0 Updating ryu v1.0.18 -> v1.0.19 Updating serde_json v1.0.137 -> v1.0.138 Updating tempfile v3.15.0 -> v3.16.0 Updating unicode-ident v1.0.14 -> v1.0.16 Adding wasi v0.13.3+wasi-0.2.2 Updating winnow v0.6.24 -> v0.6.25 Adding wit-bindgen-rt v0.33.0 Adding zerocopy v0.8.14 Adding zerocopy-derive v0.8.14 ``` Top commit has no ACKs. Tree-SHA512: 0a3f8554a78e37bcf651d4ebc0074eb92ff2d95954988e3a1ea52c8e36e2aa87f89b868b848da44b0d3026b41cca46190dbce14982ec82f718e613830da62fc4
2 parents 4447c6a + 9fa7b61 commit ec92a4c

File tree

18 files changed

+178
-106
lines changed

18 files changed

+178
-106
lines changed
 

‎Cargo.lock

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

‎contrib/bencode/src/mutable/bencode_mut.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ impl<'a> BRefAccess for BencodeMut<'a> {
8282
fn str(&self) -> Option<&str> {
8383
let bytes = self.bytes()?;
8484

85-
match str::from_utf8(bytes) {
86-
Ok(n) => Some(n),
87-
Err(_) => None,
88-
}
85+
str::from_utf8(bytes).ok()
8986
}
9087

9188
fn int(&self) -> Option<i64> {

‎contrib/bencode/src/reference/bencode_ref.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ impl<'a> BRefAccessExt<'a> for BencodeRef<'a> {
107107
fn str_ext(&self) -> Option<&'a str> {
108108
let bytes = self.bytes_ext()?;
109109

110-
match str::from_utf8(bytes) {
111-
Ok(n) => Some(n),
112-
Err(_) => None,
113-
}
110+
str::from_utf8(bytes).ok()
114111
}
115112

116113
fn bytes_ext(&self) -> Option<&'a [u8]> {

‎contrib/bencode/src/reference/decode.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ fn decode_dict(
129129
})
130130
}
131131
_ => (),
132-
};
132+
}
133+
133134
curr_pos = next_pos;
134135

135136
let (value, next_pos) = decode(bytes, curr_pos, opts, depth + 1)?;

‎packages/test-helpers/src/configuration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn ephemeral_ipv6() -> Configuration {
153153

154154
if let Some(ref mut http_api) = cfg.http_api {
155155
http_api.bind_address.clone_from(&ipv6);
156-
};
156+
}
157157

158158
if let Some(ref mut http_trackers) = cfg.http_trackers {
159159
http_trackers[0].bind_address.clone_from(&ipv6);

‎packages/test-helpers/src/random.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Random data generators for testing.
2-
use rand::distributions::Alphanumeric;
3-
use rand::{thread_rng, Rng};
2+
use rand::distr::Alphanumeric;
3+
use rand::{rng, Rng};
44

55
/// Returns a random alphanumeric string of a certain size.
66
///
77
/// It is useful for generating random names, IDs, etc for testing.
88
pub fn string(size: usize) -> String {
9-
thread_rng().sample_iter(&Alphanumeric).take(size).map(char::from).collect()
9+
rng().sample_iter(&Alphanumeric).take(size).map(char::from).collect()
1010
}

‎packages/torrent-repository/tests/common/repo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl Repo {
232232
Repo::DashMapMutexStd(repo) => {
233233
repo.torrents.insert(*info_hash, torrent.into());
234234
}
235-
};
235+
}
236236
self.get(info_hash).await
237237
}
238238
}

‎packages/tracker-api-client/src/v1/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Client {
6767

6868
if let Some(token) = &self.connection_info.api_token {
6969
query.add_param(QueryParam::new("token", token));
70-
};
70+
}
7171

7272
self.get_request_with_query(path, query, headers).await
7373
}

‎packages/tracker-client/src/udp/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub async fn check(remote_addr: &SocketAddr) -> Result<String, String> {
243243
match client.send(connect_request.into()).await {
244244
Ok(_) => (),
245245
Err(e) => tracing::debug!("Error: {e:?}."),
246-
};
246+
}
247247

248248
let process = move |response| {
249249
if matches!(response, Response::Connect(_connect_response)) {

‎packages/tracker-core/src/authentication/key/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ use std::sync::Arc;
4545
use std::time::Duration;
4646

4747
use derive_more::Display;
48-
use rand::distributions::Alphanumeric;
49-
use rand::{thread_rng, Rng};
48+
use rand::distr::Alphanumeric;
49+
use rand::{rng, Rng};
5050
use serde::{Deserialize, Serialize};
5151
use thiserror::Error;
5252
use torrust_tracker_clock::clock::Time;
@@ -81,7 +81,7 @@ pub fn generate_permanent_key() -> PeerKey {
8181
/// * `lifetime`: if `None` the key will be permanent.
8282
#[must_use]
8383
pub fn generate_key(lifetime: Option<Duration>) -> PeerKey {
84-
let random_id: String = thread_rng()
84+
let random_id: String = rng()
8585
.sample_iter(&Alphanumeric)
8686
.take(AUTH_KEY_LENGTH)
8787
.map(char::from)

‎src/app.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub async fn start(config: &Configuration, app_container: &Arc<AppContainer>) ->
9898
http_tracker::start_job(http_tracker_container, registar.give_form(), servers::http::Version::V1).await
9999
{
100100
jobs.push(job);
101-
};
101+
}
102102
}
103103
} else {
104104
tracing::info!("No HTTP blocks in configuration");
@@ -111,7 +111,7 @@ pub async fn start(config: &Configuration, app_container: &Arc<AppContainer>) ->
111111

112112
if let Some(job) = tracker_apis::start_job(http_api_container, registar.give_form(), servers::apis::Version::V1).await {
113113
jobs.push(job);
114-
};
114+
}
115115
} else {
116116
tracing::info!("No API block in configuration");
117117
}

‎src/console/ci/e2e/logs_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl RunningServices {
7676

7777
if !line.contains(INFO_THRESHOLD) {
7878
continue;
79-
};
79+
}
8080

8181
if line.contains(UDP_TRACKER_LOG_TARGET) {
8282
if let Some(captures) = udp_re.captures(&clean_line) {

‎src/console/ci/e2e/tracker_container.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::Duration;
22

3-
use rand::distributions::Alphanumeric;
3+
use rand::distr::Alphanumeric;
44
use rand::Rng;
55

66
use super::docker::{RunOptions, RunningContainer};
@@ -113,11 +113,7 @@ impl TrackerContainer {
113113
}
114114

115115
fn generate_random_container_name(prefix: &str) -> String {
116-
let rand_string: String = rand::thread_rng()
117-
.sample_iter(&Alphanumeric)
118-
.take(20)
119-
.map(char::from)
120-
.collect();
116+
let rand_string: String = rand::rng().sample_iter(&Alphanumeric).take(20).map(char::from).collect();
121117

122118
format!("{prefix}{rand_string}")
123119
}

‎src/servers/apis/v1/context/auth_key/handlers.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use crate::servers::apis::v1::responses::{invalid_auth_key_param_response, ok_re
2222
/// It returns these types of responses:
2323
///
2424
/// - `200` with a json [`AuthKey`]
25-
/// resource. If the key was generated successfully.
25+
/// resource. If the key was generated successfully.
2626
/// - `400` with an error if the key couldn't been added because of an invalid
27-
/// request.
27+
/// request.
2828
/// - `500` with serialized error in debug format. If the key couldn't be
29-
/// generated.
29+
/// generated.
3030
///
3131
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#generate-a-new-authentication-key)
3232
/// for more information about this endpoint.
@@ -57,9 +57,9 @@ pub async fn add_auth_key_handler(
5757
/// It returns two types of responses:
5858
///
5959
/// - `200` with an json [`AuthKey`]
60-
/// resource. If the key was generated successfully.
60+
/// resource. If the key was generated successfully.
6161
/// - `500` with serialized error in debug format. If the key couldn't be
62-
/// generated.
62+
/// generated.
6363
///
6464
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#generate-a-new-authentication-key)
6565
/// for more information about this endpoint.
@@ -99,9 +99,9 @@ pub struct KeyParam(String);
9999
/// It returns two types of responses:
100100
///
101101
/// - `200` with an json [`ActionStatus::Ok`](crate::servers::apis::v1::responses::ActionStatus::Ok)
102-
/// response. If the key was deleted successfully.
102+
/// response. If the key was deleted successfully.
103103
/// - `500` with serialized error in debug format. If the key couldn't be
104-
/// deleted.
104+
/// deleted.
105105
///
106106
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#delete-an-authentication-key)
107107
/// for more information about this endpoint.
@@ -124,9 +124,9 @@ pub async fn delete_auth_key_handler(
124124
/// It returns two types of responses:
125125
///
126126
/// - `200` with an json [`ActionStatus::Ok`](crate::servers::apis::v1::responses::ActionStatus::Ok)
127-
/// response. If the keys were successfully reloaded.
127+
/// response. If the keys were successfully reloaded.
128128
/// - `500` with serialized error in debug format. If the they couldn't be
129-
/// reloaded.
129+
/// reloaded.
130130
///
131131
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#reload-authentication-keys)
132132
/// for more information about this endpoint.

‎src/servers/udp/server/launcher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl Launcher {
213213
stats_event_sender
214214
.send_event(statistics::event::Event::UdpRequestAborted)
215215
.await;
216-
};
216+
}
217217
}
218218
} else {
219219
tokio::task::yield_now().await;

‎src/shared/crypto/ephemeral_instance_keys.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ pub type CipherArrayBlowfish = GenericArray<u8, <CipherBlowfish as BlockSizeUser
1515

1616
lazy_static! {
1717
/// The random static seed.
18-
pub static ref RANDOM_SEED: Seed = Rng::gen(&mut ThreadRng::default());
18+
pub static ref RANDOM_SEED: Seed = Rng::random(&mut ThreadRng::default());
1919

2020
/// The random cipher from the seed.
21-
pub static ref RANDOM_CIPHER_BLOWFISH: CipherBlowfish = CipherBlowfish::new_from_slice(&Rng::gen::<Seed>(&mut ThreadRng::default())).expect("it could not generate key");
21+
pub static ref RANDOM_CIPHER_BLOWFISH: CipherBlowfish = CipherBlowfish::new_from_slice(&Rng::random::<Seed>(&mut ThreadRng::default())).expect("it could not generate key");
2222

2323
/// The constant cipher for testing.
2424
pub static ref ZEROED_TEST_CIPHER_BLOWFISH: CipherBlowfish = CipherBlowfish::new_from_slice(&[0u8; 32]).expect("it could not generate key");

‎tests/common/fixtures.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ pub fn invalid_info_hashes() -> Vec<String> {
88
"-1".to_string(),
99
"1.1".to_string(),
1010
"INVALID INFOHASH".to_string(),
11-
"9c38422213e30bff212b30c360d26f9a0213642".to_string(), // 39-char length instead of 40
11+
"9c38422213e30bff212b30c360d26f9a0213642".to_string(), // 39-char length instead of 40. DevSkim: ignore DS173237
1212
"9c38422213e30bff212b30c360d26f9a0213642&".to_string(), // Invalid char
1313
]
1414
.to_vec()
1515
}
1616

1717
/// Returns a random info hash.
1818
pub fn random_info_hash() -> InfoHash {
19-
let mut rng = rand::thread_rng();
20-
let random_bytes: [u8; 20] = rand::Rng::gen(&mut rng);
19+
let mut rng = rand::rng();
20+
let random_bytes: [u8; 20] = rand::Rng::random(&mut rng);
2121

2222
InfoHash::from_bytes(&random_bytes)
2323
}
2424

2525
/// Returns a random transaction id.
2626
pub fn random_transaction_id() -> TransactionId {
27-
let random_value = rand::Rng::gen::<i32>(&mut rand::thread_rng());
27+
let random_value = rand::Rng::random::<i32>(&mut rand::rng());
2828
TransactionId::new(random_value)
2929
}

‎tests/servers/udp/contract.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async fn send_connection_request(transaction_id: TransactionId, client: &UdpTrac
2525
match client.send(connect_request.into()).await {
2626
Ok(_) => (),
2727
Err(err) => panic!("{err}"),
28-
};
28+
}
2929

3030
let response = match client.receive().await {
3131
Ok(response) => response,
@@ -52,7 +52,7 @@ async fn should_return_a_bad_request_response_when_the_client_sends_an_empty_req
5252
match client.client.send(&empty_udp_request()).await {
5353
Ok(_) => (),
5454
Err(err) => panic!("{err}"),
55-
};
55+
}
5656

5757
let response = match client.client.receive().await {
5858
Ok(response) => response,
@@ -94,7 +94,7 @@ mod receiving_a_connection_request {
9494
match client.send(connect_request.into()).await {
9595
Ok(_) => (),
9696
Err(err) => panic!("{err}"),
97-
};
97+
}
9898

9999
let response = match client.receive().await {
100100
Ok(response) => response,
@@ -146,7 +146,7 @@ mod receiving_an_announce_request {
146146
match client.send(announce_request.into()).await {
147147
Ok(_) => (),
148148
Err(err) => panic!("{err}"),
149-
};
149+
}
150150

151151
match client.receive().await {
152152
Ok(response) => response,
@@ -276,7 +276,7 @@ mod receiving_an_announce_request {
276276
match client.send(announce_request.into()).await {
277277
Ok(_) => (),
278278
Err(err) => panic!("{err}"),
279-
};
279+
}
280280

281281
assert!(client.receive().await.is_err());
282282

@@ -333,7 +333,7 @@ mod receiving_an_scrape_request {
333333
match client.send(scrape_request.into()).await {
334334
Ok(_) => (),
335335
Err(err) => panic!("{err}"),
336-
};
336+
}
337337

338338
let response = match client.receive().await {
339339
Ok(response) => response,

0 commit comments

Comments
 (0)
Please sign in to comment.