move port prediction into dedicated module
This commit is contained in:
parent
a0125d7d80
commit
9147194427
|
@ -0,0 +1,11 @@
|
|||
from net import Port
|
||||
|
||||
proc predictPortRange*(dstPorts: seq[Port]): seq[Port] =
|
||||
# TODO: do real port prediction
|
||||
result = newSeq[Port](1)
|
||||
let basePort = min(dstPorts[1].uint16,
|
||||
uint16.high - (result.len - 1).uint16)
|
||||
for i in 0 .. result.len - 1:
|
||||
result[i] = Port(basePort + i.uint16)
|
||||
|
||||
|
|
@ -42,14 +42,6 @@ proc injectTcpPacket*(rawFd: AsyncFD, ipPacket: IpPacket) {.async.} =
|
|||
except OSError as e:
|
||||
raise newException(PunchHoleError, e.msg)
|
||||
|
||||
proc predictPortRange*(dstPorts: seq[Port]): seq[Port] =
|
||||
# TODO: do real port prediction
|
||||
result = newSeq[Port](1)
|
||||
let basePort = min(dstPorts[1].uint16,
|
||||
uint16.high - (result.len - 1).uint16)
|
||||
for i in 0 .. result.len - 1:
|
||||
result[i] = Port(basePort + i.uint16)
|
||||
|
||||
proc makeFirewallRule(srcIp: IpAddress, srcPort: Port,
|
||||
dstIp: IpAddress, dstPort: Port): string =
|
||||
# FIXME: use & instead of fmt?
|
||||
|
|
|
@ -3,6 +3,7 @@ from net import IpAddress, Port, `$`, `==`, parseIpAddress
|
|||
from random import randomize, rand
|
||||
from sequtils import any
|
||||
import ip_packet
|
||||
import port_prediction
|
||||
import puncher
|
||||
import raw_socket
|
||||
import utils
|
||||
|
|
|
@ -3,6 +3,7 @@ from net import IpAddress, Port, `$`, `==`
|
|||
from nativesockets import setSockOptInt
|
||||
import ip_packet
|
||||
import network_interface
|
||||
import port_prediction
|
||||
import puncher
|
||||
import raw_socket
|
||||
import utils
|
||||
|
|
Loading…
Reference in New Issue