feat: 维护中国代理池并支持账号自动均匀使用

This commit is contained in:
2026-11-15 02:18:17 +08:00
parent aa26d00c60
commit ce2d6e08dd
20 changed files with 1733 additions and 162 deletions
+19
View File
@@ -26,6 +26,8 @@ from admin.users import (
)
from euniv.courses import course_page, request_course_sync_now
from euniv.db import get_db
from euniv.proxy_pool import page as proxy_page
from euniv.proxy_pool import request_refresh as request_proxy_refresh
public_router = APIRouter()
admin_router = APIRouter(prefix="/api/admin")
@@ -129,6 +131,23 @@ def get_courses(
return course_page(db, q, start, bounded, kind)
@admin_router.get("/proxies")
def get_proxies(
q: str = "",
status: str = "",
offset: int = 0,
limit: int = 50,
db: Session = Depends(get_db),
_: str = Depends(require_admin),
) -> dict:
return proxy_page(db, q, status, offset, limit)
@admin_router.post("/proxies/refresh")
def post_proxies_refresh(_: str = Depends(require_admin)) -> dict:
return request_proxy_refresh()
@admin_router.get("/users")
def get_users(db: Session = Depends(get_db), _: str = Depends(require_admin)) -> list[dict]:
return list_users(db)
+2 -2
View File
@@ -15,7 +15,7 @@ from euniv.course_workers import CourseWorkersError
from euniv.course_workers import apply as apply_workers
from euniv.course_workers import of as workers_of
from euniv.course_workers import view_of as workers_view
from euniv.proxy import ProxyError, apply, clear, summary_of, url_of, view_of
from euniv.proxy import ProxyError, apply, clear, enabled, summary_of, url_of, view_of
from euniv.study_window import StudyWindowError
from euniv.study_window import apply as apply_start
from euniv.study_window import label_of as start_label
@@ -73,7 +73,7 @@ def list_users(db: Session) -> list[dict]:
"last_refresh_at": _iso_time(account.last_refresh_at),
"credential_valid": _optional_bool(account.credential_valid),
"month_hours": account.month_hours or "",
"has_proxy": bool(account.proxy_scheme and account.proxy_host and account.proxy_port),
"has_proxy": enabled(account),
"proxy": summary_of(account),
"study_start": start_label(account),
"study_start_day": int(account.study_start_day or 1),