- proxy_service.py: 将requests和WhitelistManager改为函数内延迟import, 避免启动时加载不需要的依赖;移除未使用的get_exit_ip_via_proxy导入 - account_service.py: 移除未使用的func、joinedload、AuditLog、 user_has_permission顶层导入
21 lines
571 B
Python
21 lines
571 B
Python
"""代理模块使用的白名单适配器。"""
|
|
|
|
from typing import Optional
|
|
|
|
from .whitelist import WhitelistManager, get_local_exit_ip
|
|
|
|
|
|
class DouyuWhitelistSyncer:
|
|
"""把白名单 API 隔离成代理解析流程可调用的适配器。"""
|
|
|
|
def __init__(self, uid: str, ukey: str):
|
|
self.uid = uid
|
|
self.ukey = ukey
|
|
|
|
def sync_ip(self, ip: str) -> tuple[bool, str]:
|
|
manager = WhitelistManager(self.uid, self.ukey)
|
|
return manager.sync_ip(ip)
|
|
|
|
def get_local_exit_ip(self) -> Optional[str]:
|
|
return get_local_exit_ip()
|