diff --git a/Cargo.lock b/Cargo.lock index 6af736a..8b8a995 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -58,6 +58,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", +] + [[package]] name = "clap" version = "4.6.6" @@ -104,15 +115,25 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + [[package]] name = "getrandom" -version = "0.2.17" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", - "wasi", + "r-efi", + "rand_core", ] [[package]] @@ -194,15 +215,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" -[[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" @@ -222,34 +234,27 @@ dependencies = [ ] [[package]] -name = "rand" -version = "0.8.8" +name = "r-efi" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "rand" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ - "ppv-lite86", + "chacha20", + "getrandom", "rand_core", ] [[package]] name = "rand_core" -version = "0.6.4" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" [[package]] name = "ryu" @@ -360,12 +365,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - [[package]] name = "windows-link" version = "0.2.1" @@ -380,23 +379,3 @@ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ "windows-link", ] - -[[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.111", -] diff --git a/Cargo.toml b/Cargo.toml index 6608e6a..c092f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ clap = { version = "4", features = ["derive"] } serde = { version = "1", features = ["derive"] } serde_json = "1" thiserror = "2" -rand = "0.8" +rand = "0.10" hex = "0.4" [dependencies] diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index a1854ca..c3f0d49 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -3,7 +3,7 @@ //! IPv6 utility functions for address manipulation and generation. use ipv6_only_core::{IPv6Address, IPv6Network, Ipv6Error, Result}; -use rand::Rng; +use rand::RngExt; use std::net::Ipv6Addr; /// Compress an IPv6 address to its shortest form. @@ -33,7 +33,7 @@ pub fn generate_link_local(interface_id: Option<&str>) -> Result { })? } None => { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut bytes = [0u8; 8]; rng.fill(&mut bytes); bytes.to_vec() @@ -68,7 +68,7 @@ pub fn generate_unique_local( .map_err(|_| Ipv6Error::InvalidAddress("Invalid hex in global ID".to_string()))? } None => { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut bytes = [0u8; 5]; rng.fill(&mut bytes); bytes.to_vec() @@ -87,7 +87,7 @@ pub fn generate_unique_local( .map_err(|_| Ipv6Error::InvalidAddress("Invalid hex in subnet ID".to_string()))? } None => { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut bytes = [0u8; 2]; rng.fill(&mut bytes); bytes.to_vec() @@ -107,7 +107,7 @@ pub fn generate_unique_local( })? } None => { - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); let mut bytes = [0u8; 8]; rng.fill(&mut bytes); bytes.to_vec() @@ -137,15 +137,15 @@ pub fn generate_random_ipv6(prefix: &str) -> Result { let prefix_len = network.prefix_len(); let host_bits = 128 - prefix_len; - let mut rng = rand::thread_rng(); + let mut rng = rand::rng(); // Generate random host part let random_host: u128 = if host_bits >= 64 { - let high: u64 = rng.gen(); - let low: u64 = rng.gen(); + let high: u64 = rng.random(); + let low: u64 = rng.random(); ((high as u128) << 64) | (low as u128) } else { - rng.gen::() + rng.random::() }; let host_mask = if host_bits == 128 { u128::MAX