workaround for smartproxy bug

This commit is contained in:
Cyberes 2024-02-12 13:41:22 -07:00
parent be71e0c5f8
commit c7b68e9e04
3 changed files with 12 additions and 3 deletions

View File

@ -8,7 +8,7 @@ import time
import requests
from redis import Redis
from .config import PROXY_POOL, SMARTPROXY_POOL, IP_CHECKER, MAX_PROXY_CHECKERS
from .config import PROXY_POOL, SMARTPROXY_POOL, IP_CHECKER, MAX_PROXY_CHECKERS, SMARTPROXY_BV3HI_FIX
from .pid import zombie_slayer
from .redis_cycle import add_backend_cycler
from .smartproxy import transform_smartproxy
@ -46,10 +46,14 @@ def validate_proxies():
if pxy in SMARTPROXY_POOL:
smartproxy = True
r = requests.get(IP_CHECKER, proxies={'http': transform_smartproxy(pxy), 'https': transform_smartproxy(pxy)}, timeout=15)
# r_test = requests.get(TEST_LARGE_FILE, proxies={'http': transform_smartproxy(pxy), 'https': transform_smartproxy(pxy)}, timeout=15)
# TODO: remove when fixed
r2 = requests.get(SMARTPROXY_BV3HI_FIX, proxies={'http': transform_smartproxy(pxy), 'https': transform_smartproxy(pxy)}, timeout=15)
if r2.status_code != 200:
logger.debug(f'PROXY BV3HI TEST failed - {pxy} - got code {r2.status_code}')
return
else:
r = requests.get(IP_CHECKER, proxies={'http': pxy, 'https': pxy}, timeout=15)
# r_test = requests.get(TEST_LARGE_FILE, proxies={'http': pxy, 'https': pxy}, timeout=15)
if r.status_code != 200:
logger.debug(f'PROXY TEST failed - {pxy} - got code {r.status_code}')

View File

@ -13,6 +13,10 @@ PROXY_POOL = [
SMARTPROXY_USER = 'example'
SMARTPROXY_PASS = 'password'
# Fix the 503 error on some SmartProxy hosts.
# TODO: remove when fixed.
SMARTPROXY_BV3HI_FIX = 'https://files.catbox.moe/c8p1q6.png'
# Some domains just don't work through SmartProxy. Domains in this list are routed though
# your proxies, not SmartProxy.
BYPASS_SMARTPROXY_DOMAINS = [

View File

@ -140,6 +140,7 @@ class ProxyLoadBalancer(TcpUpstreamConnectionHandler, HttpProxyBasePlugin):
self._metadata = [
host, port, path, request.method,
]
# Queue original request optionally with auth headers to upstream proxy
if self._endpoint.has_credentials:
assert self._endpoint.username and self._endpoint.password