first commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""Shared HTTP client options (optional SOCKS5 proxy)."""
|
||||
|
||||
from .config import settings
|
||||
|
||||
|
||||
def proxy_for(target: str) -> str | None:
|
||||
"""
|
||||
target: 'binance' | 'wecom'
|
||||
Returns proxy URL when enabled and scope matches.
|
||||
"""
|
||||
if not settings.proxy_enabled or not settings.proxy_url.strip():
|
||||
return None
|
||||
scope = settings.proxy_for.lower()
|
||||
if scope == "all" or scope == target:
|
||||
return settings.proxy_url.strip()
|
||||
return None
|
||||
|
||||
|
||||
def httpx_client_kwargs(target: str, **extra) -> dict:
|
||||
kwargs = dict(extra)
|
||||
proxy = proxy_for(target)
|
||||
if proxy:
|
||||
kwargs["proxy"] = proxy
|
||||
return kwargs
|
||||
Reference in New Issue
Block a user