mirror of
https://github.com/bolucat/Archive.git
synced 2025-10-30 03:22:11 +08:00
Update On Sun Mar 2 19:33:11 CET 2025
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -92,9 +92,7 @@ impl ProxySocket<ShadowUdpSocket> {
|
||||
context: SharedContext,
|
||||
svr_cfg: &ServerConfig,
|
||||
) -> ProxySocketResult<ProxySocket<ShadowUdpSocket>> {
|
||||
ProxySocket::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
ProxySocket::connect_with_opts(context, svr_cfg, &DEFAULT_CONNECT_OPTS).await
|
||||
}
|
||||
|
||||
/// Create a client to communicate with Shadowsocks' UDP server (outbound)
|
||||
@@ -127,9 +125,7 @@ impl ProxySocket<ShadowUdpSocket> {
|
||||
context: SharedContext,
|
||||
svr_cfg: &ServerConfig,
|
||||
) -> ProxySocketResult<ProxySocket<ShadowUdpSocket>> {
|
||||
ProxySocket::bind_with_opts(context, svr_cfg, AcceptOpts::default())
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
ProxySocket::bind_with_opts(context, svr_cfg, AcceptOpts::default()).await
|
||||
}
|
||||
|
||||
/// Create a `ProxySocket` binding to a specific address (inbound)
|
||||
@@ -240,9 +236,7 @@ where
|
||||
/// Send a UDP packet to addr through proxy
|
||||
#[inline]
|
||||
pub async fn send(&self, addr: &Address, payload: &[u8]) -> ProxySocketResult<usize> {
|
||||
self.send_with_ctrl(addr, &DEFAULT_SOCKET_CONTROL, payload)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
self.send_with_ctrl(addr, &DEFAULT_SOCKET_CONTROL, payload).await
|
||||
}
|
||||
|
||||
/// Send a UDP packet to addr through proxy with `ControlData`
|
||||
@@ -391,9 +385,7 @@ where
|
||||
|
||||
/// Send a UDP packet to target through proxy `target`
|
||||
pub async fn send_to(&self, target: SocketAddr, addr: &Address, payload: &[u8]) -> ProxySocketResult<usize> {
|
||||
self.send_to_with_ctrl(target, addr, &DEFAULT_SOCKET_CONTROL, payload)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
self.send_to_with_ctrl(target, addr, &DEFAULT_SOCKET_CONTROL, payload).await
|
||||
}
|
||||
|
||||
/// Send a UDP packet to target through proxy `target`
|
||||
|
||||
Reference in New Issue
Block a user