mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-02-09 01:59:16 +08:00
Simple solution for #292, preventing active probing
This commit is contained in:
@@ -90,6 +90,11 @@ where
|
||||
pub fn get_ref(&self) -> &S {
|
||||
self.stream.get_ref()
|
||||
}
|
||||
|
||||
/// Get the internal stream and consume this Connection
|
||||
pub fn into_inner(self) -> S {
|
||||
self.stream.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -140,6 +140,11 @@ impl<S> CryptoStream<S> {
|
||||
pub fn get_ref(&self) -> &S {
|
||||
&self.stream
|
||||
}
|
||||
|
||||
/// Consume the CryptoStream and return the internal stream instance
|
||||
pub fn into_inner(self) -> S {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> CryptoStream<S>
|
||||
|
||||
@@ -24,6 +24,10 @@ impl<S> TcpMonStream<S> {
|
||||
pub fn new(flow_stat: SharedServerFlowStatistic, stream: S) -> TcpMonStream<S> {
|
||||
TcpMonStream { stream, flow_stat }
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> S {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> AsyncRead for TcpMonStream<S>
|
||||
|
||||
@@ -58,6 +58,12 @@ async fn handle_client(
|
||||
"failed to decode Address, may be wrong method or key, from client {}, error: {}",
|
||||
peer_addr, err
|
||||
);
|
||||
|
||||
// Hold the TCP connection until it closes by itself for preventing active probing.
|
||||
// Further discussion: https://github.com/shadowsocks/shadowsocks-rust/issues/292
|
||||
let mut tcp = stream.into_inner().into_inner().into_inner();
|
||||
let _ = super::ignore_until_end(&mut tcp).await;
|
||||
|
||||
return Err(From::from(err));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user