rawFd -> injectFd
This commit is contained in:
parent
a646815e49
commit
99912b4b69
|
@ -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],
|
||||||
|
|
Loading…
Reference in New Issue