mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-06 08:14:07 +00:00
fix(deps): update rust crate rand to 0.9 (#1859)
* fix(deps): update rust crate rand to 0.9 * fix: rand 0.9 compat --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: zonyitoo <zonyitoo@gmail.com>
This commit is contained in:
co-authored by
zonyitoo
parent
c81da6e84f
commit
344dff9361
Generated
+3
-3
@@ -3232,7 +3232,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project",
|
||||
"rand 0.8.5",
|
||||
"rand 0.9.0",
|
||||
"sendfd",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -3299,7 +3299,7 @@ dependencies = [
|
||||
"mimalloc",
|
||||
"mime",
|
||||
"qrcode",
|
||||
"rand 0.8.5",
|
||||
"rand 0.9.0",
|
||||
"reqwest",
|
||||
"rpassword",
|
||||
"rpmalloc",
|
||||
@@ -3349,7 +3349,7 @@ dependencies = [
|
||||
"nix",
|
||||
"once_cell",
|
||||
"pin-project",
|
||||
"rand 0.8.5",
|
||||
"rand 0.9.0",
|
||||
"regex",
|
||||
"rustls-native-certs",
|
||||
"serde",
|
||||
|
||||
+1
-1
@@ -229,7 +229,7 @@ directories = "6.0"
|
||||
xdg = "2.5"
|
||||
rpassword = "7.3"
|
||||
libc = { version = "0.2", features = ["extra_traits"] }
|
||||
rand = "0.8"
|
||||
rand = "0.9"
|
||||
|
||||
futures = "0.3"
|
||||
tokio = { version = "1", features = ["rt", "signal"] }
|
||||
|
||||
@@ -134,7 +134,7 @@ lru_time_cache = "0.11"
|
||||
bytes = "1.7"
|
||||
byte_string = "1.0"
|
||||
byteorder = "1.5"
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
rand = { version = "0.9", features = ["small_rng"] }
|
||||
sled = { version = "0.34.7", optional = true }
|
||||
|
||||
futures = "0.3"
|
||||
|
||||
@@ -23,7 +23,6 @@ use hickory_resolver::proto::{
|
||||
rr::{DNSClass, Name, RData, RecordType},
|
||||
};
|
||||
use log::{debug, error, info, trace, warn};
|
||||
use rand::{thread_rng, Rng};
|
||||
use tokio::{
|
||||
io::{AsyncReadExt, AsyncWriteExt},
|
||||
net::{TcpStream, UdpSocket},
|
||||
@@ -854,7 +853,7 @@ impl DnsClient {
|
||||
|
||||
async fn lookup_remote_inner(&self, query: &Query, remote_addr: &Address) -> io::Result<Message> {
|
||||
let mut message = Message::new();
|
||||
message.set_id(thread_rng().gen());
|
||||
message.set_id(rand::random());
|
||||
message.set_recursion_desired(true);
|
||||
message.add_query(query.clone());
|
||||
|
||||
@@ -884,7 +883,7 @@ impl DnsClient {
|
||||
// Then this future will be disabled and have no effect
|
||||
//
|
||||
// Randomly choose from 500ms ~ 1.5s for preventing obvious request pattern
|
||||
let sleep_time = thread_rng().gen_range(500..=1500);
|
||||
let sleep_time = rand::random_range(500..=1500);
|
||||
time::sleep(Duration::from_millis(sleep_time)).await;
|
||||
|
||||
let server = self.balancer.best_tcp_server();
|
||||
@@ -933,7 +932,7 @@ impl DnsClient {
|
||||
|
||||
async fn lookup_local_inner(&self, query: &Query, local_addr: &NameServerAddr) -> io::Result<Message> {
|
||||
let mut message = Message::new();
|
||||
message.set_id(thread_rng().gen());
|
||||
message.set_id(rand::random());
|
||||
message.set_recursion_desired(true);
|
||||
message.add_query(query.clone());
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ use bytes::{BufMut, BytesMut};
|
||||
use hickory_resolver::proto::{op::Message, ProtoError, ProtoErrorKind};
|
||||
use log::{error, trace};
|
||||
use lru_time_cache::{Entry, LruCache};
|
||||
use rand::{thread_rng, Rng};
|
||||
use shadowsocks::{
|
||||
config::ServerConfig,
|
||||
context::SharedContext,
|
||||
@@ -139,7 +138,7 @@ impl DnsClient {
|
||||
|
||||
async fn inner_lookup(&mut self, msg: &mut Message) -> Result<Message, ProtoError> {
|
||||
// Make a random ID
|
||||
msg.set_id(thread_rng().gen());
|
||||
msg.set_id(rand::random());
|
||||
|
||||
trace!("DNS lookup {:?}", msg);
|
||||
|
||||
|
||||
@@ -234,13 +234,18 @@ where
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static CLIENT_SESSION_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_entropy());
|
||||
static CLIENT_SESSION_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_os_rng());
|
||||
}
|
||||
|
||||
/// Generate an AEAD-2022 Client SessionID
|
||||
#[inline]
|
||||
pub fn generate_client_session_id() -> u64 {
|
||||
CLIENT_SESSION_RNG.with(|rng| rng.borrow_mut().gen())
|
||||
loop {
|
||||
let id = CLIENT_SESSION_RNG.with(|rng| rng.borrow_mut().random());
|
||||
if id != 0 {
|
||||
break id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<W> UdpAssociationContext<W>
|
||||
|
||||
@@ -462,12 +462,17 @@ impl Drop for UdpAssociationContext {
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
static CLIENT_SESSION_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_entropy());
|
||||
static CLIENT_SESSION_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_os_rng());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn generate_server_session_id() -> u64 {
|
||||
CLIENT_SESSION_RNG.with(|rng| rng.borrow_mut().gen())
|
||||
loop {
|
||||
let id = CLIENT_SESSION_RNG.with(|rng| rng.borrow_mut().random());
|
||||
if id != 0 {
|
||||
break id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UdpAssociationContext {
|
||||
|
||||
@@ -62,7 +62,7 @@ spin = { version = "0.9", features = ["std"] }
|
||||
pin-project = "1.1"
|
||||
bloomfilter = { version = "3.0.0", optional = true }
|
||||
thiserror = "2.0"
|
||||
rand = { version = "0.8", optional = true }
|
||||
rand = { version = "0.9", optional = true }
|
||||
lru_time_cache = { version = "0.11", optional = true }
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
@@ -18,11 +18,11 @@ fn get_aead_2022_padding_size(payload: &[u8]) -> usize {
|
||||
use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||
|
||||
thread_local! {
|
||||
static PADDING_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_entropy());
|
||||
static PADDING_RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_os_rng());
|
||||
}
|
||||
|
||||
if payload.is_empty() {
|
||||
PADDING_RNG.with(|rng| rng.borrow_mut().gen::<usize>() % AEAD2022_MAX_PADDING_SIZE)
|
||||
PADDING_RNG.with(|rng| rng.borrow_mut().random_range::<usize, _>(0..=AEAD2022_MAX_PADDING_SIZE))
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user