feat: add simple license activation server
This commit is contained in:
1 parent
b2db5ed499
commit
05be83d289
17 files changed
+1053
-6
No files matched your search
@@ -8,7 +8,7 @@ from urllib.parse import parse_qs
|
||||
from douyin.core import path_config
|
||||
from douyin.license.license_manager import (
|
||||
get_license_status_payload,
|
||||
install_license_text,
|
||||
install_license_or_activate,
|
||||
)
|
||||
from gui.web_gui_pkg import (
|
||||
_wg_log,
|
||||
@@ -60,6 +60,17 @@ def _coerce_bool(value) -> bool:
|
||||
return bool(value)
|
||||
|
||||
|
||||
def _license_activation_settings() -> tuple[str, int]:
|
||||
cfg = read_config()
|
||||
section = cfg.get("license") if isinstance(cfg.get("license"), dict) else {}
|
||||
activation_url = str(section.get("activation_url") or "").strip()
|
||||
try:
|
||||
timeout_seconds = int(section.get("timeout_seconds") or 10)
|
||||
except (TypeError, ValueError):
|
||||
timeout_seconds = 10
|
||||
return activation_url, max(1, timeout_seconds)
|
||||
|
||||
|
||||
def _is_invalid_ports_spec(spec) -> bool:
|
||||
"""判断端口规格是否为明确非法输入。"""
|
||||
if spec is None:
|
||||
@@ -620,7 +631,12 @@ def handle_post(handler, u, runner, csrf_token: str) -> None:
|
||||
{"ok": False, "error": "missing license_text"},
|
||||
status=400,
|
||||
)
|
||||
status = install_license_text(text)
|
||||
activation_url, timeout_seconds = _license_activation_settings()
|
||||
status = install_license_or_activate(
|
||||
text,
|
||||
activation_url=activation_url,
|
||||
timeout_seconds=timeout_seconds,
|
||||
)
|
||||
payload = get_license_status_payload()
|
||||
payload.update(
|
||||
{"ok": status.ok, "reason": status.reason, "message": status.message}
|
||||
|
||||
Reference in new issue
Block a user