diff --git a/Cargo.lock b/Cargo.lock
index ab8bc7c9e..f9fc05716 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1201,7 +1201,7 @@ dependencies = [
"public-suffix",
"quinn",
"quinn-proto",
- "rand 0.8.5",
+ "rand 0.9.0",
"regex",
"register-count",
"ring-compat",
@@ -3428,7 +3428,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if",
- "windows-targets 0.52.6",
+ "windows-targets 0.48.5",
]
[[package]]
diff --git a/clash_lib/Cargo.toml b/clash_lib/Cargo.toml
index 5f573c716..eaa8daafa 100644
--- a/clash_lib/Cargo.toml
+++ b/clash_lib/Cargo.toml
@@ -106,7 +106,7 @@ hickory-proto = { version = "0.25.0-alpha.2", features = ["dns-over-rustls", "dn
dhcproto = "0.12"
ring-compat = { version = "0.8", features = ["aead"] }
-rand = "0.8"
+rand = "0.9"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-appender = "0.2"
diff --git a/clash_lib/src/app/dns/resolver/enhanced.rs b/clash_lib/src/app/dns/resolver/enhanced.rs
index 5eb310efb..626e9751e 100644
--- a/clash_lib/src/app/dns/resolver/enhanced.rs
+++ b/clash_lib/src/app/dns/resolver/enhanced.rs
@@ -1,6 +1,6 @@
use async_trait::async_trait;
use futures::{FutureExt, TryFutureExt};
-use rand::prelude::SliceRandom;
+use rand::seq::IndexedRandom;
use std::{
net,
sync::{
@@ -531,7 +531,7 @@ impl ClashResolver for EnhancedResolver {
}
match self.lookup_ip(host, rr::RecordType::A).await {
- Ok(result) => match result.choose(&mut rand::thread_rng()).unwrap() {
+ Ok(result) => match result.choose(&mut rand::rng()).unwrap() {
net::IpAddr::V4(v4) => Ok(Some(*v4)),
_ => unreachable!("invalid IP family"),
},
@@ -564,7 +564,7 @@ impl ClashResolver for EnhancedResolver {
}
match self.lookup_ip(host, rr::RecordType::AAAA).await {
- Ok(result) => match result.choose(&mut rand::thread_rng()).unwrap() {
+ Ok(result) => match result.choose(&mut rand::rng()).unwrap() {
net::IpAddr::V6(v6) => Ok(Some(*v6)),
_ => unreachable!("invalid IP family"),
},
diff --git a/clash_lib/src/app/dns/resolver/system_linux.rs b/clash_lib/src/app/dns/resolver/system_linux.rs
index 099d18355..3ccc8d14a 100644
--- a/clash_lib/src/app/dns/resolver/system_linux.rs
+++ b/clash_lib/src/app/dns/resolver/system_linux.rs
@@ -33,7 +33,7 @@ impl ClashResolver for SystemResolver {
Ok(response
.iter()
.filter(|x| self.ipv6() || x.is_ipv4())
- .choose(&mut rand::thread_rng()))
+ .choose(&mut rand::rng()))
}
async fn resolve_v4(
@@ -42,7 +42,7 @@ impl ClashResolver for SystemResolver {
_: bool,
) -> anyhow::Result