Files
2026-05-22 13:06:42 +08:00

25 lines
662 B
Python

"""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