fix: require license gate before gui entry

This commit is contained in:
Your Name committed 2026-06-28 08:50:05 +08:00
1 parent 407c3b37c2
commit f5a77867ee
8 files changed
+268 -9

No files matched your search

+14
View File
@@ -12,6 +12,7 @@ from douyin.license.license_manager import (
get_license_status_payload,
install_license_or_activate,
)
from gui.web_gui_pkg.license_gate import render_license_gate_html
from gui.web_gui_pkg import (
_wg_log,
find_adb_executable,
@@ -104,6 +105,16 @@ def _license_gate_payload() -> dict:
return payload
def _send_html(handler, html: str, status: int = 200) -> None:
data = html.encode("utf-8")
handler.send_response(status)
handler.send_header("Content-Type", "text/html; charset=utf-8")
handler.send_header("Content-Length", str(len(data)))
handler.send_header("Cache-Control", "no-store")
handler.end_headers()
handler.wfile.write(data)
def _is_invalid_ports_spec(spec) -> bool:
"""判断端口规格是否为明确非法输入。"""
if spec is None:
@@ -369,6 +380,9 @@ def handle_get(handler, u, runner, csrf_token: str) -> None:
handler.send_error(HTTPStatus.FORBIDDEN)
return
if u.path in {"/", "/index.html"} and not check_license().ok:
return _send_html(handler, render_license_gate_html(csrf_token))
handler._serve_static(u.path)