Skip to content

Commit e2ffb9c

Browse files
fix: fake ips should not be passed to ACL rules (#2029)
ACL rules are likely not written for fake IPs. One of the major selling point of using the `fake-dns` feature is to be able to make use of ACL rules that are based on domain names instead of purely IP addresses. Passing fake IPs to ACL nullifies this benefit, which is likely not expected from users. Closes #2028
1 parent f058ccb commit e2ffb9c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/shadowsocks-service/src/local/net/tcp/auto_proxy_stream.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{
88
task::{self, Poll},
99
};
1010

11+
use log::trace;
1112
use pin_project::pin_project;
1213
use shadowsocks::{
1314
net::{ConnectOpts, TcpStream},
@@ -49,10 +50,17 @@ impl AutoProxyClientStream {
4950
where
5051
A: Into<Address>,
5152
{
52-
let addr = addr.into();
53+
#[cfg_attr(not(feature = "local-fake-dns"), allow(unused_mut))]
54+
let mut addr = addr.into();
55+
#[cfg(feature = "local-fake-dns")]
56+
if let Some(mapped_addr) = context.try_map_fake_address(&addr).await {
57+
addr = mapped_addr;
58+
}
5359
if context.check_target_bypassed(&addr).await {
60+
trace!("Bypassing target address {addr}");
5461
Self::connect_bypassed_with_opts(context, addr, opts).await
5562
} else {
63+
trace!("Proxying target address {addr}");
5664
Self::connect_proxied_with_opts(context, server, addr, opts).await
5765
}
5866
}

0 commit comments

Comments
 (0)