From ecff78c344fc52d7bb7477e99dae929325febab3 Mon Sep 17 00:00:00 2001 From: Jason Ernst Date: Thu, 7 Nov 2024 08:30:07 -0800 Subject: [PATCH] undo not adding session if its not a SYN packet, so we get correct RST response --- .../com/jasonernst/kanonproxy/KAnonProxy.kt | 16 ++++++++-------- .../jasonernst/kanonproxy/tcp/TcpHandlingTest.kt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/com/jasonernst/kanonproxy/KAnonProxy.kt b/src/main/kotlin/com/jasonernst/kanonproxy/KAnonProxy.kt index 3086007..f506f1a 100644 --- a/src/main/kotlin/com/jasonernst/kanonproxy/KAnonProxy.kt +++ b/src/main/kotlin/com/jasonernst/kanonproxy/KAnonProxy.kt @@ -171,14 +171,14 @@ class KAnonProxy( transportHeader.destinationPort, ipHeader.protocol, ) - if (!sessionTableBySessionKey.containsKey(key)) { - if (transportHeader is TcpHeader) { - if (transportHeader.isSyn().not()) { - logger.warn("non-syn packet for new session: {}, ignoring", key) - return - } - } - } +// if (!sessionTableBySessionKey.containsKey(key)) { +// if (transportHeader is TcpHeader) { +// if (transportHeader.isSyn().not()) { +// logger.warn("non-syn packet for new session: {}, ignoring", key) +// return +// } +// } +// } val session = sessionTableBySessionKey.getOrPut(key) { isNewSession = true diff --git a/src/test/kotlin/com/jasonernst/kanonproxy/tcp/TcpHandlingTest.kt b/src/test/kotlin/com/jasonernst/kanonproxy/tcp/TcpHandlingTest.kt index 1b57567..2b46d31 100644 --- a/src/test/kotlin/com/jasonernst/kanonproxy/tcp/TcpHandlingTest.kt +++ b/src/test/kotlin/com/jasonernst/kanonproxy/tcp/TcpHandlingTest.kt @@ -23,7 +23,7 @@ import java.net.SocketException import java.nio.ByteBuffer // this needs to be set to 250 if we want to test the TIME_WAIT state -@Timeout(60) +@Timeout(20) class TcpHandlingTest { private val logger = LoggerFactory.getLogger(javaClass) private val kAnonProxy = KAnonProxy(IcmpLinux, mockk(relaxed = true))