misc: simplify tor proxy URL to avoid circuit exhaustion

This commit is contained in:
Username
2026-01-08 09:05:03 +01:00
parent 39731e25b3
commit 721a602dd9

11
misc.py
View File

@@ -187,12 +187,9 @@ def categorize_error(exc):
def tor_proxy_url(torhost):
"""Generate Tor SOCKS5 proxy URL with random credentials for circuit isolation.
"""Generate Tor SOCKS5 proxy URL.
Tor treats different username:password as separate streams, using different
circuits. This ensures each connection gets a fresh circuit.
Uses no auth to allow Tor to reuse circuits naturally, avoiding
circuit exhaustion from IsolateSOCKSAuth behavior.
"""
chars = string.ascii_lowercase + string.digits
user = ''.join(random.choice(chars) for _ in range(8))
passwd = ''.join(random.choice(chars) for _ in range(8))
return 'socks5://%s:%s@%s' % (user, passwd, torhost)
return 'socks5://%s' % torhost