mirror of
https://github.com/TheSmallHanCat/flow2api.git
synced 2026-05-06 22:13:48 +08:00
26 lines
858 B
Python
26 lines
858 B
Python
"""Proxy management module"""
|
|
from typing import Optional
|
|
from ..core.database import Database
|
|
from ..core.models import ProxyConfig
|
|
|
|
class ProxyManager:
|
|
"""Proxy configuration manager"""
|
|
|
|
def __init__(self, db: Database):
|
|
self.db = db
|
|
|
|
async def get_proxy_url(self) -> Optional[str]:
|
|
"""Get proxy URL if enabled, otherwise return None"""
|
|
config = await self.db.get_proxy_config()
|
|
if config and config.enabled and config.proxy_url:
|
|
return config.proxy_url
|
|
return None
|
|
|
|
async def update_proxy_config(self, enabled: bool, proxy_url: Optional[str]):
|
|
"""Update proxy configuration"""
|
|
await self.db.update_proxy_config(enabled, proxy_url)
|
|
|
|
async def get_proxy_config(self) -> ProxyConfig:
|
|
"""Get proxy configuration"""
|
|
return await self.db.get_proxy_config()
|