Skip to content

Commit

Permalink
disable session pruning for tcp sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
compscidr committed Nov 6, 2024
1 parent bdd1374 commit b903a80
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/kotlin/com/jasonernst/kanonproxy/KAnonProxy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.jasonernst.icmp.common.v6.IcmpV6EchoPacket
import com.jasonernst.kanonproxy.tcp.TcpSession
import com.jasonernst.kanonproxy.tcp.TcpState
import com.jasonernst.kanonproxy.tcp.TcpStateMachine.Companion.G
import com.jasonernst.kanonproxy.udp.UdpSession
import com.jasonernst.knet.Packet
import com.jasonernst.knet.SentinelPacket
import com.jasonernst.knet.network.ip.IpHeader
Expand Down Expand Up @@ -301,13 +302,15 @@ class KAnonProxy(
val startTime = System.currentTimeMillis()
for (session in sessionTableBySessionKey.values) {
if (session.lastHeard < System.currentTimeMillis() - STALE_SESSION_MS) {
logger.warn("Session {} is stale, closing", session)
try {
session.channel.close()
} catch (e: Exception) {
logger.error("Error closing channel: ${e.message}")
if (session is UdpSession) {
logger.warn("Session {} is stale, closing", session)
try {
session.channel.close()
} catch (e: Exception) {
logger.error("Error closing channel: ${e.message}")
}
continue
}
continue
}
if (session is TcpSession) {
processRetransmits(session)
Expand Down

0 comments on commit b903a80

Please sign in to comment.