Рабочая схема проверки 200 портов разом

main
none 9 months ago
parent 32c32b46c4
commit d894e2198d

@ -124,7 +124,6 @@ def client(port, op = "ping"):
data = Queue() data = Queue()
ping = Thread(target = recv, args=(s, data,)) ping = Thread(target = recv, args=(s, data,))
ping.daemon = True
# Стартуем пинг # Стартуем пинг
ping.start() ping.start()
@ -223,27 +222,37 @@ def client(port, op = "ping"):
os.remove(f"verify/{site}.sig") os.remove(f"verify/{site}.sig")
def check_current(ports, cur_port): global ports
ports = []
def check_current(cur_port):
global ports
if client(cur_port, "ping"): if client(cur_port, "ping"):
ports.append(cur_port) ports.append(cur_port)
print("CATHCED: ", cur_port) print("CATHCED: ", cur_port)
return
def check_wait(port):
ping = Thread(target = check_current, args=(port,))
ping.start()
ping.join(8)
# 1. Стартуем все потоки которые вырубают другие потоки, если прошло 8 секунд
# 2. Ожидающие потоки стартуют проверку порта
# => моментальная проверка 200 портов
from tqdm import tqdm from tqdm import tqdm
from time import sleep from time import sleep
def port_check(your_port): def port_check(your_port):
ports = [] global ports
checks = list(range(4000, 4200)) checks = list(range(4000, 4200))
checks.remove(your_port) checks.remove(your_port)
for port in tqdm(checks): for port in tqdm(checks):
if client(port, "ping"): wait = Thread(target = check_wait, args=(port,))
ports.append(port) wait.start()
print("CATHCED: ", port)
# ping = Thread(target = check_current, args=(ports, port,))
# ping.start()
# sleep(10) sleep(10)
return ports return ports

Loading…
Cancel
Save