Files
ykxmz/_build/fix_netcheck_and_add_lint.py
xmz7891 b62ac865ea ykxmz 1.5.0:修复手表端 TLS 证书校验 + MTU 修复网络稳定性
被控端
- 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%)
- 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败)
- 每分钟回头找局域网,自动切回快 400 倍的路径
- 画面心跳帧:静止时省流量,客户端仍知道流是活的
- 锁屏时给出可操作的提示

手表端
- 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException
- 连接错误翻译成人话(证书/时间/解析/超时分别提示)
- 经中转连上后用服务器报的地址刷新已配对记录
- 新增局域网连接页面、服务器延迟检测

服务器端
- 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502)
- 网络调优脚本 net-tune.sh(开机自动应用)
- 管理页:批量删除、网络体检、下载区
- 隧道改 HTTP/2 + 双连接

文档
- 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
2026-10-06 19:01:05 +08:00

88 lines
3.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""两件事:
1. 修 netcheck.py 结尾的坏代码
文件末尾是 `if __name__ == "__main__": sys.exit(main())`,
但这个文件里根本没有 main() —— 它的入口是 run_check()。
通过 ykxmz.exe --netcheck 走不到这段(那走的是 run_check),
但直接 `python netcheck.py` 就会 NameError 崩掉。
2. 把 pyflakes 静态检查加进 verify_all
这次的 DEFAULT_RELAY_URL 崩溃,自带的回归全绿、编码审计也过,
因为它是"运行到那行才炸"。pyflakes 静态扫一遍就能发现。
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
NETCHECK = ROOT / "windows" / "lanremote" / "netcheck.py"
VERIFY = ROOT / "_tests" / "verify_all.ps1"
NET_OLD = '''if __name__ == "__main__":
sys.exit(main())'''
NET_NEW = '''if __name__ == "__main__":
# 直接 `python netcheck.py [秒数]` 也能用。
# 原来这里写的是 main(),但本文件没有 main() ——
# 入口是 run_check(),直接跑会 NameError。
sys.exit(run_check(int(sys.argv[1]) if len(sys.argv) > 1 else 90))'''
STAGE_ANCHOR = "# ---------------------------------------------------------------- 4b"
STAGE_NEW = """# ---------------------------------------------------------------- 3b
Banner "3b/7 Python 静态检查(pyflakes)"
# 这一层能抓到"运行到某行才炸"的问题。
# 踩过的坑:check_code_available() 用了没导入的 DEFAULT_RELAY_URL,
# 结果装到最后一步弹 NameError —— 而回归全绿、编码审计也过。
& python (Join-Path $root "_tests\\audit_python_names.py") 2>&1 |
Select-Object -Last 4
Record "Python 静态检查" ($LASTEXITCODE -eq 0)
""" + STAGE_ANCHOR
def main() -> int:
ok = True
# ---- 1. netcheck ----
text = NETCHECK.read_text(encoding="utf-8")
if "sys.exit(run_check(" in text:
print(" netcheck.py 已经修过")
elif NET_OLD in text:
text = text.replace(NET_OLD, NET_NEW, 1)
NETCHECK.write_text(text, encoding="utf-8", newline="\n")
print(" netcheck.py:结尾改成调 run_check()")
else:
print(" [失败] netcheck.py 锚点没找到")
ok = False
# ---- 2. verify_all 加阶段 ----
raw = VERIFY.read_bytes()
had_bom = raw.startswith(b"\xef\xbb\xbf")
text = raw.decode("utf-8-sig")
if "audit_python_names" in text:
print(" verify_all:已经加过静态检查阶段")
elif STAGE_ANCHOR in text:
text = text.replace(STAGE_ANCHOR, STAGE_NEW, 1)
VERIFY.write_bytes((b"\xef\xbb\xbf" if had_bom else b"")
+ text.replace("\r\n", "\n").encode("utf-8"))
print(f" verify_all:加了阶段 3b(BOM {'保留' if had_bom else '无'})")
else:
print(" [失败] verify_all 锚点没找到")
ok = False
import ast
try:
ast.parse(NETCHECK.read_text(encoding="utf-8"))
print(" netcheck.py 语法 OK")
except SyntaxError as exc:
print(f" netcheck.py 语法错误: {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())