close on failed low-TTL connects too
This commit is contained in:
parent
64cc41eb90
commit
bec4c1b158
|
@ -227,8 +227,9 @@ proc connect*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress,
|
||||||
|
|
||||||
proc prepareAccept(attempt: AcceptAttempt) {.async.} =
|
proc prepareAccept(attempt: AcceptAttempt) {.async.} =
|
||||||
for dstPort in attempt.dstPorts:
|
for dstPort in attempt.dstPorts:
|
||||||
|
var sock: AsyncSocket
|
||||||
try:
|
try:
|
||||||
let sock = newAsyncSocket()
|
sock = newAsyncSocket()
|
||||||
sock.setSockOpt(OptReuseAddr, true)
|
sock.setSockOpt(OptReuseAddr, true)
|
||||||
sock.getFd.setSockOptInt(IPPROTO_IP, IP_TTL, 2)
|
sock.getFd.setSockOptInt(IPPROTO_IP, IP_TTL, 2)
|
||||||
sock.bindAddr(attempt.srcPort, $(attempt.srcIp))
|
sock.bindAddr(attempt.srcPort, $(attempt.srcIp))
|
||||||
|
@ -236,9 +237,9 @@ proc prepareAccept(attempt: AcceptAttempt) {.async.} =
|
||||||
await connectFuture or sleepAsync(Timeout)
|
await connectFuture or sleepAsync(Timeout)
|
||||||
if connectFuture.finished():
|
if connectFuture.finished():
|
||||||
echo "connected during accept phase"
|
echo "connected during accept phase"
|
||||||
sock.close()
|
|
||||||
except OSError:
|
except OSError:
|
||||||
discard
|
discard
|
||||||
|
sock.close()
|
||||||
|
|
||||||
proc doAccept(puncher: TcpSyniPuncher, srcIp: IpAddress,
|
proc doAccept(puncher: TcpSyniPuncher, srcIp: IpAddress,
|
||||||
srcPort: Port) {.async.} =
|
srcPort: Port) {.async.} =
|
||||||
|
|
Loading…
Reference in New Issue