rawFd -> injectFd

This commit is contained in:
Christian Ulrich 2020-10-10 12:35:36 +02:00
parent a646815e49
commit 99912b4b69
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 4 additions and 4 deletions

View File

@ -254,7 +254,7 @@ proc doAccept(puncher: TcpSyniPuncher, srcIp: IpAddress,
sock.close() sock.close()
proc injectSynPackets(attempt: AcceptAttempt) {.async.} = proc injectSynPackets(attempt: AcceptAttempt) {.async.} =
let rawFd = setupTcpInjectingSocket() let injectFd = setupTcpInjectingSocket()
for dstPort in attempt.dstPorts: for dstPort in attempt.dstPorts:
let synOut = IpPacket(protocol: tcp, ipAddrSrc: attempt.srcIp, let synOut = IpPacket(protocol: tcp, ipAddrSrc: attempt.srcIp,
ipAddrDst: attempt.dstIp, ipTTL: 2, ipAddrDst: attempt.dstIp, ipTTL: 2,
@ -262,7 +262,7 @@ proc injectSynPackets(attempt: AcceptAttempt) {.async.} =
tcpSeqNumber: rand(uint32), tcpAckNumber: 0, tcpSeqNumber: rand(uint32), tcpAckNumber: 0,
tcpFlags: {SYN}, tcpWindowSize: 1452 * 10) tcpFlags: {SYN}, tcpWindowSize: 1452 * 10)
echo &"[{synOut.ipAddrSrc}:{synOut.tcpPortSrc} -> {synOut.ipAddrDst}:{synOut.tcpPortDst}, SEQ {synOut.tcpSeqNumber}] injecting outgoing SYN" echo &"[{synOut.ipAddrSrc}:{synOut.tcpPortSrc} -> {synOut.ipAddrDst}:{synOut.tcpPortDst}, SEQ {synOut.tcpSeqNumber}] injecting outgoing SYN"
await rawFd.injectTcpPacket(synOut) await injectFd.injectTcpPacket(synOut)
for seqNum in attempt.seqNums: for seqNum in attempt.seqNums:
let synIn = IpPacket(protocol: tcp, ipAddrSrc: attempt.dstIp, let synIn = IpPacket(protocol: tcp, ipAddrSrc: attempt.dstIp,
ipAddrDst: attempt.srcIp, ipTTL: 64, ipAddrDst: attempt.srcIp, ipTTL: 64,
@ -271,8 +271,8 @@ proc injectSynPackets(attempt: AcceptAttempt) {.async.} =
tcpSeqNumber: seqNum, tcpAckNumber: 0, tcpSeqNumber: seqNum, tcpAckNumber: 0,
tcpFlags: {SYN}, tcpWindowSize: 1452 * 10) tcpFlags: {SYN}, tcpWindowSize: 1452 * 10)
echo &"[{synIn.ipAddrSrc}:{synIn.tcpPortSrc} -> {synIn.ipAddrDst}:{synIn.tcpPortDst}, SEQ {synIn.tcpSeqNumber}] injecting incoming SYN" echo &"[{synIn.ipAddrSrc}:{synIn.tcpPortSrc} -> {synIn.ipAddrDst}:{synIn.tcpPortDst}, SEQ {synIn.tcpSeqNumber}] injecting incoming SYN"
await rawFd.injectTcpPacket(synIn) await injectFd.injectTcpPacket(synIn)
closeSocket(rawFd) closeSocket(injectFd)
proc accept*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress, proc accept*(puncher: TcpSyniPuncher, srcPort: Port, dstIp: IpAddress,
dstPorts: seq[Port], dstPorts: seq[Port],