diff --git a/Cargo.lock b/Cargo.lock index 2643cbef4681..2efbbb5350ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1873,9 +1873,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "ipnetwork" @@ -2061,7 +2061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] @@ -3957,9 +3957,9 @@ dependencies = [ [[package]] name = "shadowsocks" -version = "1.20.3" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6a87d691a190af90706a2846b6d53ab16afbbb582eed8b9e6b9dca2d0a633a" +checksum = "5ecb3780dfbc654de9383758015b9bb95c6e32fecace36ebded09d67e854d130" dependencies = [ "arc-swap", "async-trait", @@ -3992,9 +3992,9 @@ dependencies = [ [[package]] name = "shadowsocks-crypto" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65da645ff4a6440ba1b52a9d6b4c8792054860ac135cb87f8ad3d2c7a78d41b5" +checksum = "bc77ecb3a97509d22751b76665894fcffad2d10df8758f4e3f20c92ccde6bf4f" dependencies = [ "aes", "aes-gcm", @@ -4012,9 +4012,9 @@ dependencies = [ [[package]] name = "shadowsocks-service" -version = "1.20.4" +version = "1.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c0ce5a3a15e2688b7014c37ed3db33dc296d8b8fda36643c053882bf1d5f44" +checksum = "e79e4f64b489b29e542dea54ea5b4c69e51701e25b222034c257f8b84f74b7e3" dependencies = [ "arc-swap", "async-trait", @@ -4023,6 +4023,7 @@ dependencies = [ "bytes", "cfg-if", "futures", + "http 1.1.0", "http-body-util", "httparse", "hyper", diff --git a/Cargo.toml b/Cargo.toml index c06ff4f62d5d..72eecc36b7ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -125,8 +125,8 @@ env_logger = "0.10.0" thiserror = "1.0.57" log = "0.4" -shadowsocks = "1.20.3" -shadowsocks-service = "1.20.3" +shadowsocks = "1.21.0" +shadowsocks-service = "1.21.2" windows-sys = "0.52.0" diff --git a/test/Cargo.lock b/test/Cargo.lock index f9e94da0be4f..cd43c60da28d 100644 --- a/test/Cargo.lock +++ b/test/Cargo.lock @@ -1238,9 +1238,9 @@ dependencies = [ [[package]] name = "hickory-resolver" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28757f23aa75c98f254cf0405e6d8c25b831b32921b050a66692427679b1f243" +checksum = "0a2e2aba9c389ce5267d31cf1e4dace82390ae276b0b364ea55630b1fa1b44b4" dependencies = [ "cfg-if", "futures-util", @@ -3243,9 +3243,9 @@ dependencies = [ [[package]] name = "shadowsocks" -version = "1.20.3" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb6a87d691a190af90706a2846b6d53ab16afbbb582eed8b9e6b9dca2d0a633a" +checksum = "5ecb3780dfbc654de9383758015b9bb95c6e32fecace36ebded09d67e854d130" dependencies = [ "arc-swap", "async-trait", @@ -3278,9 +3278,9 @@ dependencies = [ [[package]] name = "shadowsocks-crypto" -version = "0.5.4" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65da645ff4a6440ba1b52a9d6b4c8792054860ac135cb87f8ad3d2c7a78d41b5" +checksum = "bc77ecb3a97509d22751b76665894fcffad2d10df8758f4e3f20c92ccde6bf4f" dependencies = [ "aes", "aes-gcm", diff --git a/test/Cargo.toml b/test/Cargo.toml index 621591699260..048916bc4f61 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -68,10 +68,6 @@ thiserror = "1.0.57" log = "0.4" colored = "2.0.0" -# Proxy protocols -shadowsocks = "1.20.3" -shadowsocks-service = "1.20.3" - windows-sys = "0.52.0" chrono = { version = "0.4.26", default-features = false } clap = { version = "4.2.7", features = ["cargo", "derive"] } diff --git a/tunnel-obfuscation/src/shadowsocks.rs b/tunnel-obfuscation/src/shadowsocks.rs index f838f96e6ee4..29c33d0e15a4 100644 --- a/tunnel-obfuscation/src/shadowsocks.rs +++ b/tunnel-obfuscation/src/shadowsocks.rs @@ -11,6 +11,7 @@ use shadowsocks::{ config::{ServerConfig, ServerType}, context::Context, crypto::CipherKind, + net::{ConnectOpts, UdpSocket}, relay::{ udprelay::proxy_socket::{ProxySocketError, UdpSocketType}, Address, @@ -20,7 +21,7 @@ use shadowsocks::{ #[cfg(any(target_os = "android", target_os = "linux"))] use std::os::fd::AsRawFd; use std::{io, net::SocketAddr, sync::Arc}; -use tokio::{net::UdpSocket, sync::oneshot}; +use tokio::sync::oneshot; const SHADOWSOCKS_CIPHER: CipherKind = CipherKind::AES_256_GCM; const SHADOWSOCKS_PASSWORD: &str = "mullvad"; @@ -157,7 +158,10 @@ async fn run_forwarding( Ok(()) } -fn connect_shadowsocks(remote_socket: UdpSocket, shadowsocks_endpoint: SocketAddr) -> ProxySocket { +fn connect_shadowsocks( + remote_socket: UdpSocket, + shadowsocks_endpoint: SocketAddr, +) -> ProxySocket { let ss_context = Context::new_shared(ServerType::Local); let ss_config: ServerConfig = ServerConfig::new( shadowsocks_endpoint, @@ -176,7 +180,7 @@ async fn create_shadowsocks_socket( } else { SocketAddr::new("::".parse().unwrap(), 0) }; - let socket = UdpSocket::bind(random_bind_addr) + let socket = UdpSocket::bind_with_opts(&random_bind_addr, &ConnectOpts::default()) .await .map_err(Error::BindRemoteUdp)?; #[cfg(target_os = "linux")] @@ -193,7 +197,7 @@ async fn create_local_udp_socket(ipv4: bool) -> Result<(UdpSocket, SocketAddr)> } else { SocketAddr::new("::1".parse().unwrap(), 0) }; - let local_udp_socket = UdpSocket::bind(random_bind_addr) + let local_udp_socket = UdpSocket::bind_with_opts(&random_bind_addr, &ConnectOpts::default()) .await .map_err(Error::BindUdp)?; let udp_client_addr = local_udp_socket @@ -213,7 +217,7 @@ async fn wait_for_local_udp_client(udp_listener: &UdpSocket) -> io::Result<()> { } async fn handle_outgoing( - ss_write: Arc, + ss_write: Arc>, local_udp_read: Arc, ss_addr: SocketAddr, wg_addr: Address, @@ -243,7 +247,7 @@ async fn handle_outgoing( } async fn handle_incoming( - ss_read: Arc, + ss_read: Arc>, local_udp_write: Arc, ss_addr: SocketAddr, wg_addr: Address,