mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 16:00:43 +00:00
被控端 - 修复 MTU 问题:夹 MSS + 路径 MTU 探测(公网可用率 48% -> 100%) - 复用 HTTP 连接(免掉每次新建 TLS 的 30% 握手失败) - 每分钟回头找局域网,自动切回快 400 倍的路径 - 画面心跳帧:静止时省流量,客户端仍知道流是活的 - 锁屏时给出可操作的提示 手表端 - 内置 GTS Root R4 / GlobalSign Root CA,修 SSLHandshakeException - 连接错误翻译成人话(证书/时间/解析/超时分别提示) - 经中转连上后用服务器报的地址刷新已配对记录 - 新增局域网连接页面、服务器延迟检测 服务器端 - 支持 chunked 请求体(修每 16 秒一次的连接错乱与大面积 502) - 网络调优脚本 net-tune.sh(开机自动应用) - 管理页:批量删除、网络体检、下载区 - 隧道改 HTTP/2 + 双连接 文档 - 许可协议 / 安装前必读 / 安装后须知(作者:小麦子)
98 lines
2.9 KiB
Python
98 lines
2.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""生成「网络自检.bat」—— 纯 ASCII,彻底避开编码坑。
|
|
|
|
真机问题:双击后中文全是乱码。
|
|
根因:.bat 用 GBK 存盘 + chcp 936,但用户机器上控制台代码页并不是 936
|
|
(可能开了「Beta: 使用 UTF-8 提供全球语言支持」),
|
|
于是 bat 自己的中文和 Python 的输出都花了。
|
|
|
|
彻底方案:
|
|
* **bat 里一个中文都不留**(纯 ASCII),只负责设 UTF-8 代码页并调用 Python
|
|
* 中文全部交给 Python 输出,Python 自己把控制台设成 65001
|
|
* 脚本名用通配符找(*.py),这样中文文件名也不影响纯 ASCII 的 bat
|
|
|
|
这样无论系统默认代码页是什么都不会乱。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
LINES = [
|
|
"@echo off",
|
|
"chcp 65001 >nul 2>nul",
|
|
"title LAN Remote - Network Self Check",
|
|
'cd /d "%~dp0"',
|
|
"",
|
|
"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",
|
|
"",
|
|
"rem Find the single .py next to this file (its name may be Chinese,",
|
|
"rem which would break this pure-ASCII launcher if hard-coded).",
|
|
'set "SCRIPT="',
|
|
'for %%f in ("%~dp0*.py") do if not defined SCRIPT set "SCRIPT=%%~ff"',
|
|
"if not defined SCRIPT goto NOFILE",
|
|
"",
|
|
"%PY% \"%SCRIPT%\"",
|
|
"goto END",
|
|
"",
|
|
":NOPY",
|
|
"echo.",
|
|
"echo [ERROR] Python not found (neither python nor py on PATH).",
|
|
"echo.",
|
|
"echo The self-check needs Python. Usually you do not need it -",
|
|
"echo use the Toolbox instead:",
|
|
"echo 1 Start agent",
|
|
"echo 2 Fix firewall",
|
|
"echo.",
|
|
"goto END",
|
|
"",
|
|
":NOFILE",
|
|
"echo.",
|
|
"echo [ERROR] No .py script found next to this .bat.",
|
|
"echo.",
|
|
"",
|
|
":END",
|
|
"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="ascii", 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
|
|
try:
|
|
data.decode("ascii")
|
|
ascii_ok = True
|
|
except UnicodeDecodeError:
|
|
ascii_ok = False
|
|
|
|
print(f" 路径: {target}")
|
|
print(f" 大小: {len(data)} 字节 CRLF={crlf} 裸LF={lone} 纯ASCII={ascii_ok}")
|
|
|
|
problems = []
|
|
if lone:
|
|
problems.append("存在裸 LF")
|
|
if not ascii_ok:
|
|
problems.append("含非 ASCII 字符")
|
|
if not any(b"*.py" in line for line in [data]):
|
|
problems.append("没有用通配符找 .py")
|
|
if problems:
|
|
for item in problems:
|
|
print(f" [失败] {item}")
|
|
return 1
|
|
print(" 自检: 通过")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|