44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
import os
|
|
import random
|
|
from typing import List, Dict, Optional
|
|
|
|
# Verified live PrivadoVPN SOCKS5 server endpoints
|
|
# Note: uses socks5h:// for remote DNS resolution to prevent DNS leaks and connection drops
|
|
PRIVADO_SOCKS5_HOSTS = [
|
|
"jfk.socks.privado.io", # New York JFK
|
|
"ams.socks.privado.io", # Amsterdam
|
|
]
|
|
|
|
DEFAULT_PRIVADO_USER = "nhqyqsx21846"
|
|
DEFAULT_PRIVADO_PASS = "umjy1xyucnch"
|
|
DEFAULT_PORT = 1080
|
|
|
|
def get_privado_proxy_list() -> List[str]:
|
|
"""
|
|
Builds socks5h:// proxy URLs for all verified Privado servers.
|
|
"""
|
|
user = os.getenv("PRIVADO_USER", DEFAULT_PRIVADO_USER).strip()
|
|
pwd = os.getenv("PRIVADO_PASS", DEFAULT_PRIVADO_PASS).strip()
|
|
|
|
custom_proxy = os.getenv("SOCKS5_PROXY") or os.getenv("PROXY_URL") or ""
|
|
if custom_proxy:
|
|
proxies = [p.strip() for p in custom_proxy.split(",") if p.strip()]
|
|
if proxies:
|
|
return proxies
|
|
|
|
proxy_list = []
|
|
for host in PRIVADO_SOCKS5_HOSTS:
|
|
proxy_list.append(f"socks5h://{user}:{pwd}@{host}:{DEFAULT_PORT}")
|
|
return proxy_list
|
|
|
|
def get_random_privado_proxy() -> Optional[str]:
|
|
proxies = get_privado_proxy_list()
|
|
if proxies:
|
|
return random.choice(proxies)
|
|
return None
|
|
|
|
def get_rotating_proxy_dict() -> Dict[str, str]:
|
|
proxy = get_random_privado_proxy()
|
|
if proxy:
|
|
return {"http": proxy, "https": proxy}
|
|
return {}
|