From ef9a2962dfc603aee52be9066d77522d47b3ece7 Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Thu, 16 Sep 2021 21:35:34 -0700 Subject: [PATCH] bugfix(fake_tcp) do not RST packets that already have RST on them --- src/fake_tcp/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fake_tcp/mod.rs b/src/fake_tcp/mod.rs index 8b2f049..bf4201e 100644 --- a/src/fake_tcp/mod.rs +++ b/src/fake_tcp/mod.rs @@ -394,6 +394,7 @@ impl Stack { assert!(shared.tuples.lock().unwrap().insert(tuple, Arc::new(incoming)).is_none()); tokio::spawn(sock.accept()); } else { + info!("Bad TCP SYN packet from {}, sending RST", remote_addr); let buf = build_tcp_packet( local_addr, remote_addr, @@ -404,7 +405,8 @@ impl Stack { ); shared.outgoing.try_send(buf).unwrap(); } - } else { + } else if (tcp_packet.get_flags() & tcp::TcpFlags::RST) == 0 { + info!("Bad TCP packet from {}, sending RST", remote_addr); let buf = build_tcp_packet( local_addr, remote_addr,