Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Apr 21, 2024
1 parent a40257c commit b719d49
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 37 deletions.
14 changes: 9 additions & 5 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
8 changes: 2 additions & 6 deletions crates/shadowsocks-service/src/local/http/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand All @@ -99,13 +98,8 @@ impl AutoProxyClientStream {
where
A: Into<Address>,
{
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`
Expand Down
3 changes: 1 addition & 2 deletions crates/shadowsocks-service/src/local/net/udp/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion crates/shadowsocks-service/src/local/redir/tcprelay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Socks4TcpHandler {
self.context,
&server,
&target_addr,
server.connect_opts_ref()
server.connect_opts_ref(),
)
.await;
server_opt = Some(server);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl Socks5TcpHandler {
self.context,
&server,
&target_addr,
server.connect_opts_ref()
server.connect_opts_ref(),
)
.await;
server_opt = Some(server);
Expand Down
3 changes: 2 additions & 1 deletion crates/shadowsocks-service/src/local/tun/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 3 additions & 7 deletions crates/shadowsocks-service/src/local/tunnel/tcprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions crates/shadowsocks-service/src/server/udprelay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion crates/shadowsocks/src/relay/tcprelay/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ use std::{
pin::Pin,
slice,
task::{self, Poll},
u16,
};

use byte_string::ByteStr;
Expand Down
1 change: 0 additions & 1 deletion crates/shadowsocks/src/relay/tcprelay/aead_2022.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ use std::{
sync::Arc,
task::{self, Poll},
time::SystemTime,
u16,
};

use aes::{
Expand Down

0 comments on commit b719d49

Please sign in to comment.