Skip to content

Commit 1dd66f3

Browse files
ibigbugdependabot[bot]cndev0
authored
Dependabot/cargo/rust dependencies c9f23a8216 (#699)
* build(deps): bump the rust-dependencies group across 1 directory with 3 updates Bumps the rust-dependencies group with 3 updates in the / directory: [rand](https://github.com/rust-random/rand), [tuic](https://github.com/Itsusinn/tuic) and [tuic-quinn](https://github.com/Itsusinn/tuic). Updates `rand` from 0.8.5 to 0.9.0 - [Release notes](https://github.com/rust-random/rand/releases) - [Changelog](https://github.com/rust-random/rand/blob/master/CHANGELOG.md) - [Commits](rust-random/rand@0.8.5...0.9.0) Updates `tuic` from v1.4.3 to v1.4.5 - [Release notes](https://github.com/Itsusinn/tuic/releases) - [Commits](Itsusinn/tuic@2a96237...17ee3f7) Updates `tuic-quinn` from v1.4.3 to v1.4.5 - [Release notes](https://github.com/Itsusinn/tuic/releases) - [Commits](Itsusinn/tuic@2a96237...17ee3f7) --- updated-dependencies: - dependency-name: rand dependency-type: direct:production update-type: version-update:semver-minor dependency-group: rust-dependencies - dependency-name: tuic dependency-type: direct:production dependency-group: rust-dependencies - dependency-name: tuic-quinn dependency-type: direct:production dependency-group: rust-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> * up * ci * Update Cargo.toml Signed-off-by: Yuwei Ba <[email protected]> * Update Cargo.toml Signed-off-by: Yuwei Ba <[email protected]> * up * rm warning * pre intall cross * f * up * Revert "up" This reverts commit 810f48b. * Revert "Revert "up"" This reverts commit 256721f. * up * up * up --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Yuwei Ba <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: cndev0 <[email protected]>
1 parent 1c1f1a3 commit 1dd66f3

File tree

15 files changed

+39
-38
lines changed

15 files changed

+39
-38
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clash_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ hickory-proto = { version = "0.25.0-alpha.2", features = ["dns-over-rustls", "dn
106106
dhcproto = "0.12"
107107
ring-compat = { version = "0.8", features = ["aead"] }
108108

109-
rand = "0.8"
109+
rand = "0.9"
110110
tracing = "0.1"
111111
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
112112
tracing-appender = "0.2"

clash_lib/src/app/dns/resolver/enhanced.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use async_trait::async_trait;
22
use futures::{FutureExt, TryFutureExt};
3-
use rand::prelude::SliceRandom;
3+
use rand::seq::IndexedRandom;
44
use std::{
55
net,
66
sync::{
@@ -531,7 +531,7 @@ impl ClashResolver for EnhancedResolver {
531531
}
532532

533533
match self.lookup_ip(host, rr::RecordType::A).await {
534-
Ok(result) => match result.choose(&mut rand::thread_rng()).unwrap() {
534+
Ok(result) => match result.choose(&mut rand::rng()).unwrap() {
535535
net::IpAddr::V4(v4) => Ok(Some(*v4)),
536536
_ => unreachable!("invalid IP family"),
537537
},
@@ -564,7 +564,7 @@ impl ClashResolver for EnhancedResolver {
564564
}
565565

566566
match self.lookup_ip(host, rr::RecordType::AAAA).await {
567-
Ok(result) => match result.choose(&mut rand::thread_rng()).unwrap() {
567+
Ok(result) => match result.choose(&mut rand::rng()).unwrap() {
568568
net::IpAddr::V6(v6) => Ok(Some(*v6)),
569569
_ => unreachable!("invalid IP family"),
570570
},

clash_lib/src/app/dns/resolver/system_linux.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl ClashResolver for SystemResolver {
3333
Ok(response
3434
.iter()
3535
.filter(|x| self.ipv6() || x.is_ipv4())
36-
.choose(&mut rand::thread_rng()))
36+
.choose(&mut rand::rng()))
3737
}
3838

3939
async fn resolve_v4(
@@ -42,7 +42,7 @@ impl ClashResolver for SystemResolver {
4242
_: bool,
4343
) -> anyhow::Result<Option<std::net::Ipv4Addr>> {
4444
let response = self.inner.ipv4_lookup(host).await?;
45-
Ok(response.iter().map(|x| x.0).choose(&mut rand::thread_rng()))
45+
Ok(response.iter().map(|x| x.0).choose(&mut rand::rng()))
4646
}
4747

4848
async fn resolve_v6(
@@ -51,7 +51,7 @@ impl ClashResolver for SystemResolver {
5151
_: bool,
5252
) -> anyhow::Result<Option<std::net::Ipv6Addr>> {
5353
let response = self.inner.ipv6_lookup(host).await?;
54-
Ok(response.iter().map(|x| x.0).choose(&mut rand::thread_rng()))
54+
Ok(response.iter().map(|x| x.0).choose(&mut rand::rng()))
5555
}
5656

5757
async fn cached_for(&self, _: std::net::IpAddr) -> Option<String> {

clash_lib/src/app/dns/resolver/system_non_linux.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl ClashResolver for SystemResolver {
3939
}
4040
})
4141
.collect::<Vec<_>>();
42-
Ok(response.into_iter().choose(&mut rand::thread_rng()))
42+
Ok(response.into_iter().choose(&mut rand::rng()))
4343
}
4444

4545
async fn resolve_v4(
@@ -54,7 +54,7 @@ impl ClashResolver for SystemResolver {
5454
_ => None,
5555
})
5656
.collect::<Vec<_>>();
57-
Ok(response.into_iter().choose(&mut rand::thread_rng()))
57+
Ok(response.into_iter().choose(&mut rand::rng()))
5858
}
5959

6060
async fn resolve_v6(
@@ -72,7 +72,7 @@ impl ClashResolver for SystemResolver {
7272
_ => None,
7373
})
7474
.collect::<Vec<_>>();
75-
Ok(response.into_iter().choose(&mut rand::thread_rng()))
75+
Ok(response.into_iter().choose(&mut rand::rng()))
7676
}
7777

7878
async fn cached_for(&self, _: std::net::IpAddr) -> Option<String> {

clash_lib/src/common/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{fmt::Write, num::ParseIntError, path::Path};
55

66
use crate::{common::errors::new_io_error, Error};
77
use rand::{
8-
distributions::uniform::{SampleRange, SampleUniform},
8+
distr::uniform::{SampleRange, SampleUniform},
99
Fill, Rng,
1010
};
1111
use sha2::Digest;
@@ -16,15 +16,15 @@ where
1616
T: SampleUniform,
1717
R: SampleRange<T>,
1818
{
19-
let mut rng = rand::thread_rng();
20-
rng.gen_range(range)
19+
let mut rng = rand::rng();
20+
rng.random_range(range)
2121
}
2222

2323
pub fn rand_fill<T>(buf: &mut T)
2424
where
2525
T: Fill + ?Sized,
2626
{
27-
let mut rng = rand::thread_rng();
27+
let mut rng = rand::rng();
2828
rng.fill(buf)
2929
}
3030

clash_lib/src/proxy/converters/hysteria2.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ impl PortGenrateor {
4040
}
4141

4242
pub fn get(&self) -> u16 {
43-
let mut rng = rand::thread_rng();
43+
let mut rng = rand::rng();
4444
let len =
4545
1 + self.ports.len() + self.range.iter().map(|r| r.len()).sum::<usize>();
46-
let idx = rng.gen_range(0..len);
46+
let idx = rng.random_range(0..len);
4747
match idx {
4848
0 => self.default,
4949
idx if idx <= self.ports.len() => self.ports[idx - 1],

clash_lib/src/proxy/hysteria2/codec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::ErrorKind;
22

33
use bytes::{Buf, BufMut, BytesMut};
44
use quinn_proto::{coding::Codec, VarInt};
5-
use rand::distributions::Alphanumeric;
5+
use rand::distr::Alphanumeric;
66
use tokio_util::codec::{Decoder, Encoder};
77

88
use crate::session::SocksAddr;
@@ -64,8 +64,8 @@ impl Decoder for Hy2TcpCodec {
6464
#[inline]
6565
pub fn padding(range: std::ops::RangeInclusive<u32>) -> Vec<u8> {
6666
use rand::Rng;
67-
let mut rng = rand::thread_rng();
68-
let len = rng.gen_range(range) as usize;
67+
let mut rng = rand::rng();
68+
let len = rng.random_range(range) as usize;
6969
rng.sample_iter(Alphanumeric).take(len).collect()
7070
}
7171

clash_lib/src/proxy/hysteria2/salamander.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl SalamanderObfs {
4242
}
4343

4444
fn encrypt(&self, data: &mut [u8]) -> Bytes {
45-
let salt: [u8; 8] = rand::thread_rng().gen();
45+
let salt: [u8; 8] = rand::rng().random();
4646

4747
let mut res = BytesMut::with_capacity(8 + data.len());
4848
res.put_slice(&salt);

clash_lib/src/proxy/shadowsocks/shadow_tls/connector.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{io, ptr::copy_nonoverlapping, sync::Arc};
22

33
use rand::Rng;
44

5-
use rand::distributions::Distribution;
5+
use rand::distr::Distribution;
66
use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
77
use tokio_rustls::{client::TlsStream, TlsConnector};
88

@@ -119,7 +119,7 @@ fn generate_session_id(hmac: &Hmac, buf: &[u8]) -> [u8; TLS_SESSION_ID_SIZE] {
119119
}
120120

121121
let mut session_id = [0; TLS_SESSION_ID_SIZE];
122-
rand::thread_rng().fill(&mut session_id[..TLS_SESSION_ID_SIZE - HMAC_SIZE]);
122+
rand::rng().fill(&mut session_id[..TLS_SESSION_ID_SIZE - HMAC_SIZE]);
123123
let mut hmac = hmac.to_owned();
124124
hmac.update(&buf[0..SESSION_ID_START]);
125125
hmac.update(&session_id);
@@ -143,13 +143,13 @@ async fn fake_request<S: tokio::io::AsyncRead + AsyncWrite + Unpin>(
143143
) -> std::io::Result<()> {
144144
const HEADER: &[u8; 207] = b"GET / HTTP/1.1\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36\nAccept: gzip, deflate, br\nConnection: Close\nCookie: sessionid=";
145145
const FAKE_REQUEST_LENGTH_RANGE: (usize, usize) = (16, 64);
146-
let cnt = rand::thread_rng()
147-
.gen_range(FAKE_REQUEST_LENGTH_RANGE.0..FAKE_REQUEST_LENGTH_RANGE.1);
146+
let cnt = rand::rng()
147+
.random_range(FAKE_REQUEST_LENGTH_RANGE.0..FAKE_REQUEST_LENGTH_RANGE.1);
148148
let mut buffer = Vec::with_capacity(cnt + HEADER.len() + 1);
149149

150150
buffer.extend_from_slice(HEADER);
151-
rand::distributions::Alphanumeric
152-
.sample_iter(rand::thread_rng())
151+
rand::distr::Alphanumeric
152+
.sample_iter(rand::rng())
153153
.take(cnt)
154154
.for_each(|c| buffer.push(c));
155155
buffer.push(b'\n');

0 commit comments

Comments
 (0)