From 01b4ce1cb9c31e973e24173865307a9b4a7f38ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Mon, 16 Mar 2026 18:12:50 +0100 Subject: [PATCH 1/2] chore(portmapper): Update to rand 0.10 --- Cargo.lock | 255 ++++++++++++++++++++++++++++++++++++++++-- portmapper/Cargo.toml | 4 +- portmapper/src/pcp.rs | 2 +- 3 files changed, 249 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5535c178..c9059f02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + [[package]] name = "async-trait" version = "0.1.89" @@ -131,6 +137,17 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601" +dependencies = [ + "cfg-if", + "cpufeatures", + "rand_core 0.10.0", +] + [[package]] name = "chrono" version = "0.4.44" @@ -177,6 +194,15 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + [[package]] name = "critical-section" version = "1.2.0" @@ -301,6 +327,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -447,10 +479,24 @@ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" dependencies = [ "cfg-if", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", ] +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.0", + "wasip2", + "wasip3", +] + [[package]] name = "h2" version = "0.4.13" @@ -479,6 +525,15 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + [[package]] name = "hashbrown" version = "0.16.1" @@ -691,6 +746,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "idna" version = "1.1.0" @@ -727,7 +788,7 @@ dependencies = [ "hyper", "hyper-util", "log", - "rand", + "rand 0.9.2", "tokio", "url", "xmltree", @@ -740,7 +801,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.16.1", + "serde", + "serde_core", ] [[package]] @@ -799,6 +862,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" version = "0.2.183" @@ -1295,8 +1364,8 @@ dependencies = [ "netwatch", "ntest", "num_enum", - "rand", - "rand_chacha", + "rand 0.10.0", + "rand_chacha 0.10.0", "serde", "smallvec", "socket2", @@ -1345,6 +1414,16 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.117", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -1387,14 +1466,31 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "rand" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ - "rand_chacha", - "rand_core", + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8" +dependencies = [ + "chacha20", + "getrandom 0.4.2", + "rand_core 0.10.0", ] [[package]] @@ -1404,7 +1500,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_chacha" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e6af7f3e25ded52c41df4e0b1af2d047e45896c2f3281792ed68a1c243daedb" +dependencies = [ + "ppv-lite86", + "rand_core 0.10.0", ] [[package]] @@ -1413,9 +1519,15 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ - "getrandom", + "getrandom 0.3.4", ] +[[package]] +name = "rand_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba" + [[package]] name = "regex-automata" version = "0.4.14" @@ -1946,6 +2058,15 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.114" @@ -2044,6 +2165,28 @@ version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe29135b180b72b04c74aa97b2b4a2ef275161eff9a6c7955ea9eaedc7e1d4e" +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + [[package]] name = "wasm-tracing" version = "2.1.0" @@ -2055,6 +2198,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + [[package]] name = "web-sys" version = "0.3.91" @@ -2312,6 +2467,88 @@ name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] [[package]] name = "wmi" diff --git a/portmapper/Cargo.toml b/portmapper/Cargo.toml index ab294c34..0dd444bc 100644 --- a/portmapper/Cargo.toml +++ b/portmapper/Cargo.toml @@ -27,7 +27,7 @@ libc = "0.2.139" netwatch = { version = "0.15.0", path = "../netwatch" } n0-error = "0.1.2" num_enum = "0.7" -rand = "0.9" +rand = "0.10" serde = { version = "1.0.185", features = ["derive", "rc"] } smallvec = "1.11.1" socket2 = "0.6" @@ -43,7 +43,7 @@ tower-layer = "0.3.3" [dev-dependencies] ntest = "0.9" -rand_chacha = "0.9" +rand_chacha = "0.10" tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] } [features] diff --git a/portmapper/src/pcp.rs b/portmapper/src/pcp.rs index e700c9bb..605bff2f 100644 --- a/portmapper/src/pcp.rs +++ b/portmapper/src/pcp.rs @@ -4,7 +4,7 @@ use std::{net::Ipv4Addr, num::NonZeroU16, time::Duration}; use n0_error::{e, stack_error}; use netwatch::UdpSocket; -use rand::RngCore; +use rand::Rng; use tracing::{debug, trace}; use crate::{Protocol, defaults::PCP_RECV_TIMEOUT as RECV_TIMEOUT}; From 9727da785d57ce30fccbbdb8520ce403f960352e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Wed, 18 Mar 2026 08:16:24 +0100 Subject: [PATCH 2/2] Fix cfg(test) code --- portmapper/src/nat_pmp/protocol/request.rs | 2 ++ portmapper/src/nat_pmp/protocol/response.rs | 2 ++ portmapper/src/pcp/protocol/opcode_data.rs | 2 ++ portmapper/src/pcp/protocol/request.rs | 2 ++ portmapper/src/pcp/protocol/response.rs | 2 ++ 5 files changed, 10 insertions(+) diff --git a/portmapper/src/nat_pmp/protocol/request.rs b/portmapper/src/nat_pmp/protocol/request.rs index bb8a58b8..78118e4c 100644 --- a/portmapper/src/nat_pmp/protocol/request.rs +++ b/portmapper/src/nat_pmp/protocol/request.rs @@ -63,6 +63,8 @@ impl Request { #[cfg(test)] fn random(opcode: super::Opcode, rng: &mut R) -> Self { + use rand::RngExt; + match opcode { Opcode::DetermineExternalAddress => Request::ExternalAddress, Opcode::MapUdp => Request::Mapping { diff --git a/portmapper/src/nat_pmp/protocol/response.rs b/portmapper/src/nat_pmp/protocol/response.rs index 7fc30a46..2d0c9288 100644 --- a/portmapper/src/nat_pmp/protocol/response.rs +++ b/portmapper/src/nat_pmp/protocol/response.rs @@ -185,6 +185,8 @@ impl Response { #[cfg(test)] fn random(opcode: Opcode, rng: &mut R) -> Self { + use rand::RngExt; + match opcode { Opcode::DetermineExternalAddress => { let octets: [u8; 4] = rng.random(); diff --git a/portmapper/src/pcp/protocol/opcode_data.rs b/portmapper/src/pcp/protocol/opcode_data.rs index 5f80305b..ce70413f 100644 --- a/portmapper/src/pcp/protocol/opcode_data.rs +++ b/portmapper/src/pcp/protocol/opcode_data.rs @@ -106,6 +106,8 @@ impl MapData { #[cfg(test)] fn random(rng: &mut R) -> MapData { + use rand::RngExt; + let octets: [u8; 16] = rng.random(); MapData { nonce: rng.random(), diff --git a/portmapper/src/pcp/protocol/request.rs b/portmapper/src/pcp/protocol/request.rs index 30dd3e24..97b2814a 100644 --- a/portmapper/src/pcp/protocol/request.rs +++ b/portmapper/src/pcp/protocol/request.rs @@ -103,6 +103,8 @@ impl Request { #[cfg(test)] fn random(opcode: super::Opcode, rng: &mut R) -> Self { + use rand::RngExt; + let opcode_data = OpcodeData::random(opcode, rng); let addr_octets: [u8; 16] = rng.random(); Request { diff --git a/portmapper/src/pcp/protocol/response.rs b/portmapper/src/pcp/protocol/response.rs index 37f31cc2..6b7af206 100644 --- a/portmapper/src/pcp/protocol/response.rs +++ b/portmapper/src/pcp/protocol/response.rs @@ -225,6 +225,8 @@ impl Response { #[cfg(test)] fn random(opcode: Opcode, rng: &mut R) -> Self { + use rand::RngExt; + let data = OpcodeData::random(opcode, rng); Self { lifetime_seconds: rng.random(),