mirror of
https://github.com/telemt/telemt.git
synced 2026-04-15 01:24:09 +03:00
Update dependencies and refactor random number generation
- Bump versions of several dependencies in Cargo.toml for improved functionality and security, including: - socket2 to 0.6 - nix to 0.31 - toml to 1.0 - x509-parser to 0.18 - dashmap to 6.1 - rand to 0.10 - reqwest to 0.13 - notify to 8.2 - ipnetwork to 0.21 - webpki-roots to 1.0 - criterion to 0.8 - Introduce `OnceLock` for secure random number generation in multiple modules to ensure thread safety and reduce overhead. - Refactor random number generation calls to use the new `RngExt` trait methods for consistency and clarity. - Add new PNG files for architectural documentation.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#![allow(deprecated)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use rand::{Rng, RngCore, SeedableRng};
|
||||
use rand::{Rng, RngExt, SeedableRng};
|
||||
use rand::rngs::StdRng;
|
||||
use parking_lot::Mutex;
|
||||
use zeroize::Zeroize;
|
||||
@@ -101,7 +101,7 @@ impl SecureRandom {
|
||||
return 0;
|
||||
}
|
||||
let mut inner = self.inner.lock();
|
||||
inner.rng.gen_range(0..max)
|
||||
inner.rng.random_range(0..max)
|
||||
}
|
||||
|
||||
/// Generate random bits
|
||||
@@ -141,7 +141,7 @@ impl SecureRandom {
|
||||
pub fn shuffle<T>(&self, slice: &mut [T]) {
|
||||
let mut inner = self.inner.lock();
|
||||
for i in (1..slice.len()).rev() {
|
||||
let j = inner.rng.gen_range(0..=i);
|
||||
let j = inner.rng.random_range(0..=i);
|
||||
slice.swap(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user