diff --git a/tcp_syni.nim b/tcp_syni.nim index 707dad0..de9c676 100644 --- a/tcp_syni.nim +++ b/tcp_syni.nim @@ -133,8 +133,8 @@ proc doConnect(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress, proc doAccept(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress, dstPort: Port, seqNums: seq[uint32], future: Future[AsyncSocket]) {.async.} = - let sock = newAsyncSocket() try: + let sock = newAsyncSocket() sock.setSockOpt(OptReuseAddr, true) sock.getFd.setSockOptInt(IPPROTO_IP, IP_TTL, 2) sock.bindAddr(srcPort, $srcIp) @@ -144,9 +144,14 @@ proc doAccept(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress, dstPort: Port, except OSError: discard try: + # FIXME: timeout let rawFd = setupTcpInjectingSocket() asyncCheck injectSyns(rawFd, dstIp, dstPort, srcIp, srcPort, seqNums) - sock.getFd.setSockOptInt(IPPROTO_IP, IP_TTL, 64) + let sock = newAsyncSocket() + sock.setSockOpt(OptReuseAddr, true) + sock.setSockOpt(OptReusePort, true) + sock.bindAddr(srcPort, $srcIp) + sock.listen() let connectedSock = await sock.accept() future.complete(connectedSock) except OSError as e: