From e1260d14de464a6415fab3b3fb1c863751023ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Sat, 19 Dec 2020 11:24:52 +0100 Subject: [PATCH] Update rand to 0.8 and rand_distr to 0.4 --- Cargo.lock | 97 +++++++++++++++++++++--------- aquatic_common/Cargo.toml | 2 +- aquatic_common/src/lib.rs | 6 +- aquatic_http/Cargo.toml | 2 +- aquatic_http_load_test/Cargo.toml | 4 +- aquatic_http_protocol/Cargo.toml | 2 +- aquatic_udp/Cargo.toml | 2 +- aquatic_udp_bench/Cargo.toml | 4 +- aquatic_udp_load_test/Cargo.toml | 4 +- aquatic_udp_load_test/src/utils.rs | 14 ++--- aquatic_ws/Cargo.toml | 2 +- aquatic_ws_load_test/Cargo.toml | 4 +- 12 files changed, 89 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bac52d5..7ae97fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ name = "aquatic_common" version = "0.1.0" dependencies = [ "indexmap", - "rand", + "rand 0.8.0", ] [[package]] @@ -94,7 +94,7 @@ dependencies = [ "privdrop", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "serde", "smartstring", "socket2", @@ -112,7 +112,7 @@ dependencies = [ "mio", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "rand_distr", "serde", ] @@ -132,7 +132,7 @@ dependencies = [ "memchr", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "serde", "serde_bencode", "smartstring", @@ -158,7 +158,7 @@ dependencies = [ "privdrop", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "serde", "socket2", ] @@ -174,7 +174,7 @@ dependencies = [ "indicatif", "mimalloc", "num-format", - "rand", + "rand 0.8.0", "rand_distr", "serde", ] @@ -193,7 +193,7 @@ dependencies = [ "parking_lot", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "rand_distr", "serde", "socket2", @@ -229,7 +229,7 @@ dependencies = [ "privdrop", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "serde", "socket2", "tungstenite", @@ -247,7 +247,7 @@ dependencies = [ "mio", "quickcheck", "quickcheck_macros", - "rand", + "rand 0.8.0", "rand_distr", "serde", "serde_json", @@ -694,6 +694,17 @@ dependencies = [ "wasi 0.9.0+wasi-snapshot-preview1", ] +[[package]] +name = "getrandom" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + [[package]] name = "gimli" version = "0.23.0" @@ -1181,8 +1192,8 @@ checksum = "a44883e74aa97ad63db83c4bf8ca490f02b2fc02f92575e720c8551e843c945f" dependencies = [ "env_logger", "log", - "rand", - "rand_core", + "rand 0.7.3", + "rand_core 0.5.1", ] [[package]] @@ -1211,12 +1222,23 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.15", "libc", - "rand_chacha", - "rand_core", - "rand_hc", - "rand_pcg", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76330fb486679b4ace3670f117bbc9e16204005c4bde9c4bd372f45bed34f12" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.0", + "rand_hc 0.3.0", ] [[package]] @@ -1226,7 +1248,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.0", ] [[package]] @@ -1235,17 +1267,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.15", +] + +[[package]] +name = "rand_core" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8b34ba8cfb21243bd8df91854c830ff0d785fff2e82ebd4434c2644cb9ada18" +dependencies = [ + "getrandom 0.2.0", ] [[package]] name = "rand_distr" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56" +checksum = "da9e8f32ad24fb80d07d2323a9a2ce8b30d68a62b8cb4df88119ff49a698f038" dependencies = [ "num-traits", - "rand", + "rand 0.8.0", ] [[package]] @@ -1254,16 +1295,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] -name = "rand_pcg" -version = "0.2.1" +name = "rand_hc" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" dependencies = [ - "rand_core", + "rand_core 0.6.0", ] [[package]] @@ -1582,7 +1623,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ "cfg-if 0.1.10", "libc", - "rand", + "rand 0.7.3", "redox_syscall", "remove_dir_all", "winapi", @@ -1684,7 +1725,7 @@ dependencies = [ "input_buffer", "log", "native-tls", - "rand", + "rand 0.7.3", "sha-1", "url", "utf-8", diff --git a/aquatic_common/Cargo.toml b/aquatic_common/Cargo.toml index 1fa29c3..df81bee 100644 --- a/aquatic_common/Cargo.toml +++ b/aquatic_common/Cargo.toml @@ -12,4 +12,4 @@ name = "aquatic_common" [dependencies] indexmap = "1" -rand = { version = "0.7", features = ["small_rng"] } \ No newline at end of file +rand = { version = "0.8", features = ["small_rng"] } \ No newline at end of file diff --git a/aquatic_common/src/lib.rs b/aquatic_common/src/lib.rs index cef413e..d1cfc98 100644 --- a/aquatic_common/src/lib.rs +++ b/aquatic_common/src/lib.rs @@ -57,12 +57,10 @@ pub fn extract_response_peers( let half_peer_map_len = peer_map_len / 2; let offset_first_half = rng.gen_range( - 0, - (half_peer_map_len + (peer_map_len % 2)) - half_num_to_take + 0..(half_peer_map_len + (peer_map_len % 2)) - half_num_to_take ); let offset_second_half = rng.gen_range( - half_peer_map_len, - peer_map_len - half_num_to_take + half_peer_map_len..peer_map_len - half_num_to_take ); let end_first_half = offset_first_half + half_num_to_take; diff --git a/aquatic_http/Cargo.toml b/aquatic_http/Cargo.toml index 61aa20f..65d4a3b 100644 --- a/aquatic_http/Cargo.toml +++ b/aquatic_http/Cargo.toml @@ -33,7 +33,7 @@ mio = { version = "0.7", features = ["tcp", "os-poll", "os-util"] } native-tls = "0.2" parking_lot = "0.11" privdrop = "0.5" -rand = { version = "0.7", features = ["small_rng"] } +rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive"] } smartstring = "0.2" socket2 = { version = "0.3", features = ["reuseport"] } diff --git a/aquatic_http_load_test/Cargo.toml b/aquatic_http_load_test/Cargo.toml index 1bd5f5b..4262dc1 100644 --- a/aquatic_http_load_test/Cargo.toml +++ b/aquatic_http_load_test/Cargo.toml @@ -16,8 +16,8 @@ aquatic_http_protocol = "0.1.0" hashbrown = "0.9" mimalloc = { version = "0.1", default-features = false } mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] } -rand = { version = "0.7", features = ["small_rng"] } -rand_distr = "0.3" +rand = { version = "0.8", features = ["small_rng"] } +rand_distr = "0.4" serde = { version = "1", features = ["derive"] } [dev-dependencies] diff --git a/aquatic_http_protocol/Cargo.toml b/aquatic_http_protocol/Cargo.toml index 58e6b50..6d757a0 100644 --- a/aquatic_http_protocol/Cargo.toml +++ b/aquatic_http_protocol/Cargo.toml @@ -34,7 +34,7 @@ httparse = "1" itoa = "0.4" log = "0.4" memchr = "2" -rand = { version = "0.7", features = ["small_rng"] } +rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive"] } serde_bencode = "0.2" smartstring = "0.2" diff --git a/aquatic_udp/Cargo.toml b/aquatic_udp/Cargo.toml index cdffb60..4196f3c 100644 --- a/aquatic_udp/Cargo.toml +++ b/aquatic_udp/Cargo.toml @@ -28,7 +28,7 @@ mimalloc = { version = "0.1", default-features = false } mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] } parking_lot = "0.11" privdrop = "0.5" -rand = { version = "0.7", features = ["small_rng"] } +rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive"] } socket2 = { version = "0.3", features = ["reuseport"] } diff --git a/aquatic_udp_bench/Cargo.toml b/aquatic_udp_bench/Cargo.toml index 9f3f565..e887947 100644 --- a/aquatic_udp_bench/Cargo.toml +++ b/aquatic_udp_bench/Cargo.toml @@ -17,6 +17,6 @@ crossbeam-channel = "0.5" indicatif = "0.15" mimalloc = { version = "0.1", default-features = false } num-format = "0.4" -rand = { version = "0.7", features = ["small_rng"] } -rand_distr = "0.3" +rand = { version = "0.8", features = ["small_rng"] } +rand_distr = "0.4" serde = { version = "1", features = ["derive"] } diff --git a/aquatic_udp_load_test/Cargo.toml b/aquatic_udp_load_test/Cargo.toml index d396868..5e899e8 100644 --- a/aquatic_udp_load_test/Cargo.toml +++ b/aquatic_udp_load_test/Cargo.toml @@ -18,8 +18,8 @@ hashbrown = "0.9" mimalloc = { version = "0.1", default-features = false } mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] } parking_lot = "0.11" -rand = { version = "0.7", features = ["small_rng"] } -rand_distr = "0.3" +rand = { version = "0.8", features = ["small_rng"] } +rand_distr = "0.4" serde = { version = "1", features = ["derive"] } socket2 = { version = "0.3", features = ["reuseport"] } diff --git a/aquatic_udp_load_test/src/utils.rs b/aquatic_udp_load_test/src/utils.rs index 929b9b9..e02b712 100644 --- a/aquatic_udp_load_test/src/utils.rs +++ b/aquatic_udp_load_test/src/utils.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use rand_distr::{Standard, Pareto}; +use rand_distr::Pareto; use rand::prelude::*; use aquatic_udp_protocol::*; @@ -15,7 +15,9 @@ pub fn create_torrent_peer( info_hashes: &Arc>, connection_id: ConnectionId ) -> TorrentPeer { - let num_scape_hashes = rng.gen_range(1, config.handler.scrape_max_torrents); + let num_scape_hashes = rng.gen_range( + 1..config.handler.scrape_max_torrents + ); let mut scrape_hash_indeces = Vec::new(); @@ -82,13 +84,7 @@ pub fn create_connect_request(transaction_id: TransactionId) -> Request { fn random_20_bytes() -> [u8; 20] { let mut bytes = [0; 20]; - for (i, b) in rand::thread_rng() - .sample_iter(&Standard) - .enumerate() - .take(20) { - - bytes[i] = b - } + thread_rng().fill_bytes(&mut bytes[..]); bytes } \ No newline at end of file diff --git a/aquatic_ws/Cargo.toml b/aquatic_ws/Cargo.toml index 5fd90ea..a7b17a5 100644 --- a/aquatic_ws/Cargo.toml +++ b/aquatic_ws/Cargo.toml @@ -31,7 +31,7 @@ mio = { version = "0.7", features = ["tcp", "os-poll", "os-util"] } native-tls = "0.2" parking_lot = "0.11" privdrop = "0.5" -rand = { version = "0.7", features = ["small_rng"] } +rand = { version = "0.8", features = ["small_rng"] } serde = { version = "1", features = ["derive"] } socket2 = { version = "0.3", features = ["reuseport"] } tungstenite = "0.11" diff --git a/aquatic_ws_load_test/Cargo.toml b/aquatic_ws_load_test/Cargo.toml index c9ea7b8..31f567c 100644 --- a/aquatic_ws_load_test/Cargo.toml +++ b/aquatic_ws_load_test/Cargo.toml @@ -16,8 +16,8 @@ aquatic_ws_protocol = "0.1.0" hashbrown = { version = "0.9", features = ["serde"] } mimalloc = { version = "0.1", default-features = false } mio = { version = "0.7", features = ["udp", "os-poll", "os-util"] } -rand = { version = "0.7", features = ["small_rng"] } -rand_distr = "0.3" +rand = { version = "0.8", features = ["small_rng"] } +rand_distr = "0.4" serde = { version = "1", features = ["derive"] } serde_json = "1" slab = "0.4"