1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import os
import re
from ping3 import ping
import random
from multiprocessing import Pool
from colorama import init, Fore, Back, Style
import tqdm
init()
pool_size = 20
_print = print
def print(data=''):
data = str(data)
_print(data + Style.RESET_ALL)
def ping_host(host):
r = ping(host)
r = r if type(r) == float else 0
r *= 100
r = int(r)
if r == 0:
r = 10000
return (host, r)
print(Fore.YELLOW + f"\n Ultimate {Fore.BLUE}Surfshark{Fore.YELLOW} VPN pinger")
print(Fore.YELLOW + f" - Pool size: {Fore.GREEN}{pool_size}")
print(Fore.YELLOW + f" - by {Fore.RED}cofob{Fore.YELLOW} (c) 2022\n")
files_unprocessed = os.listdir()
files = []
for i in files_unprocessed:
if i.endswith("udp.ovpn") and not i.startswith('ru-'):
files.append(i)
hosts = []
print(f"Pinging {Fore.RED}all except Russian{Style.RESET_ALL} hosts...")
names = []
for name in files:
with open(name, 'r') as file:
text = file.read()
r = re.findall(r'remote ([a-z0-9\-.]+)', text)[0]
names.append(r)
p = Pool(pool_size)
for i in tqdm.tqdm(p.imap_unordered(ping_host, names), total=len(names)):
hosts.append(i)
p.close()
p.terminate()
print("\nResults:")
for host in hosts:
print(Fore.GREEN + f"- {Style.RESET_ALL} {host[0]}: "
f"{(Fore.GREEN + str(host[1])) if host[1] != 10000 else (Fore.RED + 'offline' + Fore.GREEN)}")
hosts.sort(key=lambda x: x[1])
hosts = hosts[:5]
print(f"\n{Fore.YELLOW}Best hosts:")
for host in hosts:
print(f"{Fore.GREEN}- {Style.RESET_ALL}{host[0]}: {Fore.MAGENTA}{host[1]}")
rand = random.choice(hosts)
for file in files:
if file.find(rand[0]) != -1:
filename = file
break
print(Fore.GREEN + "\nSelected random:")
print(f"{Fore.GREEN}- {Fore.YELLOW}{rand[0]}: {rand[1]}")
print(f"{Fore.GREEN}- {Fore.YELLOW}{filename}")
print(f"\n{Fore.GREEN}Launching VPN...")
print(f"{Fore.RED}# {Fore.YELLOW}openvpn {filename}")
os.system(f"openvpn {filename}")