Files
ykxmz/_build/make_netcheck_bat.py
T
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

95 lines
3.0 KiB
Python
Raw 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 -*-
"""生成「网络自检.bat」。
真机问题:双击后终端一闪就没了,但直接双击 .py 正常。
根因和之前防火墙脚本一样 —— **裸 LF 换行**,cmd 逐段误读直接退出。
这里统一用 CRLF + GBK(chcp 936),并加三层防闪退:
1. 任何分支最后都 pause
2. python 找不到时给出明确提示,不是静默退出
3. where python 失败时再试 py(Windows 的 Python 启动器)
"""
from __future__ import annotations
import sys
from pathlib import Path
LINES = [
"@echo off",
"chcp 936 >nul",
"title 局域网遥控 . 网络自检",
'cd /d "%~dp0"',
"",
"echo ============================================================",
"echo 局域网遥控 . 网络自检",
"echo ============================================================",
"echo.",
'set "PY="',
"where python >nul 2>nul && set \"PY=python\"",
'if not defined PY where py >nul 2>nul && set "PY=py"',
"",
"if not defined PY goto NOPY",
'if not exist "%~dp0网络自检.py" goto NOFILE',
"",
f"%PY% \"%~dp0网络自检.py\"",
"goto END",
"",
":NOPY",
"echo [错误] 没找到 Python(python 和 py 都不存在)。",
"echo.",
"echo 网络自检本身需要 Python 才能跑。",
"echo 但通常你不需要它 —— 直接用「工具箱」里的:",
"echo 1. 启动被控端",
"echo 2. 一键修复防火墙",
"echo 这两步做完手表就应该能连上了。",
"echo.",
"goto END",
"",
":NOFILE",
"echo [错误] 同目录下没找到 网络自检.py",
"echo 请确认脚本和本 .bat 在同一个文件夹里。",
"echo.",
"",
":END",
"echo.",
"echo ------------------------------------------------------------",
"echo 自检结束。可以关闭本窗口。",
"echo ------------------------------------------------------------",
"pause",
]
def main() -> int:
target = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\tools\网络自检.bat")
target.parent.mkdir(parents=True, exist_ok=True)
with open(target, "w", encoding="gbk", newline="\r\n") as handle:
handle.write("\n".join(LINES) + "\n")
data = target.read_bytes()
crlf = data.count(b"\r\n")
lone = data.count(b"\n") - crlf
bom = data[:3] == b"\xef\xbb\xbf"
text = data.decode("gbk")
print(f" 路径: {target}")
print(f" 大小: {len(data)} 字节 CRLF={crlf} 裸LF={lone} BOM={bom}")
problems = []
if lone:
problems.append(f"存在 {lone} 处裸 LF")
if bom:
problems.append("存在 BOM")
for probe in ("网络自检", "pause", "chcp 936"):
if probe not in text:
problems.append(f"缺少「{probe}」")
if problems:
for item in problems:
print(f" [失败] {item}")
return 1
print(" 自检: 通过")
return 0
if __name__ == "__main__":
sys.exit(main())