mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-07 00:13:33 +00:00
set SO_LINGER (0) for misbehav clients before close()
This commit is contained in:
@@ -35,6 +35,11 @@ impl<S> MonProxyStream<S> {
|
||||
pub fn get_mut(&mut self) -> &mut S {
|
||||
&mut self.stream
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> S {
|
||||
self.stream
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> AsyncRead for MonProxyStream<S>
|
||||
|
||||
@@ -132,6 +132,12 @@ impl TcpServerClient {
|
||||
|
||||
#[cfg(feature = "aead-cipher-2022")]
|
||||
if self.method.is_aead_2022() {
|
||||
// Set SO_LINGER(0) for misbehave clients, which will eventually receive RST. (ECONNRESET)
|
||||
// This will also prevent the socket entering TIME_WAIT state.
|
||||
|
||||
let stream = self.stream.into_inner().into_inner();
|
||||
let _ = stream.set_linger(Some(Duration::ZERO));
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user