From 2cadc1621f3a797a1237f495eb975f83cb15f723 Mon Sep 17 00:00:00 2001 From: SajjadPourali Date: Tue, 16 Apr 2024 11:55:00 -0400 Subject: [PATCH] Discard incoming segments that contain an RST, when state is CLOSED --- Cargo.toml | 2 +- src/stream/tcp.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 233b00e..74e85d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ udp-stream = { version = "0.0", default-features = false } criterion = { version = "0.5" } #tun2.rs example -tun2 = { version = "1.2", features = ["async"] } +tun2 = { version = "1.3", features = ["async"] } #tun_wintun.rs example [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies] diff --git a/src/stream/tcp.rs b/src/stream/tcp.rs index c55935c..e82441c 100644 --- a/src/stream/tcp.rs +++ b/src/stream/tcp.rs @@ -84,7 +84,9 @@ impl IpStackTcpStream { write_notify: None, }; if !tcp.inner().syn { - _ = pkt_sender.send(stream.create_rev_packet(RST | ACK, TTL, None, Vec::new())?); + if !tcp.inner().rst { + _ = pkt_sender.send(stream.create_rev_packet(RST | ACK, TTL, None, Vec::new())?); + } Err(IpStackError::InvalidTcpPacket) } else { Ok(stream)