import threadpool, asyncnet, nativesockets, random, strutils, asyncdispatch 
from os import sleep

var
    sshVer = "" sock = newAsyncSocket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
proc genAddr(): string =
    randomize()

var
    ip0 = rand(1..255) ip1 = rand(255) ip2 = rand(255) ip3 = rand(255)

return (join([$ip0, $ip1, $ip2, $ip3], "."))

proc ap1(host: string) =
    

try:
    echo "Testing: " & host sock.connect(host, Port(22), 250 * 1) sshVer = 
await recvLine(sock, 250 * 1)
except:
    echo getCurrentExceptionMsg()

echo sshVer

proc ap2(host: string) =
    

try:
    echo "Testing: " & host sock.connect(host, Port(22)) sshVer = await 
recvLine(sock, 250 * 1)
except:
    echo getCurrentExceptionMsg()

echo sshVer

var
    host1 = genAddr() host2 = genAddr() ap1Res = spawn ap1(host1) ap2Res = 
spawn ap2(host2)
while not ap1Res.isReady or not ap2Res.isReady:
    sleep(100)

Reply via email to