Skip to content

Commit 4c3b053

Browse files
committed
feat(shadowsocks-service): AutoProxyClientStream prevent mapping fake-ips twice (#2028)
1 parent e2ffb9c commit 4c3b053

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ impl AutoProxyClientStream {
8989
if let Some(mapped_addr) = context.try_map_fake_address(&addr).await {
9090
addr = mapped_addr;
9191
}
92+
Self::connect_bypassed_with_opts_inner(context, addr, connect_opts).await
93+
}
94+
95+
async fn connect_bypassed_with_opts_inner<A>(
96+
context: Arc<ServiceContext>,
97+
addr: A,
98+
connect_opts: &ConnectOpts,
99+
) -> io::Result<Self>
100+
where
101+
A: Into<Address>,
102+
{
103+
let addr = addr.into();
92104
let stream = TcpStream::connect_remote_with_opts(context.context_ref(), &addr, connect_opts).await?;
93105
Ok(Self::Bypassed(stream))
94106
}
@@ -117,6 +129,18 @@ impl AutoProxyClientStream {
117129
if let Some(mapped_addr) = context.try_map_fake_address(&addr).await {
118130
addr = mapped_addr;
119131
}
132+
Self::connect_proxied_with_opts_inner(context, server, addr, connect_opts).await
133+
}
134+
135+
async fn connect_proxied_with_opts_inner<A>(
136+
context: Arc<ServiceContext>,
137+
server: &ServerIdent,
138+
addr: A,
139+
connect_opts: &ConnectOpts,
140+
) -> io::Result<Self>
141+
where
142+
A: Into<Address>,
143+
{
120144
let flow_stat = context.flow_stat();
121145
let stream = match ProxyClientStream::connect_with_opts_map(
122146
context.context(),

0 commit comments

Comments
 (0)