Files
ykxmz/_build/fix_bat_names.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

131 lines
4.3 KiB
Python

# -*- coding: utf-8 -*-
"""修 .bat 里的旧程序名。
发现:
tools/fxfhq.bat、tools/wlzj.bat、tools/xffhq.bat 都是**改名之前**
生成的,里面还在找 LanRemote-Agent.exe。
程序已经叫 ykxmz.exe 了,这些脚本一跑就"找不到程序" —— 真 bug。
编码约定(这部分是对的,不动):
.bat 用 **GBK** + CRLF + `chcp 936`。
这是中文 Windows 下 cmd.exe 的正确做法:
控制台默认代码页 936,UTF-8 的中文在 cmd 里会变乱码。
顺手把生成它们的脚本也改了,免得下次重新生成又变回旧名。
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
BATS = [
ROOT / "tools" / "fxfhq.bat",
ROOT / "tools" / "wlzj.bat",
ROOT / "tools" / "xffhq.bat",
ROOT / "windows" / "放行防火墙_以管理员运行.bat",
]
# 生成它们的脚本(下次重新生成时用得上)
GENERATORS = [
ROOT / "_build" / "fix_netcheck_output.py",
ROOT / "_build" / "make_fix_bat.py",
ROOT / "_build" / "make_toolbox.py",
ROOT / "_build" / "rename_tools.py",
]
# 兼容旧名:查找 EXE 时把两个名字都试一遍,
# 这样从老版本升级上来的目录也能找到程序
LOOKUP_OLD = '''set "EXE=%~dp0LanRemote-Agent.exe"
if not exist "%EXE%" set "EXE=%~dp0..\\LanRemote-Agent.exe"
if not exist "%EXE%" set "EXE=%~dp0LanRemote-Agent\\LanRemote-Agent.exe"'''
LOOKUP_NEW = '''set "EXE=%~dp0ykxmz.exe"
if not exist "%EXE%" set "EXE=%~dp0..\\ykxmz.exe"
if not exist "%EXE%" set "EXE=%~dp0ykxmz\\ykxmz.exe"
rem 兼容改名前的老目录(升级上来的机器上可能还留着)
if not exist "%EXE%" set "EXE=%~dp0LanRemote-Agent.exe"
if not exist "%EXE%" set "EXE=%~dp0..\\LanRemote-Agent.exe"'''
def patch_bat(path: Path) -> int:
if not path.is_file():
return 0
raw = path.read_bytes()
# 按 GBK 解(这些文件本来就是 GBK)
try:
text = raw.decode("gbk")
except UnicodeDecodeError:
print(f" [跳过] {path.name}: 不是 GBK")
return 0
original = text
# 1. 整段查找逻辑(带老目录兜底)
if LOOKUP_OLD in text:
text = text.replace(LOOKUP_OLD, LOOKUP_NEW)
# 2. 其余零散出现
text = text.replace("LanRemote-Agent.exe", "ykxmz.exe")
text = text.replace('LanRemote-Agent\\\\LanRemote-Agent',
'ykxmz\\\\ykxmz')
if text == original:
print(f" {path.name}: 没有旧名")
return 0
count = original.count("LanRemote-Agent")
# 写回:GBK + CRLF
body = text.replace("\r\n", "\n").replace("\n", "\r\n")
path.write_bytes(body.encode("gbk", errors="replace"))
print(f" {path.name}: 改了 {count} 处(GBK + CRLF 保持)")
return count
def main() -> int:
total = 0
print("一、修 .bat 内容")
for path in BATS:
total += patch_bat(path)
print()
print("二、修生成它们的脚本(免得重新生成又变回旧名)")
for path in GENERATORS:
if not path.is_file():
continue
text = path.read_text(encoding="utf-8")
if "LanRemote-Agent" not in text:
print(f" {path.name}: 干净")
continue
count = text.count("LanRemote-Agent")
text = text.replace("LanRemote-Agent.exe", "ykxmz.exe")
text = text.replace("LanRemote-Agent\\\\LanRemote-Agent",
"ykxmz\\\\ykxmz")
path.write_text(text, encoding="utf-8", newline="\n")
print(f" {path.name}: 改了 {count} 处")
print()
print("三、复核 .bat")
ok = True
for path in BATS:
if not path.is_file():
continue
raw = path.read_bytes()
try:
text = raw.decode("gbk")
except UnicodeDecodeError as exc:
print(f" [坏] {path.name}: GBK 解不开 {exc}")
ok = False
continue
crlf = raw.count(b"\r\n")
lf_only = raw.count(b"\n") - crlf
old_name = "LanRemote-Agent" in text
print(f" {path.name}: GBK ✓ CRLF {crlf} 纯LF {lf_only} "
f"旧名 {'还有!' if old_name else '无'}")
if lf_only or old_name:
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())