diff --git a/clash_lib/src/app/dns/dhcp.rs b/clash_lib/src/app/dns/dhcp.rs index 4e90a1aa..bbf66808 100644 --- a/clash_lib/src/app/dns/dhcp.rs +++ b/clash_lib/src/app/dns/dhcp.rs @@ -176,7 +176,7 @@ async fn listen_dhcp_client(iface: &str) -> io::Result { new_udp_socket( Some(&listen_addr.parse().expect("must parse")), - Some(&Interface::Name(iface.to_string())) + Some(&Interface::Name(iface.to_string())), ) .await } diff --git a/clash_lib/src/common/http.rs b/clash_lib/src/common/http.rs index 441fb77e..dafc221b 100644 --- a/clash_lib/src/common/http.rs +++ b/clash_lib/src/common/http.rs @@ -49,7 +49,7 @@ impl Service for LocalConnector { _ => panic!("invalid url: {}", remote), }, }), - None + None, ) .await }) diff --git a/clash_lib/src/proxy/direct/mod.rs b/clash_lib/src/proxy/direct/mod.rs index 77c004fb..4877f9aa 100644 --- a/clash_lib/src/proxy/direct/mod.rs +++ b/clash_lib/src/proxy/direct/mod.rs @@ -52,7 +52,7 @@ impl OutboundHandler for Handler { resolver, sess.destination.host().as_str(), sess.destination.port(), - None + None, ) .await?; @@ -75,12 +75,9 @@ impl OutboundHandler for Handler { sess: &Session, resolver: ThreadSafeDNSResolver, ) -> std::io::Result { - 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; diff --git a/clash_lib/src/proxy/relay/mod.rs b/clash_lib/src/proxy/relay/mod.rs index e53033c8..8a2c7167 100644 --- a/clash_lib/src/proxy/relay/mod.rs +++ b/clash_lib/src/proxy/relay/mod.rs @@ -91,7 +91,7 @@ impl OutboundHandler for Handler { resolver.clone(), remote_addr.host().as_str(), remote_addr.port(), - None + None, ) .await?; diff --git a/clash_lib/src/proxy/shadowsocks/mod.rs b/clash_lib/src/proxy/shadowsocks/mod.rs index dff599da..0fbf619a 100644 --- a/clash_lib/src/proxy/shadowsocks/mod.rs +++ b/clash_lib/src/proxy/shadowsocks/mod.rs @@ -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( @@ -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, diff --git a/clash_lib/src/proxy/socks/inbound/stream.rs b/clash_lib/src/proxy/socks/inbound/stream.rs index 21871537..51e341c4 100644 --- a/clash_lib/src/proxy/socks/inbound/stream.rs +++ b/clash_lib/src/proxy/socks/inbound/stream.rs @@ -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 {}", diff --git a/clash_lib/src/proxy/trojan/mod.rs b/clash_lib/src/proxy/trojan/mod.rs index d268d75b..a7108d81 100644 --- a/clash_lib/src/proxy/trojan/mod.rs +++ b/clash_lib/src/proxy/trojan/mod.rs @@ -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( @@ -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( diff --git a/clash_lib/src/proxy/utils/socket_helpers.rs b/clash_lib/src/proxy/utils/socket_helpers.rs index d3ffab58..320524ed 100644 --- a/clash_lib/src/proxy/utils/socket_helpers.rs +++ b/clash_lib/src/proxy/utils/socket_helpers.rs @@ -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; diff --git a/clash_lib/src/proxy/vmess/mod.rs b/clash_lib/src/proxy/vmess/mod.rs index 330bd03f..6f8251c9 100644 --- a/clash_lib/src/proxy/vmess/mod.rs +++ b/clash_lib/src/proxy/vmess/mod.rs @@ -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( @@ -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( diff --git a/clash_lib/src/proxy/wg/wireguard.rs b/clash_lib/src/proxy/wg/wireguard.rs index ca24e13c..f0be577a 100644 --- a/clash_lib/src/proxy/wg/wireguard.rs +++ b/clash_lib/src/proxy/wg/wireguard.rs @@ -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, diff --git a/clash_lib/src/session.rs b/clash_lib/src/session.rs index 0ada4166..205caa40 100644 --- a/clash_lib/src/session.rs +++ b/clash_lib/src/session.rs @@ -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 @@ -468,4 +467,4 @@ pub fn get_somark() -> Option { } else { None } -} \ No newline at end of file +}