Files
ykxmz/_build/fix_admin_tests2.py
xmz7891 566d9e384f 阶段1+2:恢复 HTTP/2 加速 + 重做官网
阶段1 网络加速
- 发现隧道在跑 QUIC(ExecStart 丢了 --protocol http2),
  实测 QUIC 可用率 48% vs HTTP/2 80%+,是重大性能回退。
  恢复后公网延迟从 4141ms 降到 690ms(快 6 倍),可用率 92%。
- 优选 IP 结论:无效。hosts 覆盖确实生效了(日志里连的就是指定 IP),
  但落点仍是 lax —— 运营商把所有 Cloudflare anycast 都路由到美西。
  已清掉这段无效配置。
- BBR 不可用:设备是自定义内核 6.4.0-rc4-jsbsbxjxh66,
  没编 tcp_bbr 模块也没配置项。改用 cubic + 调优:
  TCP 缓冲 4MB、tcp_fastopen=3、tcp_slow_start_after_idle=0
  (长轮询场景关键)、tcp_tw_reuse=1。

阶段2 官网重做
- 拆出独立模块 relay/landing.py(relay.py 已两千多行,
  再塞 HTML 没法看)
- 信息结构参考成熟产品站:吸顶导航 / Hero / 九宫格功能 /
  三步上手 / 下载 / FAQ / 页脚
- 保持白色简洁:底白、浅灰面板、细边框、大量留白
- logo 用内联 SVG(ICO 放 img 里实测是破图)
- 管理入口从官网移除(管理不对外开放)

过程中被自己的测试抓到两个 bug:
- 模块叫 site.py 会和 Python 标准库重名,import site 拿到的是标准库
- _logo() 里把 % 格式化和字符串拼接混用,直接抛 TypeError
2026-10-06 23:53:19 +08:00

76 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
r'''管理页路径变了,相关测试要跟着改。
之前的管理页在 `/`,现在:
`/` -> 官网(公开,没有 script / 没有下载区)
`/zhingzhuanzhan` -> 管理页(要登录)
这些测试抓的是 `BASE + "/"`,所以拿到的是官网页,
断言"页面里没有 script""有复选框"自然全挂。
同时登录表单现在多了账号字段,测试的 POST body 也要补上。
'''
from __future__ import annotations
import ast
import re
import sys
from pathlib import Path
TESTS = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_tests")
ADMIN_FILES = [
"test_admin_js.py", "test_admin_batch_delete.py",
"test_admin_delete.py", "test_admin_button.py",
"test_admin_netcheck.py", "test_relay_admin_login.py",
]
ADMIN = "/zhingzhuanzhan"
def main() -> int:
for name in ADMIN_FILES:
path = TESTS / name
if not path.is_file():
print(f" [跳过] {name} 不存在")
continue
text = path.read_text(encoding="utf-8")
original = text
# 抓页面:BASE + "/" -> BASE + "/zhingzhuanzhan"
text = re.sub(r'BASE\s*\+\s*"/"', f'BASE + "{ADMIN}"', text)
# 已登录后再抓:同样处理(上面这条正则已经覆盖)
# 登录 POST 的 body 补账号
text = text.replace('data=b"password=', 'data=b"username=xmz7891&password=')
text = text.replace('data="password=', 'data="username=xmz7891&password=')
text = text.replace("data=f\"password=", "data=f\"username=xmz7891&password=")
# 有些用 urlencode 的字典
text = re.sub(r'(\{"password":\s*)', r'{"username": "xmz7891", \1', text)
if text != original:
path.write_text(text, encoding="utf-8", newline="\n")
n = original.count('BASE + "/"')
print(f" {name}: 改了 {n} 处页面路径 / 登录表单")
else:
print(f" {name}: 无需改动")
print()
print(" 语法检查:")
ok = True
for name in ADMIN_FILES:
path = TESTS / name
if not path.is_file():
continue
try:
ast.parse(path.read_text(encoding="utf-8"))
except SyntaxError as exc:
print(f" [失败] {name}: 行 {exc.lineno}: {exc.msg}")
ok = False
print(" 全部 OK" if ok else " 有错")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())