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

100 lines
3.3 KiB
Python

# -*- coding: utf-8 -*-
"""两处收尾:
1. 彻底删掉「自动搜索电脑」那一段
(上次我图省事写了个 if(false) 包起来,结果 search 是 null 还在用,
会编译失败,而且很难看。)
2. Json 加 stringList 方法
RelayTransport 里我用它读 lanIps,但 Json 里没这个方法。
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
WATCH = ROOT / "android" / "src" / "com" / "lanremote" / "watch"
MAIN = WATCH / "MainActivity.java"
JSON = WATCH / "Json.java"
# ---------- 1. 删掉搜索按钮那一段 ----------
DEAD_START = " // 老版本的「自动搜索电脑」按钮去掉了:"
DEAD_END = " box.addView(search);\n"
# ---------- 2. Json.stringList ----------
JSON_ANCHOR = ''' public static List<Object> list(Map<String, Object> map, String key) {'''
JSON_NEW = ''' /**
* 取一个字符串数组。元素不是字符串的会被跳过。
*
* 中转会把被控端上报的局域网 IP 列表放在这里(lanIps),
* 手表用它判断能不能走局域网直连。
*/
public static List<String> stringList(Map<String, Object> map, String key) {
List<String> out = new java.util.ArrayList<String>();
List<Object> raw = list(map, key);
if (raw == null) {
return out;
}
for (Object item : raw) {
if (item instanceof String) {
String text = ((String) item).trim();
if (!text.isEmpty()) {
out.add(text);
}
}
}
return out;
}
public static List<Object> list(Map<String, Object> map, String key) {'''
def main() -> int:
ok = True
# ---- 删掉那一段 ----
lines = MAIN.read_text(encoding="utf-8").splitlines(keepends=True)
start = end = None
for index, line in enumerate(lines):
if DEAD_START in line and start is None:
start = index
if start is not None and line.strip() == "box.addView(search);":
end = index
break
if start is None or end is None:
print(" [失败] 找不到要删的那一段")
ok = False
else:
print(f" 删掉第 {start + 1} 到 {end + 1} 行({end - start + 1} 行)")
del lines[start:end + 1]
MAIN.write_text("".join(lines), encoding="utf-8", newline="\n")
# ---- Json.stringList ----
text = JSON.read_text(encoding="utf-8")
if "stringList" in text:
print(" Json 已经有 stringList")
elif JSON_ANCHOR in text:
text = text.replace(JSON_ANCHOR, JSON_NEW, 1)
JSON.write_text(text, encoding="utf-8", newline="\n")
print(" Json 加了 stringList")
else:
print(" [失败] Json 锚点没找到")
ok = False
# 确认 startDiscovery 还有没有被引用
main_text = MAIN.read_text(encoding="utf-8")
uses = [i + 1 for i, line in enumerate(main_text.splitlines())
if "startDiscovery" in line]
print(f" startDiscovery 剩余引用行: {uses if uses else '无'}")
if uses:
print(" (还引用着的话,得看是不是只剩定义本身)")
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())