summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Pettersson <markus.pettersson@mullvad.net>2025-09-16 15:19:07 +0200
committerMarkus Pettersson <markus.pettersson@mullvad.net>2025-09-23 17:04:31 +0200
commitdced4f1e30dd941cb9beaa8add5c1585523a3e7a (patch)
tree22ed54a9e25481384e2b8c9b27bd524f905ddc46
parent9a6664c9259775359b5e794b28b1a30fc0602734 (diff)
downloadmullvadvpn-dced4f1e30dd941cb9beaa8add5c1585523a3e7a.tar.xz
mullvadvpn-dced4f1e30dd941cb9beaa8add5c1585523a3e7a.zip
Upgrade `rand` to `0.9` in `talpid-wireguard`
Document why `rand` can't be upgraded in `wireguard_nt::daita`
-rw-r--r--Cargo.lock1
-rw-r--r--talpid-wireguard/Cargo.toml7
-rw-r--r--talpid-wireguard/src/connectivity/pinger/icmp.rs2
-rw-r--r--talpid-wireguard/src/mtu_detection.rs13
-rw-r--r--talpid-wireguard/src/wireguard_nt/daita.rs2
5 files changed, 14 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6b47c3d791..62ac26d187 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5855,6 +5855,7 @@ dependencies = [
"parking_lot",
"proptest",
"rand 0.8.5",
+ "rand 0.9.2",
"rand_chacha 0.3.1",
"rtnetlink",
"socket2 0.5.8",
diff --git a/talpid-wireguard/Cargo.toml b/talpid-wireguard/Cargo.toml
index cf6e0f8acf..fb198c9502 100644
--- a/talpid-wireguard/Cargo.toml
+++ b/talpid-wireguard/Cargo.toml
@@ -30,9 +30,8 @@ zeroize = "1"
chrono = { workspace = true, features = ["clock"] }
tokio = { workspace = true, features = ["process", "rt-multi-thread", "fs"] }
tunnel-obfuscation = { path = "../tunnel-obfuscation" }
-rand = "0.8.5"
+rand = { workspace = true }
surge-ping = "0.8.0"
-rand_chacha = "0.3.1"
wireguard-go-rs = { path = "../wireguard-go-rs" }
tun07 = { package = "tun", version = "0.7.11", features = [
"async",
@@ -67,6 +66,10 @@ bitflags = "1.2"
talpid-windows = { path = "../talpid-windows" }
widestring = "1.0"
maybenot = "2.0.0"
+# TODO: rand 0.8 is a hard requirement of maybenot-ffi 2.0. May be upgraded to rand 0.9
+# when maybenot 2.2 is released.
+rand08 = { package = "rand", version = "0.8.5" }
+rand_chacha = "0.3.1"
# TODO: Figure out which features are needed and which are not
[target.'cfg(windows)'.dependencies.windows-sys]
diff --git a/talpid-wireguard/src/connectivity/pinger/icmp.rs b/talpid-wireguard/src/connectivity/pinger/icmp.rs
index 338f364844..590242c27c 100644
--- a/talpid-wireguard/src/connectivity/pinger/icmp.rs
+++ b/talpid-wireguard/src/connectivity/pinger/icmp.rs
@@ -170,7 +170,7 @@ impl PayloadWriter for Pinger {
}
fn write_payload(&mut self, buffer: &mut [u8]) {
- rand::thread_rng().fill(buffer);
+ rand::rng().fill(buffer);
}
}
diff --git a/talpid-wireguard/src/mtu_detection.rs b/talpid-wireguard/src/mtu_detection.rs
index 98d4394437..04f7f36c41 100644
--- a/talpid-wireguard/src/mtu_detection.rs
+++ b/talpid-wireguard/src/mtu_detection.rs
@@ -239,7 +239,7 @@ mod tests {
/// see <https://docs.rs/tokio/latest/tokio/time/fn.pause.html#auto-advance> for details.
mod timeout {
use super::*;
- use rand::{distributions::Uniform, thread_rng};
+ use rand::{Rng, distr::Uniform};
use std::pin::Pin;
use tokio::test;
@@ -280,11 +280,10 @@ mod tests {
/// order.
#[test(start_paused = true)]
async fn all_pings_ok() {
- let mut rng = thread_rng();
// Random delay for each ping, but within PING_OFFSET_TIMEOUT of the first
- let uniform = Uniform::new(Duration::ZERO, PING_OFFSET_TIMEOUT);
+ let uniform = Uniform::new(Duration::ZERO, PING_OFFSET_TIMEOUT).unwrap();
let pings = (0..=100)
- .map(|p| delayed_ping(Ok(p), rng.sample(uniform)))
+ .map(|p| delayed_ping(Ok(p), rand::rng().sample(uniform)))
.collect();
let max = max_ping_size(pings).await.unwrap();
assert_eq!(max, 100);
@@ -310,15 +309,15 @@ mod tests {
/// each other in time, the largest return value is chosen as normal.
#[test(start_paused = true)]
async fn delay_first_ping() {
- let mut rng = thread_rng();
// Random delay for each ping, but within PING_OFFSET_TIMEOUT of the first and no sooner
// than 5s
let uniform = Uniform::new(
Duration::from_secs(5),
Duration::from_secs(5) + PING_OFFSET_TIMEOUT,
- );
+ )
+ .unwrap();
let pings = (0..=100)
- .map(|p| delayed_ping(Ok(p), rng.sample(uniform)))
+ .map(|p| delayed_ping(Ok(p), rand::rng().sample(uniform)))
.collect();
let max = max_ping_size(pings).await.unwrap();
assert_eq!(max, 100);
diff --git a/talpid-wireguard/src/wireguard_nt/daita.rs b/talpid-wireguard/src/wireguard_nt/daita.rs
index 9cf96852fd..a2c5d7e6c1 100644
--- a/talpid-wireguard/src/wireguard_nt/daita.rs
+++ b/talpid-wireguard/src/wireguard_nt/daita.rs
@@ -1,7 +1,7 @@
use super::WIREGUARD_KEY_LENGTH;
use maybenot::{MachineId, Timer};
use once_cell::sync::OnceCell;
-use rand::{
+use rand08::{
SeedableRng,
rngs::{OsRng, adapter::ReseedingRng},
};