bugfix
This commit is contained in:
parent
de3da36959
commit
6b874dc50d
@ -12,6 +12,11 @@ import ssl
|
|||||||
import os
|
import os
|
||||||
from appPublic.log import exception, debug
|
from appPublic.log import exception, debug
|
||||||
|
|
||||||
|
use_socks5i_proxy=True
|
||||||
|
def set_use_socks5(use_or_not):
|
||||||
|
global use_socks5_proxy
|
||||||
|
use_socks5_proxy = use_or_not
|
||||||
|
|
||||||
async def liner(async_gen):
|
async def liner(async_gen):
|
||||||
remainer = b''
|
remainer = b''
|
||||||
async for chunk in async_gen:
|
async for chunk in async_gen:
|
||||||
@ -78,7 +83,7 @@ class StreamHttpClient:
|
|||||||
Makes an HTTP request and yields response chunks (streamed).
|
Makes an HTTP request and yields response chunks (streamed).
|
||||||
"""
|
"""
|
||||||
use_socks = url in self.socks_urls
|
use_socks = url in self.socks_urls
|
||||||
if use_socks:
|
if use_socks and use_socks5_proxy:
|
||||||
debug(f"🔁 Using SOCKS5 directly for: {url}")
|
debug(f"🔁 Using SOCKS5 directly for: {url}")
|
||||||
async for chunk in self._request_with_connector(
|
async for chunk in self._request_with_connector(
|
||||||
method, url,
|
method, url,
|
||||||
@ -99,6 +104,8 @@ class StreamHttpClient:
|
|||||||
yield chunk
|
yield chunk
|
||||||
except TimeoutError as e:
|
except TimeoutError as e:
|
||||||
debug(f"❌ Direct request failed: {e}, {headers=}, {data=},{params=}")
|
debug(f"❌ Direct request failed: {e}, {headers=}, {data=},{params=}")
|
||||||
|
if not use_socks5_proxy:
|
||||||
|
raise e
|
||||||
debug("🧦 Retrying with SOCKS5 proxy...")
|
debug("🧦 Retrying with SOCKS5 proxy...")
|
||||||
try:
|
try:
|
||||||
async for chunk in self._request_with_connector(
|
async for chunk in self._request_with_connector(
|
||||||
@ -114,6 +121,8 @@ class StreamHttpClient:
|
|||||||
raise e2
|
raise e2
|
||||||
except ClientConnectionError as e:
|
except ClientConnectionError as e:
|
||||||
debug(f"❌ Direct request failed: {e}, {headers=}, {data=},{params=}")
|
debug(f"❌ Direct request failed: {e}, {headers=}, {data=},{params=}")
|
||||||
|
if not use_socks5_proxy:
|
||||||
|
raise e
|
||||||
debug("🧦 Retrying with SOCKS5 proxy...")
|
debug("🧦 Retrying with SOCKS5 proxy...")
|
||||||
try:
|
try:
|
||||||
async for chunk in self._request_with_connector(
|
async for chunk in self._request_with_connector(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user