修改默认值
This commit is contained in:
1 parent
a1867fd03e
commit
6faee25ba7
4 files changed
+38
-19
No files matched your search
+19
-9
@@ -25,6 +25,7 @@ from maintain import db
|
||||
from maintain.batch_register import run_batch
|
||||
from maintain.runtime_log import rtlog, runtime_log_path
|
||||
from maintain.cliproxy_mgmt import (
|
||||
management_api_root,
|
||||
probe_auth_file_models_for_oauth_stem,
|
||||
verify_management_auth,
|
||||
)
|
||||
@@ -240,10 +241,13 @@ def api_overview():
|
||||
"dingtalk_webhook": settings.get("dingtalk_webhook", ""),
|
||||
"dingtalk_secret": settings.get("dingtalk_secret", ""),
|
||||
"cliproxy_management_base": settings.get(
|
||||
"cliproxy_management_base", ""
|
||||
"cliproxy_management_base", db.DEFAULT_CLIPROXY_BASE
|
||||
),
|
||||
"cliproxy_management_key_set": bool(
|
||||
settings.get("cliproxy_management_key", "").strip()
|
||||
(
|
||||
settings.get("cliproxy_management_key", "").strip()
|
||||
or db.DEFAULT_CLIPROXY_KEY
|
||||
)
|
||||
),
|
||||
"cliproxy_probe_timeout_sec": settings.get(
|
||||
"cliproxy_probe_timeout_sec", "30"
|
||||
@@ -463,8 +467,8 @@ def _probe_error_skip_delete(err: str) -> bool:
|
||||
|
||||
|
||||
def _run_cliproxy_inspect_worker(task_id: int, source: str) -> None:
|
||||
base = db.get_setting("cliproxy_management_base", "").strip()
|
||||
key = db.get_setting("cliproxy_management_key", "").strip()
|
||||
base = db.get_setting("cliproxy_management_base", db.DEFAULT_CLIPROXY_BASE).strip()
|
||||
key = db.get_setting("cliproxy_management_key", db.DEFAULT_CLIPROXY_KEY).strip()
|
||||
if not base or not key:
|
||||
rtlog().warning(
|
||||
"[inspect#%s] %s 中止: 未配置管理地址或密钥", task_id, source
|
||||
@@ -624,8 +628,8 @@ def _run_cliproxy_sweeper_worker(
|
||||
finalize_task: bool = True,
|
||||
) -> dict[str, int | str]:
|
||||
"""按 usage 连续失败阈值清理 auth-files 里的失效 JSON。"""
|
||||
base = db.get_setting("cliproxy_management_base", "").strip()
|
||||
key = db.get_setting("cliproxy_management_key", "").strip()
|
||||
base = db.get_setting("cliproxy_management_base", db.DEFAULT_CLIPROXY_BASE).strip()
|
||||
key = db.get_setting("cliproxy_management_key", db.DEFAULT_CLIPROXY_KEY).strip()
|
||||
if not base or not key:
|
||||
msg = "请先在「配置编辑」填写 Cliproxy 管理地址与密钥"
|
||||
if finalize_task:
|
||||
@@ -641,6 +645,12 @@ def _run_cliproxy_sweeper_worker(
|
||||
db.get_setting("cliproxy_sweeper_allow_name_fallback", "1").strip() == "1"
|
||||
)
|
||||
apply_mode = run_mode == "delete"
|
||||
mgmt_root = management_api_root(base)
|
||||
if not mgmt_root:
|
||||
msg = "管理端地址无效,请检查 cliproxy_management_base"
|
||||
if finalize_task:
|
||||
db.update_task(task_id, status="error", message=msg)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
rtlog().info(
|
||||
"[sweeper#%s] %s 开始 base=%s threshold=%s mode=%s",
|
||||
@@ -660,7 +670,7 @@ def _run_cliproxy_sweeper_worker(
|
||||
run_started_epoch = int(time.time())
|
||||
|
||||
usage_obj = cliproxy_sweeper.request_json_or_die(
|
||||
base_url=base.rstrip("/"),
|
||||
base_url=mgmt_root,
|
||||
path="/usage",
|
||||
method="GET",
|
||||
headers=headers,
|
||||
@@ -673,7 +683,7 @@ def _run_cliproxy_sweeper_worker(
|
||||
run_started_epoch=run_started_epoch,
|
||||
)
|
||||
auth_files_obj = cliproxy_sweeper.request_json_or_die(
|
||||
base_url=base.rstrip("/"),
|
||||
base_url=mgmt_root,
|
||||
path="/auth-files",
|
||||
method="GET",
|
||||
headers=headers,
|
||||
@@ -700,7 +710,7 @@ def _run_cliproxy_sweeper_worker(
|
||||
file_name = str(c.get("file_name", ""))
|
||||
encoded_name = urllib.parse.quote(file_name, safe="")
|
||||
code, _ = cliproxy_sweeper.http_request_with_retry(
|
||||
base_url=base.rstrip("/"),
|
||||
base_url=mgmt_root,
|
||||
path=f"/auth-files?name={encoded_name}",
|
||||
method="DELETE",
|
||||
headers=headers,
|
||||
|
||||
Reference in new issue
Block a user