From 56bfb253e554819977a019e2ecf4a98d783f77ae Mon Sep 17 00:00:00 2001 From: Christian Ulrich Date: Fri, 25 Sep 2020 17:19:34 +0200 Subject: [PATCH] more meaningful debug messages --- tcp_syni.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tcp_syni.nim b/tcp_syni.nim index 49cbd88..aa68ec2 100644 --- a/tcp_syni.nim +++ b/tcp_syni.nim @@ -56,9 +56,7 @@ proc injectTcpPacket(rawFd: AsyncFD, ipPacket: IpPacket) {.async.} = toSockAddr(ipPacket.ipAddrDst, ipPacket.tcpPortDst, sockaddr, sockaddrLen) await rawFd.sendTo(packet.cstring, packet.len, cast[ptr SockAddr](addr sockaddr), sockaddrLen) - echo &"injected {ipPacket.ipAddrSrc}:{ipPacket.tcpPortSrc.int} -> {ipPacket.ipAddrDst}:{ipPacket.tcpPortDst.int} (seq {ipPacket.tcpSeqNumber})" except OSError as e: - echo &"cannot inject {ipPacket.ipAddrSrc}:{ipPacket.tcpPortSrc.int} -> {ipPacket.ipAddrDst}:{ipPacket.tcpPortDst.int} (seq {ipPacket.tcpSeqNumber}): ", e.msg raise newException(PunchHoleError, e.msg) proc captureSeqNumbers(puncher: TcpSyniPuncher, rawFd: AsyncFD, @@ -96,6 +94,7 @@ proc captureAndResendAck(puncher: TcpSyniPuncher, captureFd: AsyncFD, for port in puncher.dstPorts: if parsed.tcpPortDst.int == port.int: parsed.ipTTL = 64 + echo &"[{parsed.ipAddrSrc}:{parsed.tcpPortSrc.int} -> {parsed.ipAddrDst}:{parsed.tcpPortDst}, SEQ {parsed.tcpSeqNumber}] resending ACK with TTL {parsed.ipTTL}" await injectFd.injectTcpPacket(parsed) return @@ -201,6 +200,7 @@ proc accept*(puncher: TcpSyniPuncher): Future[AsyncSocket] {.async.} = tcpAckNumber: 0, tcpFlags: {SYN}, tcpWindowSize: 1452 * 10) + echo &"[{ipPacket.ipAddrSrc}:{ipPacket.tcpPortSrc} -> {ipPacket.ipAddrDst}:{ipPacket.tcpPortDst}, SEQ {ipPacket.tcpSeqNumber}] injecting SYN" asyncCheck rawFd.injectTcpPacket(ipPacket) let sock = newAsyncSocket() sock.setSockOpt(OptReuseAddr, true)