workaround for smartproxy bug
This commit is contained in:
parent
be71e0c5f8
commit
c7b68e9e04
|
@ -8,7 +8,7 @@ import time
|
||||||
import requests
|
import requests
|
||||||
from redis import Redis
|
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 .pid import zombie_slayer
|
||||||
from .redis_cycle import add_backend_cycler
|
from .redis_cycle import add_backend_cycler
|
||||||
from .smartproxy import transform_smartproxy
|
from .smartproxy import transform_smartproxy
|
||||||
|
@ -46,10 +46,14 @@ def validate_proxies():
|
||||||
if pxy in SMARTPROXY_POOL:
|
if pxy in SMARTPROXY_POOL:
|
||||||
smartproxy = True
|
smartproxy = True
|
||||||
r = requests.get(IP_CHECKER, proxies={'http': transform_smartproxy(pxy), 'https': transform_smartproxy(pxy)}, timeout=15)
|
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:
|
else:
|
||||||
r = requests.get(IP_CHECKER, proxies={'http': pxy, 'https': pxy}, timeout=15)
|
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:
|
if r.status_code != 200:
|
||||||
logger.debug(f'PROXY TEST failed - {pxy} - got code {r.status_code}')
|
logger.debug(f'PROXY TEST failed - {pxy} - got code {r.status_code}')
|
||||||
|
|
|
@ -13,6 +13,10 @@ PROXY_POOL = [
|
||||||
SMARTPROXY_USER = 'example'
|
SMARTPROXY_USER = 'example'
|
||||||
SMARTPROXY_PASS = 'password'
|
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
|
# Some domains just don't work through SmartProxy. Domains in this list are routed though
|
||||||
# your proxies, not SmartProxy.
|
# your proxies, not SmartProxy.
|
||||||
BYPASS_SMARTPROXY_DOMAINS = [
|
BYPASS_SMARTPROXY_DOMAINS = [
|
||||||
|
|
|
@ -140,6 +140,7 @@ class ProxyLoadBalancer(TcpUpstreamConnectionHandler, HttpProxyBasePlugin):
|
||||||
self._metadata = [
|
self._metadata = [
|
||||||
host, port, path, request.method,
|
host, port, path, request.method,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Queue original request optionally with auth headers to upstream proxy
|
# Queue original request optionally with auth headers to upstream proxy
|
||||||
if self._endpoint.has_credentials:
|
if self._endpoint.has_credentials:
|
||||||
assert self._endpoint.username and self._endpoint.password
|
assert self._endpoint.username and self._endpoint.password
|
||||||
|
|
Loading…
Reference in New Issue