Skip to content

Commit

Permalink
Upgrade shadowsocks to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Dec 10, 2024
1 parent 6d811b3 commit f3a8810
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
19 changes: 10 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
12 changes: 6 additions & 6 deletions test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
16 changes: 10 additions & 6 deletions tunnel-obfuscation/src/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use shadowsocks::{
config::{ServerConfig, ServerType},
context::Context,
crypto::CipherKind,
net::{ConnectOpts, UdpSocket},
relay::{
udprelay::proxy_socket::{ProxySocketError, UdpSocketType},
Address,
Expand All @@ -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";
Expand Down Expand Up @@ -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<UdpSocket> {
let ss_context = Context::new_shared(ServerType::Local);
let ss_config: ServerConfig = ServerConfig::new(
shadowsocks_endpoint,
Expand All @@ -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")]
Expand All @@ -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
Expand All @@ -213,7 +217,7 @@ async fn wait_for_local_udp_client(udp_listener: &UdpSocket) -> io::Result<()> {
}

async fn handle_outgoing(
ss_write: Arc<ProxySocket>,
ss_write: Arc<ProxySocket<UdpSocket>>,
local_udp_read: Arc<UdpSocket>,
ss_addr: SocketAddr,
wg_addr: Address,
Expand Down Expand Up @@ -243,7 +247,7 @@ async fn handle_outgoing(
}

async fn handle_incoming(
ss_read: Arc<ProxySocket>,
ss_read: Arc<ProxySocket<UdpSocket>>,
local_udp_write: Arc<UdpSocket>,
ss_addr: SocketAddr,
wg_addr: Address,
Expand Down

0 comments on commit f3a8810

Please sign in to comment.