check if we can stop accepting on successfull accept

This commit is contained in:
Christian Ulrich 2020-10-05 17:42:12 +02:00
parent bca5817a6c
commit 02b36516b4
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 5 additions and 6 deletions

View File

@ -250,15 +250,14 @@ proc doAccept(puncher: TcpSyniPuncher, srcIp: IpAddress,
let i = puncher.findAcceptAttempt(srcIp, srcPort, peerIp, @[peerPort]) let i = puncher.findAcceptAttempt(srcIp, srcPort, peerIp, @[peerPort])
if i == -1: if i == -1:
echo "Accepted connection, but no attempt found. Discarding." echo "Accepted connection, but no attempt found. Discarding."
continue
else: else:
let attempt = puncher.acceptAttempts[i] let attempt = puncher.acceptAttempts[i]
attempt.future.complete(peer) attempt.future.complete(peer)
# FIXME: we have to check if more attempts on this endpoint exist and break otherwise let attempts = puncher.findAcceptAttemptsByLocalAddr(srcIp, srcPort)
else: # FIXME: should attempts have timestamps, so we can decide here which ones to delete?
let attempts = puncher.findAcceptAttemptsByLocalAddr(srcIp, srcPort) if attempts.len() <= 1:
# FIXME: should attempts have timestamps, so we can decide here which ones to delete? break
if attempts.len() <= 1:
break
sock.close() sock.close()
proc accept*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress, proc accept*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress,