try continuous port range
This commit is contained in:
parent
769621f4b9
commit
490d34bd79
|
@ -84,16 +84,13 @@ proc predictPortRange*(localPort: Port, probedPorts: seq[Port]): seq[Port] =
|
||||||
return
|
return
|
||||||
# assume symmetric NAT with random port mapping
|
# assume symmetric NAT with random port mapping
|
||||||
randomize()
|
randomize()
|
||||||
let first = if minPort >= 1024 + 10000:
|
let first = if maxPort <= uint16.high - RandomPortCount - 1000'u16:
|
||||||
minPort - 10000
|
maxPort + 1000'u16
|
||||||
else:
|
else:
|
||||||
1024
|
uint16.high - RandomPortCount
|
||||||
let last = if maxPort <= uint16.high - 10000:
|
result = newSeq[Port](RandomPortCount)
|
||||||
maxPort + 10000
|
for i in 0'u16 .. RandomPortCount - 1'u16:
|
||||||
else:
|
result[i] = Port(first + i)
|
||||||
uint16.high
|
|
||||||
for _ in 1 .. RandomPortCount:
|
|
||||||
result.add(Port(rand(first .. last)))
|
|
||||||
|
|
||||||
suite "port prediction tests":
|
suite "port prediction tests":
|
||||||
test "single port":
|
test "single port":
|
||||||
|
|
Loading…
Reference in New Issue