From e0b03cff6682984cd0039b8c3eee39caccbbc492 Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Sat, 26 Sep 2026 20:20:37 +0200 Subject: [PATCH] deps: move to rand 0.10 The 0.9 and 0.10 renames removed `rand::RngCore` and `thread_rng`, so the upload filler now calls `rand::fill` and the multipart boundary calls `RngExt::random_range`. Both still draw from the thread RNG, so the payload is the same uniform bytes as before. --- Cargo.lock | 69 +++------------------------------------ Cargo.toml | 2 +- fuzz/Cargo.lock | 60 +++++++++++++++++++--------------- src/defs/bytes_counter.rs | 4 +-- src/helper.rs | 6 ++-- 5 files changed, 44 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec9b2a7..61f5eeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -130,7 +130,7 @@ checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -378,7 +378,7 @@ dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -722,7 +722,7 @@ dependencies = [ "icu_properties", "libc", "native-tls", - "rand 0.8.7", + "rand", "rustls", "rustls-native-certs", "rustls-pki-types", @@ -969,15 +969,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "proc-macro2" version = "1.0.107" @@ -1008,17 +999,6 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22f6172bdec972074665ed81ed53b71da00bfc44b65a753cfde883ec4c702a1a" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.10.3" @@ -1027,26 +1007,7 @@ checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ "chacha20", "getrandom 0.4.3", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", + "rand_core", ] [[package]] @@ -1335,7 +1296,7 @@ dependencies = [ "hex", "parking_lot", "pnet_packet", - "rand 0.10.3", + "rand", "socket2 0.6.5", "thiserror", "tokio", @@ -1819,26 +1780,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.8.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556764e583adb45a9f8d413c2a147fa7e8d821e48e12b14fd560b607998b75eb" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ab42fc20575779bd240faa45f94a74256f755c0fa9e89f0ede20d91d0cdfc1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "zerofrom" version = "0.1.8" diff --git a/Cargo.toml b/Cargo.toml index 1a1b4bc..9455537 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,7 +78,7 @@ hyper-tls = { version = "0.6", features = ["alpn"], optional = true } hyper-util = { version = "0.1", features = ["client", "client-legacy", "http1", "http2", "tokio"] } libc = "0.2" native-tls = { version = "0.2", features = ["alpn"], optional = true } -rand = "0.8" +rand = "0.10" rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12", "logging"], optional = true } rustls-native-certs = { version = "0.8", optional = true } rustls-pki-types = { version = "1", optional = true } diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index d458947..b197228 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -130,6 +130,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core 0.10.1", +] + [[package]] name = "chrono" version = "0.4.45" @@ -205,6 +216,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + [[package]] name = "csv" version = "1.4.0" @@ -345,6 +365,7 @@ dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", + "rand_core 0.10.1", ] [[package]] @@ -689,7 +710,7 @@ dependencies = [ "hyper-rustls", "hyper-util", "libc", - "rand 0.8.7", + "rand 0.10.3", "rustls", "rustls-native-certs", "rustls-pki-types", @@ -915,35 +936,25 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22f6172bdec972074665ed81ed53b71da00bfc44b65a753cfde883ec4c702a1a" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ - "rand_chacha 0.9.0", + "rand_chacha", "rand_core 0.9.5", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "rand" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", ] [[package]] @@ -958,21 +969,18 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ - "getrandom 0.2.17", + "getrandom 0.3.4", ] [[package]] name = "rand_core" -version = "0.9.5" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" [[package]] name = "redox_syscall" diff --git a/src/defs/bytes_counter.rs b/src/defs/bytes_counter.rs index 1b3da25..8588b20 100644 --- a/src/defs/bytes_counter.rs +++ b/src/defs/bytes_counter.rs @@ -3,8 +3,6 @@ use std::sync::Mutex; use std::time::Instant; -use rand::RngCore; - /// Tracks total bytes transferred and derives the average transfer rate. /// /// The total is a mutex rather than an `AtomicU64` because 32-bit targets such @@ -110,6 +108,6 @@ impl Default for BytesCounter { /// faster for bulk data and the payload only needs to be incompressible. pub fn random_data(length: usize) -> Vec { let mut data = vec![0u8; length]; - rand::thread_rng().fill_bytes(&mut data); + rand::fill(&mut data[..]); data } diff --git a/src/helper.rs b/src/helper.rs index 4ad5d8c..c9c4a3a 100644 --- a/src/helper.rs +++ b/src/helper.rs @@ -4,7 +4,7 @@ use std::net::IpAddr; use std::time::{Duration, Instant}; use bytes::Bytes; -use rand::Rng; +use rand::RngExt; use url::Url; use crate::cli::Cli; @@ -438,9 +438,9 @@ async fn send_telemetry( /// Builds a `multipart/form-data` body, returning the content type and bytes. fn multipart_form(fields: &[(&str, &str)]) -> (String, Bytes) { let boundary: String = { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); (0..60) - .map(|_| char::from(b'a' + rng.gen_range(0..26))) + .map(|_| char::from(b'a' + rng.random_range(0..26))) .collect() };