use predicted port range

This commit is contained in:
Christian Ulrich 2020-10-15 19:20:44 +02:00
parent 9e96dd5c78
commit a191de4452
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import asyncdispatch, asyncnet, strformat import asyncdispatch, asyncnet, strformat
from net import IpAddress, Port, `$`, `==` from net import IpAddress, Port, `$`, `==`
import port_prediction
import puncher import puncher
import utils import utils
@ -39,7 +40,8 @@ proc respond*(puncher: TcpNutssResponder, srcPort: Port, dstIp: IpAddress,
let localIp = getPrimaryIPAddr(dstIp) let localIp = getPrimaryIPAddr(dstIp)
try: try:
let connectFuture = newFuture[AsyncSocket]("respond") let connectFuture = newFuture[AsyncSocket]("respond")
for dstPort in dstPorts: let portRange = predictPortRange(dstPorts)
for dstPort in portRange:
asyncCheck connect(localIp, srcPort, dstIp, dstPort, connectFuture) asyncCheck connect(localIp, srcPort, dstIp, dstPort, connectFuture)
await connectFuture or sleepAsync(Timeout) await connectFuture or sleepAsync(Timeout)
if connectFuture.finished(): if connectFuture.finished():