From 02b36516b4d7bd90aa58275705ff82f38508151b Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Mon, 5 Oct 2020 17:42:12 +0200 Subject: [PATCH] check if we can stop accepting on successfull accept --- tcp_syni.nim | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tcp_syni.nim b/tcp_syni.nim index 6e4fa9c..dd2dd0f 100644 --- a/tcp_syni.nim +++ b/tcp_syni.nim @@ -250,15 +250,14 @@ proc doAccept(puncher: TcpSyniPuncher, srcIp: IpAddress, let i = puncher.findAcceptAttempt(srcIp, srcPort, peerIp, @[peerPort]) if i == -1: echo "Accepted connection, but no attempt found. Discarding." + continue else: let attempt = puncher.acceptAttempts[i] attempt.future.complete(peer) - # FIXME: we have to check if more attempts on this endpoint exist and break otherwise - else: - let attempts = puncher.findAcceptAttemptsByLocalAddr(srcIp, srcPort) - # FIXME: should attempts have timestamps, so we can decide here which ones to delete? - if attempts.len() <= 1: - break + let attempts = puncher.findAcceptAttemptsByLocalAddr(srcIp, srcPort) + # FIXME: should attempts have timestamps, so we can decide here which ones to delete? + if attempts.len() <= 1: + break sock.close() proc accept*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress,