mirror of
https://github.com/TheSmallHanCat/flow2api.git
synced 2026-06-02 21:02:36 +08:00
feat:flow2api初版
This commit is contained in:
25
src/services/proxy_manager.py
Normal file
25
src/services/proxy_manager.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""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()
|
||||
Reference in New Issue
Block a user