增加了代理平台和日志

This commit is contained in:
yml2213
2026-06-24 14:22:29 +08:00
parent 0d03b2c242
commit 83345dfdc5
21 changed files with 1134 additions and 444 deletions
+26 -6
View File
@@ -7,9 +7,12 @@ from sqlalchemy.orm import Session
from ..database import get_db
from ..models import User
from ..schemas import ProxyConfigOut, ProxyConfigUpdate
from ..schemas import ProxyConfigOut, ProxyConfigUpdate, PlatformInfo, PlatformFieldDef
from ..deps import require_permission, authenticate_websocket
from ..services.proxy_service import proxy_service
from core.douyu.proxy_platforms import (
get_platform_names, get_platform_labels, get_credential_fields,
)
router = APIRouter(prefix="/api/proxy", tags=["代理与白名单"])
@@ -30,17 +33,34 @@ def update_proxy_config(
):
return proxy_service.update_config(
db,
enabled=req.enabled,
api_url=req.api_url,
http=req.http,
https=req.https,
whitelist_enabled=req.whitelist_enabled,
enabled=req.enabled if req.enabled is not None else False,
api_url=req.api_url if req.api_url is not None else "",
http=req.http if req.http is not None else "",
https=req.https if req.https is not None else "",
whitelist_enabled=req.whitelist_enabled if req.whitelist_enabled is not None else False,
whitelist_platform=req.whitelist_platform or "xiequ",
whitelist_credentials=req.whitelist_credentials,
whitelist_uid=req.whitelist_uid,
whitelist_ukey=req.whitelist_ukey,
current_user=current,
)
@router.get("/platforms", response_model=list[PlatformInfo])
def list_platforms():
"""获取所有可用的代理白名单平台及其凭据字段定义。"""
labels = get_platform_labels()
result = []
for name in get_platform_names():
fields = get_credential_fields(name)
result.append(PlatformInfo(
name=name,
label=labels.get(name, name),
credential_fields=[PlatformFieldDef(**f) for f in fields],
))
return result
# ---- WebSocket 日志推送 ----
@router.websocket("/ws/test/{test_id}")