Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 34 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
hyperpolymath marked this conversation as resolved.
hex = "0.4"

[dependencies]
Expand Down
18 changes: 9 additions & 9 deletions crates/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -33,7 +33,7 @@ pub fn generate_link_local(interface_id: Option<&str>) -> Result<String> {
})?
}
None => {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let mut bytes = [0u8; 8];
rng.fill(&mut bytes);
bytes.to_vec()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -137,15 +137,15 @@ pub fn generate_random_ipv6(prefix: &str) -> Result<String> {
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::<u128>()
rng.random::<u128>()
};
let host_mask = if host_bits == 128 {
u128::MAX
Expand Down
Loading