Upload files to "routes"

This commit is contained in:
2026-07-24 15:35:19 +00:00
parent 40f106fd51
commit c128e582ab
5 changed files with 1417 additions and 0 deletions

42
routes/admin_ws.py Normal file
View File

@@ -0,0 +1,42 @@
import json
from core.state import db
from routes.portal import _get_admin_account, _has_any_admin_scope
def _send(ws, msg: dict) -> None:
try:
ws.send(json.dumps(msg))
except Exception:
pass
def register_admin_ws(sock) -> None:
@sock.route("/admin/ws")
def admin_ws_handler(ws):
account, scopes = _get_admin_account()
if not account or not _has_any_admin_scope(scopes):
ws.close()
return
import core.admin_ws as awr
awr.register(ws)
try:
from routes.misc import get_sanitize_log
from core.anticheat import get_suspects
suspects = get_suspects()
_send(ws, {"type": "init", "sanitize_log": get_sanitize_log(), "suspects": suspects})
except Exception as e:
print(f"[AdminWS] init error: {e}")
try:
while True:
msg = ws.receive(timeout=30)
if msg is None:
break
except Exception:
pass
finally:
awr.unregister(ws)