diff --git a/crates/shadowsocks-service/src/config.rs b/crates/shadowsocks-service/src/config.rs index d71241efd172..199038a14950 100644 --- a/crates/shadowsocks-service/src/config.rs +++ b/crates/shadowsocks-service/src/config.rs @@ -1528,8 +1528,12 @@ impl Config { }; #[cfg(target_os = "macos")] { - local_config.launchd_tcp_socket_name = config.launchd_tcp_socket_name.clone(); - local_config.launchd_udp_socket_name = config.launchd_udp_socket_name.clone(); + local_config + .launchd_tcp_socket_name + .clone_from(&config.launchd_tcp_socket_name); + local_config + .launchd_udp_socket_name + .clone_from(&config.launchd_udp_socket_name); } let local_instance = LocalInstanceConfig { @@ -2613,8 +2617,8 @@ impl fmt::Display for Config { #[cfg(target_os = "macos")] { - jconf.launchd_tcp_socket_name = local.launchd_tcp_socket_name.clone(); - jconf.launchd_udp_socket_name = local.launchd_udp_socket_name.clone(); + jconf.launchd_tcp_socket_name.clone_from(&local.launchd_tcp_socket_name); + jconf.launchd_udp_socket_name.clone_from(&local.launchd_udp_socket_name); } if local.protocol != ProtocolType::Socks { @@ -2981,7 +2985,7 @@ impl fmt::Display for Config { } jconf.outbound_bind_addr = self.outbound_bind_addr.map(|i| i.to_string()); - jconf.outbound_bind_interface = self.outbound_bind_interface.clone(); + jconf.outbound_bind_interface.clone_from(&self.outbound_bind_interface); // Security if self.security.replay_attack.policy != ReplayAttackPolicy::default() { diff --git a/crates/shadowsocks-service/src/local/http/utils.rs b/crates/shadowsocks-service/src/local/http/utils.rs index 41bd4a6c8920..a79d57a15c50 100644 --- a/crates/shadowsocks-service/src/local/http/utils.rs +++ b/crates/shadowsocks-service/src/local/http/utils.rs @@ -131,12 +131,8 @@ pub async fn connect_host( } else { let server = balancer.best_tcp_server(); - match AutoProxyClientStream::connect_with_opts( - context, - server.as_ref(), - host, - server.connect_opts_ref() - ).await { + match AutoProxyClientStream::connect_with_opts(context, server.as_ref(), host, server.connect_opts_ref()).await + { Ok(s) => Ok((s, Some(server))), Err(err) => { error!( diff --git a/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs b/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs index ed19aa6ba538..36fea6b32e32 100644 --- a/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs +++ b/crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs @@ -85,8 +85,7 @@ impl AutoProxyClientStream { if let Some(mapped_addr) = context.try_map_fake_address(&addr).await { addr = mapped_addr; } - let stream = - TcpStream::connect_remote_with_opts(context.context_ref(), &addr, connect_opts).await?; + let stream = TcpStream::connect_remote_with_opts(context.context_ref(), &addr, connect_opts).await?; Ok(AutoProxyClientStream::Bypassed(stream)) } @@ -99,13 +98,8 @@ impl AutoProxyClientStream { where A: Into
, { - AutoProxyClientStream::connect_proxied_with_opts( - context.clone(), - server, - addr, - context.connect_opts_ref() - ) - .await + AutoProxyClientStream::connect_proxied_with_opts(context.clone(), server, addr, context.connect_opts_ref()) + .await } /// Connect to target `addr` via shadowsocks' server configured by `svr_cfg` diff --git a/crates/shadowsocks-service/src/local/net/udp/association.rs b/crates/shadowsocks-service/src/local/net/udp/association.rs index 13e066097e6f..d58cd6b1c6d1 100644 --- a/crates/shadowsocks-service/src/local/net/udp/association.rs +++ b/crates/shadowsocks-service/src/local/net/udp/association.rs @@ -572,8 +572,7 @@ where let svr_cfg = server.server_config(); let socket = - ProxySocket::connect_with_opts(self.context.context(), svr_cfg, server.connect_opts_ref()) - .await?; + ProxySocket::connect_with_opts(self.context.context(), svr_cfg, server.connect_opts_ref()).await?; let socket = MonProxySocket::from_socket(socket, self.context.flow_stat()); self.proxied_socket.insert(socket) diff --git a/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs b/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs index b416319c8cb2..3b76a62b6a57 100644 --- a/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs +++ b/crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs @@ -47,7 +47,8 @@ async fn establish_client_tcp_redir<'a>( let server = balancer.best_tcp_server(); let svr_cfg = server.server_config(); - let mut remote = AutoProxyClientStream::connect_with_opts(context, &server, addr, server.connect_opts_ref()).await?; + let mut remote = + AutoProxyClientStream::connect_with_opts(context, &server, addr, server.connect_opts_ref()).await?; establish_tcp_tunnel(svr_cfg, &mut stream, &mut remote, peer_addr, addr).await } diff --git a/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs b/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs index fa502d5466b8..ad15a703c757 100644 --- a/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs +++ b/crates/shadowsocks-service/src/local/socks/server/socks4/tcprelay.rs @@ -106,7 +106,7 @@ impl Socks4TcpHandler { self.context, &server, &target_addr, - server.connect_opts_ref() + server.connect_opts_ref(), ) .await; server_opt = Some(server); diff --git a/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs b/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs index eff5af3c46c0..95659411fb40 100644 --- a/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs +++ b/crates/shadowsocks-service/src/local/socks/server/socks5/tcprelay.rs @@ -258,7 +258,7 @@ impl Socks5TcpHandler { self.context, &server, &target_addr, - server.connect_opts_ref() + server.connect_opts_ref(), ) .await; server_opt = Some(server); diff --git a/crates/shadowsocks-service/src/local/tun/tcp.rs b/crates/shadowsocks-service/src/local/tun/tcp.rs index 857271476e34..13ec5841fc17 100644 --- a/crates/shadowsocks-service/src/local/tun/tcp.rs +++ b/crates/shadowsocks-service/src/local/tun/tcp.rs @@ -576,7 +576,8 @@ async fn establish_client_tcp_redir<'a>( let server = balancer.best_tcp_server(); let svr_cfg = server.server_config(); - let mut remote = AutoProxyClientStream::connect_with_opts(context, &server, addr, server.connect_opts_ref()).await?; + let mut remote = + AutoProxyClientStream::connect_with_opts(context, &server, addr, server.connect_opts_ref()).await?; establish_tcp_tunnel(svr_cfg, &mut stream, &mut remote, peer_addr, addr).await } diff --git a/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs b/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs index 1ccf55a3ccf0..ea113b44e1cd 100644 --- a/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs +++ b/crates/shadowsocks-service/src/local/tunnel/tcprelay.rs @@ -138,12 +138,8 @@ async fn handle_tcp_client( svr_cfg.addr(), ); - let mut remote = AutoProxyClientStream::connect_proxied_with_opts( - context, - &server, - forward_addr, - server.connect_opts_ref() - ) - .await?; + let mut remote = + AutoProxyClientStream::connect_proxied_with_opts(context, &server, forward_addr, server.connect_opts_ref()) + .await?; establish_tcp_tunnel(svr_cfg, &mut stream, &mut remote, peer_addr, forward_addr).await } diff --git a/crates/shadowsocks-service/src/server/udprelay.rs b/crates/shadowsocks-service/src/server/udprelay.rs index ea13e6b47cb8..0cc3cb45f675 100644 --- a/crates/shadowsocks-service/src/server/udprelay.rs +++ b/crates/shadowsocks-service/src/server/udprelay.rs @@ -648,7 +648,7 @@ impl UdpAssociationContext { return; } - session_context.client_user = control.user.clone(); + session_context.client_user.clone_from(&control.user); } if let Err(err) = self.dispatch_received_outbound_packet(target_addr, data).await { @@ -822,7 +822,7 @@ impl UdpAssociationContext { control.client_session_id = client_session.client_session_id; control.server_session_id = self.server_session_id; control.packet_id = self.server_packet_id; - control.user = client_session.client_user.clone(); + control.user.clone_from(&client_session.client_user); if let Err(err) = self .inbound diff --git a/crates/shadowsocks/src/relay/tcprelay/aead.rs b/crates/shadowsocks/src/relay/tcprelay/aead.rs index 6945502cf84c..4d0c7fc88287 100644 --- a/crates/shadowsocks/src/relay/tcprelay/aead.rs +++ b/crates/shadowsocks/src/relay/tcprelay/aead.rs @@ -37,7 +37,6 @@ use std::{ pin::Pin, slice, task::{self, Poll}, - u16, }; use byte_string::ByteStr; diff --git a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs index 5a424c48c22f..c1cd52a7b55e 100644 --- a/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs +++ b/crates/shadowsocks/src/relay/tcprelay/aead_2022.rs @@ -51,7 +51,6 @@ use std::{ sync::Arc, task::{self, Poll}, time::SystemTime, - u16, }; use aes::{