Skip to content

Commit

Permalink
refactor: remove cfg on fn args
Browse files Browse the repository at this point in the history
instead, just do nothing on other platforms
  • Loading branch information
Itsusinn committed Mar 28, 2024
1 parent d9303f6 commit 5d6b0c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 4 additions & 6 deletions clash_lib/src/proxy/direct/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ impl OutboundHandler for Handler {
sess.destination.host().as_str(),
sess.destination.port(),
None,
#[cfg(any(target_os = "linux", target_os = "android"))]
None,
sess.packet_mark,
)
.await?;

Expand All @@ -66,8 +65,8 @@ impl OutboundHandler for Handler {
async fn proxy_stream(
&self,
s: AnyStream,
#[allow(unused_variables)] sess: &Session,
#[allow(unused_variables)] _resolver: ThreadSafeDNSResolver,
_sess: &Session,
_resolver: ThreadSafeDNSResolver,
) -> std::io::Result<AnyStream> {
Ok(s)
}
Expand All @@ -80,8 +79,7 @@ impl OutboundHandler for Handler {
let d = new_udp_socket(
None,
sess.iface.as_ref(),
#[cfg(any(target_os = "linux", target_os = "android"))]
None,
sess.packet_mark,
)
.await
.map(|x| OutboundDatagramImpl::new(x, resolver))?;
Expand Down
8 changes: 4 additions & 4 deletions clash_lib/src/proxy/utils/socket_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub async fn new_tcp_stream<'a>(
address: &'a str,
port: u16,
iface: Option<&'a Interface>,
#[cfg(any(target_os = "linux", target_os = "android"))] packet_mark: Option<u32>,
packet_mark: Option<u32>,
) -> io::Result<AnyStream> {
let dial_addr = resolver
.resolve(address, false)
Expand Down Expand Up @@ -125,7 +125,7 @@ pub async fn new_tcp_stream<'a>(
pub async fn new_udp_socket(
src: Option<&SocketAddr>,
iface: Option<&Interface>,
#[cfg(any(target_os = "linux", target_os = "android"))] packet_mark: Option<u32>,
packet_mark: Option<u32>,
) -> io::Result<UdpSocket> {
let socket = match src {
Some(src) => {
Expand Down Expand Up @@ -172,9 +172,9 @@ impl StdSocketExt for std::net::TcpStream {
}

fn set_mark<'a>(socket: socket2::SockRef<'a>, mark: u32) -> io::Result<()> {
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
#[cfg(any(target_os = "android", target_os = "linux"))]
return socket.set_mark(mark);
#[cfg(not(any(target_os = "android", target_os = "fuchsia", target_os = "linux")))]
#[cfg(not(any(target_os = "android", target_os = "linux")))]
return Ok(());
}

Expand Down

0 comments on commit 5d6b0c9

Please sign in to comment.