-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaioproxy_check_forwarded.py
More file actions
50 lines (37 loc) · 1.32 KB
/
Copy pathaioproxy_check_forwarded.py
File metadata and controls
50 lines (37 loc) · 1.32 KB
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
"""Check a forwarded proxy by dispatching multiple async requests."""
import asyncio
from utils import get_starship
async def main():
"""Run proxy checks and print aggregate results."""
tasks = []
proxy_list = []
oks = 0
bads = 0
forwarded_proxy = 'http://login:password@host:port'
retries_count = 500
counter = 0
while counter < retries_count:
proxy_list.append(forwarded_proxy)
counter += 1
for proxy in proxy_list:
tasks.append(get_starship(proxy))
counter += 1
results = await asyncio.gather(*tasks)
for result in results:
if result['status']:
message = result.get('message')
if isinstance(message, dict) and 'ip' in message:
print(f"OK: {result['proxy']}: {message}")
oks += 1
else:
print(f"BAD: {result['proxy']}: {message}")
bads += 1
else:
print(f"BAD: {result['proxy']}: {result['message']}")
bads += 1
oks_percent = round(oks / len(proxy_list) * 100)
bads_percent = round(bads / len(proxy_list) * 100)
print(f"OKS: {oks}({oks_percent}%) / BADS: {bads}({bads_percent}%)")
# Not used in Python 3.10 or later
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())