type: 收窄豆鱼服务层类型
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
|
||||
import threading
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from .proxy_resolver import ProxyResolver
|
||||
@@ -28,8 +26,8 @@ class ProxyFetcher:
|
||||
self,
|
||||
api_url: str,
|
||||
whitelist_platform: str = "xiequ",
|
||||
whitelist_credentials: dict = None,
|
||||
stop_event: Optional[threading.Event] = None,
|
||||
whitelist_credentials: dict | None = None,
|
||||
stop_event: threading.Event | None = None,
|
||||
):
|
||||
self.api_url = api_url
|
||||
self.stop_event = stop_event
|
||||
@@ -66,7 +64,7 @@ class ProxyFetcher:
|
||||
return True, f"出口 IP {local_ip} 已同步: {msg}"
|
||||
return False, f"出口 IP {local_ip} 同步失败: {msg}"
|
||||
|
||||
def fetch_new_proxy(self, max_attempts: int = 3) -> Optional[str]:
|
||||
def fetch_new_proxy(self, max_attempts: int = 3) -> str | None:
|
||||
"""从代理 API 获取 1 个可用代理,失败返回 None。
|
||||
|
||||
不主动检测/同步本地出口 IP;如果代理 API 返回"白名单错误",
|
||||
@@ -115,7 +113,7 @@ class ProxyFetcher:
|
||||
def get_proxy_fetcher(
|
||||
api_url: str,
|
||||
whitelist_platform: str = "xiequ",
|
||||
whitelist_credentials: dict = None,
|
||||
whitelist_credentials: dict | None = None,
|
||||
) -> ProxyFetcher:
|
||||
"""获取代理获取器实例。"""
|
||||
return ProxyFetcher(
|
||||
|
||||
Reference in New Issue
Block a user