fix direction
This commit is contained in:
parent
c5f6348cf2
commit
4499c09e85
12
tcp_syni.nim
12
tcp_syni.nim
|
@ -84,13 +84,13 @@ proc injectSyns(rawFd: AsyncFD, srcIp: IpAddress, srcPort: Port,
|
||||||
seqNums: seq[uint32]) {.async.} =
|
seqNums: seq[uint32]) {.async.} =
|
||||||
for seqNum in seqNums:
|
for seqNum in seqNums:
|
||||||
let ipPacket = IpPacket(protocol: tcp,
|
let ipPacket = IpPacket(protocol: tcp,
|
||||||
tcpIpSrc: srcIp,
|
tcpIpSrc: dstIp,
|
||||||
tcpIpDst: dstIp,
|
tcpIpDst: srcIp,
|
||||||
tcpPortSrc: dstPort,
|
tcpPortSrc: srcPort,
|
||||||
tcpPortDst: srcPort,
|
tcpPortDst: dstPort,
|
||||||
tcpSeqNumber: seqNum,
|
tcpSeqNumber: seqNum,
|
||||||
tcpFlags: {SYN})
|
tcpFlags: {SYN})
|
||||||
echo &"injecting {srcIP}:{srcPort.int} -> {dstIp}:{dstPort.int} (seq {seqNum})"
|
echo &"injecting {dstIP}:{dstPort.int} -> {srcIp}:{srcPort.int} (seq {seqNum})"
|
||||||
try:
|
try:
|
||||||
let packet = serialize(ipPacket)
|
let packet = serialize(ipPacket)
|
||||||
var sockaddr: Sockaddr_storage
|
var sockaddr: Sockaddr_storage
|
||||||
|
@ -148,7 +148,7 @@ proc doAccept(srcIp: IpAddress, srcPort: Port, dstIp: IpAddress, dstPort: Port,
|
||||||
let connectedSock = await sock.accept()
|
let connectedSock = await sock.accept()
|
||||||
future.complete(connectedSock)
|
future.complete(connectedSock)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
echo &"connection {srcIP}:{srcPort.int} -> {dstIp}:{dstPort.int} failed: ", e.msg
|
echo &"accepting connection {srcIP}:{srcPort.int} -> {dstIp}:{dstPort.int} failed: ", e.msg
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc connect*(puncher: TcpSyniPuncher,
|
proc connect*(puncher: TcpSyniPuncher,
|
||||||
|
|
Loading…
Reference in New Issue