have to resend ACK, not SYN+ACK

This commit is contained in:
Christian Ulrich 2020-08-23 15:17:19 +02:00
parent ee2f95b72f
commit e745141b51
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 4 additions and 4 deletions

View File

@ -80,7 +80,7 @@ proc captureSeqNumbers(puncher: TcpSyniPuncher, rawFd: AsyncFD,
break break
await cb(seqNums) await cb(seqNums)
proc captureAndResendSynAck(puncher: TcpSyniPuncher, rawFd: AsyncFD) {.async.} = proc captureAndResendAck(puncher: TcpSyniPuncher, rawFd: AsyncFD) {.async.} =
while true: while true:
let packet = await rawFd.recv(4000) let packet = await rawFd.recv(4000)
if packet == "": if packet == "":
@ -90,7 +90,7 @@ proc captureAndResendSynAck(puncher: TcpSyniPuncher, rawFd: AsyncFD) {.async.} =
parsed.ipAddrSrc == puncher.srcIp and parsed.ipAddrSrc == puncher.srcIp and
parsed.tcpPortSrc.int == puncher.srcPort.int and parsed.tcpPortSrc.int == puncher.srcPort.int and
parsed.ipAddrDst == puncher.dstIp and parsed.ipAddrDst == puncher.dstIp and
parsed.tcpFlags == {SYN, ACK}: parsed.tcpFlags == {ACK}:
for port in puncher.dstPorts: for port in puncher.dstPorts:
if parsed.tcpPortDst.int == port.int: if parsed.tcpPortDst.int == port.int:
let ipPacket = IpPacket(protocol: tcp, let ipPacket = IpPacket(protocol: tcp,
@ -158,9 +158,9 @@ proc connect*(puncher: TcpSyniPuncher,
progressCb: PunchProgressCb): Future[AsyncSocket] {.async.} = progressCb: PunchProgressCb): Future[AsyncSocket] {.async.} =
let iface = fromIpAddress(puncher.srcIp) let iface = fromIpAddress(puncher.srcIp)
let captureSeqFd = setupEthernetCapturingSocket(iface) let captureSeqFd = setupEthernetCapturingSocket(iface)
let captureSynAckFd = setupEthernetCapturingSocket(iface) let captureAckFd = setupEthernetCapturingSocket(iface)
asyncCheck puncher.captureSeqNumbers(captureSeqFd, progressCb) asyncCheck puncher.captureSeqNumbers(captureSeqFd, progressCb)
asyncCheck puncher.captureAndResendSynAck(captureSynAckFd) asyncCheck puncher.captureAndResendAck(captureAckFd)
await puncher.addFirewallRules() await puncher.addFirewallRules()
try: try:
result = await puncher.connectParallel() result = await puncher.connectParallel()