minor improvements

This commit is contained in:
Vladless
2025-02-21 22:36:03 +03:00
parent c9e791fa76
commit 769f5eaf9a
18 changed files with 2459 additions and 1990 deletions
+4 -4
View File
@@ -18,15 +18,15 @@ PING_SEMAPHORE = asyncio.Semaphore(3)
async def ping_server(server_ip: str) -> bool:
"""Пингует сервер через ICMP или TCP 443, если ICMP недоступен."""
"""Пингует сервер через ICMP или TCP 443, если ICMP недоступен или возникает ошибка."""
async with PING_SEMAPHORE:
try:
response = ping(server_ip, timeout=3)
return response is not None and response is not False
except PermissionError:
if response is not None and response is not False:
return True
return await check_tcp_connection(server_ip, 443)
except Exception:
return False
return await check_tcp_connection(server_ip, 443)
async def check_tcp_connection(host: str, port: int) -> bool: