feat(proxy): add geo country routing to proxy urls

This commit is contained in:
Anish Sarkar 2026-07-15 15:31:38 +05:30
parent 2265fcc513
commit 4fac1a20c3
3 changed files with 60 additions and 11 deletions

View file

@ -67,13 +67,23 @@ class ProxyProvider(ABC):
return None
return {"http": proxy_url, "https": proxy_url}
def get_sticky_proxy_url(self, session_id: str) -> str | None:
def get_geo_proxy_url(self, country: str | None = None) -> str | None:
"""Return a proxy URL pinned to ``country`` when supported.
Providers without vendor-specific country routing safely fall back to
their ordinary proxy URL.
"""
return self.get_proxy_url()
def get_sticky_proxy_url(
self, session_id: str, country: str | None = None
) -> str | None:
"""Return a proxy URL pinned to ``session_id`` when supported.
Providers without vendor-specific session routing safely fall back to
their ordinary proxy URL.
"""
return self.get_proxy_url()
return self.get_geo_proxy_url(country)
def get_location(self) -> str:
"""Return the proxy's configured exit region (e.g. ``"us"``), or ``""``.