Skip to content

Commit

Permalink
style: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
iHsin committed Apr 9, 2024
1 parent 4ee0b15 commit e7c07ca
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 33 deletions.
2 changes: 1 addition & 1 deletion clash_lib/src/app/dns/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async fn listen_dhcp_client(iface: &str) -> io::Result<UdpSocket> {

new_udp_socket(
Some(&listen_addr.parse().expect("must parse")),
Some(&Interface::Name(iface.to_string()))
Some(&Interface::Name(iface.to_string())),
)
.await
}
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/common/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Service<Uri> for LocalConnector {
_ => panic!("invalid url: {}", remote),
},
}),
None
None,
)
.await
})
Expand Down
11 changes: 4 additions & 7 deletions clash_lib/src/proxy/direct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl OutboundHandler for Handler {
resolver,
sess.destination.host().as_str(),
sess.destination.port(),
None
None,
)
.await?;

Expand All @@ -75,12 +75,9 @@ impl OutboundHandler for Handler {
sess: &Session,
resolver: ThreadSafeDNSResolver,
) -> std::io::Result<BoxedChainedDatagram> {
let d = new_udp_socket(
None,
sess.iface.as_ref()
)
.await
.map(|x| OutboundDatagramImpl::new(x, resolver))?;
let d = new_udp_socket(None, sess.iface.as_ref())
.await
.map(|x| OutboundDatagramImpl::new(x, resolver))?;

let d = ChainedDatagramWrapper::new(d);
d.append_to_chain(self.name()).await;
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl OutboundHandler for Handler {
resolver.clone(),
remote_addr.host().as_str(),
remote_addr.port(),
None
None,
)
.await?;

Expand Down
8 changes: 2 additions & 6 deletions clash_lib/src/proxy/shadowsocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl OutboundHandler for Handler {
resolver.clone(),
self.opts.server.as_str(),
self.opts.port,
self.opts.common_opts.iface.as_ref()
self.opts.common_opts.iface.as_ref(),
)
.map_err(|x| {
io::Error::new(
Expand Down Expand Up @@ -306,11 +306,7 @@ impl OutboundHandler for Handler {
_ => return Err(io::Error::new(io::ErrorKind::Other, "unsupported cipher")),
},
);
let socket = new_udp_socket(
None,
self.opts.common_opts.iface.as_ref()
)
.await?;
let socket = new_udp_socket(None, self.opts.common_opts.iface.as_ref()).await?;
let socket = ProxySocket::from_socket(UdpSocketType::Client, ctx, &cfg, socket);
let d = OutboundDatagramShadowsocks::new(
socket,
Expand Down
6 changes: 1 addition & 5 deletions clash_lib/src/proxy/socks/inbound/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,7 @@ pub async fn handle_tcp<'a>(
}
socks_command::UDP_ASSOCIATE => {
let udp_addr = SocketAddr::new(s.local_addr()?.ip(), 0);
let udp_inbound = new_udp_socket(
Some(&udp_addr),
None
)
.await?;
let udp_inbound = new_udp_socket(Some(&udp_addr), None).await?;

trace!(
"Got a UDP_ASSOCIATE request from {}, UDP assigned at {}",
Expand Down
4 changes: 2 additions & 2 deletions clash_lib/src/proxy/trojan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl OutboundHandler for Handler {
resolver.clone(),
self.opts.server.as_str(),
self.opts.port,
self.opts.common_opts.iface.as_ref()
self.opts.common_opts.iface.as_ref(),
)
.map_err(|x| {
io::Error::new(
Expand Down Expand Up @@ -193,7 +193,7 @@ impl OutboundHandler for Handler {
resolver.clone(),
self.opts.server.as_str(),
self.opts.port,
self.opts.common_opts.iface.as_ref()
self.opts.common_opts.iface.as_ref(),
)
.map_err(|x| {
io::Error::new(
Expand Down
2 changes: 1 addition & 1 deletion clash_lib/src/proxy/utils/socket_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::{
time::Duration,
};

use crate::session::get_somark;
use socket2::TcpKeepalive;
use tokio::{
net::{TcpSocket, TcpStream, UdpSocket},
time::timeout,
};
use crate::session::get_somark;

#[cfg(target_os = "windows")]
use tracing::warn;
Expand Down
4 changes: 2 additions & 2 deletions clash_lib/src/proxy/vmess/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl OutboundHandler for Handler {
resolver,
self.opts.server.as_str(),
self.opts.port,
self.opts.common_opts.iface.as_ref()
self.opts.common_opts.iface.as_ref(),
)
.map_err(|x| {
io::Error::new(
Expand Down Expand Up @@ -212,7 +212,7 @@ impl OutboundHandler for Handler {
resolver.clone(),
self.opts.server.as_str(),
self.opts.port,
self.opts.common_opts.iface.as_ref()
self.opts.common_opts.iface.as_ref(),
)
.map_err(|x| {
io::Error::new(
Expand Down
6 changes: 1 addition & 5 deletions clash_lib/src/proxy/wg/wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ impl WireguardTunnel {

let remote_endpoint = config.remote_endpoint;

let udp = new_udp_socket(
None,
None
)
.await?;
let udp = new_udp_socket(None, None).await?;

Ok(Self {
source_peer_ip: config.source_peer_ip,
Expand Down
3 changes: 1 addition & 2 deletions clash_lib/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@ fn insuff_bytes() -> io::Error {
io::Error::new(io::ErrorKind::Other, "insufficient bytes")
}


static GLOBAL_MARK: AtomicU32 = AtomicU32::new(0);
static ENABLE_MARK: AtomicBool = AtomicBool::new(false);
/// get socket SO_MARK that outgoing socket should use
Expand All @@ -468,4 +467,4 @@ pub fn get_somark() -> Option<u32> {
} else {
None
}
}
}

0 comments on commit e7c07ca

Please sign in to comment.