close socket on timeout

master
Christian Ulrich 2020-10-25 22:23:39 +01:00
parent 383260c95e
commit 699f8306c2
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
2 changed files with 2 additions and 1 deletions

View File

@ -79,7 +79,7 @@ method initiate*(puncher: TcpNutssPuncher, attempt: Attempt,
try:
let acceptFuture = attempt.acceptFuture.get()
await injectSynPackets(attempt)
await progress("")
await progress("") # FIXME: await means we wait until the rendezvous server replied
await acceptFuture or sleepAsync(Timeout)
if acceptFuture.finished():
result = acceptFuture.read()

View File

@ -41,6 +41,7 @@ proc doInitiate(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress,
await sock.send("ACK")
initiateFuture.complete(sock)
else:
sock.close()
echo &"connection {srcIp}:{srcPort.int} -> {dstIp}:{dstPort.int} timed out"
proc doRespond(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress,