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

107 lines
3.5 KiB
Bash
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.
#!/bin/bash
# 把中转的状态文件清空 —— 让用户的电脑能干净地认领 789113。
#
# 为什么设备列表抹干净了 789113 还被占:
# codes(deviceId -> 配对码)是持久化在 relay_state.json 里的,
# 里面堆积了我早期所有测试留下的绑定。有些绑定的设备早就没了,
# 但码还占着。而 /v1/admin/forget 只能按"当前在线设备列表"里的码来抹,
# 抹不到这些孤儿绑定。
#
# 做法:停服务 -> 清空 codes -> 起服务。
set -u
STATE=/root/lanremote-relay/data/relay_state.json
echo "===== 1. 清空之前有多少绑定 ====="
python3 - <<'PY'
import json
try:
d = json.load(open('/root/lanremote-relay/data/relay_state.json'))
except Exception as exc:
print(f" 读不到: {exc}")
raise SystemExit
codes = d.get("codes", [])
print(f" {len(codes)} 条绑定")
has = [c for c in codes if str(c.get("code")) == "789113"]
if has:
print(f" 789113 绑在: {has[0].get('deviceId')}")
PY
echo
echo "===== 2. 备份 + 停服务 ====="
cp -f "$STATE" "${STATE}.bak" 2>/dev/null || true
ls -la "${STATE}.bak" | sed 's/^/ /'
systemctl stop lanremote-relay
sleep 2
echo " 服务: $(systemctl is-active lanremote-relay)"
echo
echo "===== 3. 清空绑定(保留其他设置字段)====="
python3 - <<'PY'
import json
path = "/root/lanremote-relay/data/relay_state.json"
try:
d = json.load(open(path))
except Exception:
d = {}
before = len(d.get("codes", []))
d["codes"] = []
# 顺带清掉退役会话记录
if "retired" in d:
d["retired"] = {}
json.dump(d, open(path, "w"))
print(f" 清掉 {before} 条绑定,现在是 {len(d.get('codes', []))} 条")
print(f" 保留的字段: {sorted(d.keys())}")
PY
echo
echo "===== 4. 起服务 ====="
systemctl start lanremote-relay
sleep 4
echo " 服务: $(systemctl is-active lanremote-relay)"
echo
echo "===== 5. 验证 789113 空闲 ====="
R=$(curl -s --max-time 8 -X POST http://127.0.0.1:8080/v1/agent/register \
-H 'Content-Type: application/json' \
-d '{"deviceId":"probe-clean","code":"789113","name":"探测","version":"1.4.0"}')
echo " $R" | head -c 180
echo
if echo "$R" | grep -q '"ok": *true'; then
echo " ✓ 789113 空闲可用"
KEY=$(cat /root/lanremote-relay/data/admin_key.txt)
curl -s -o /dev/null -X POST http://127.0.0.1:8080/v1/admin/forget \
-H "X-Admin: $KEY" -H 'Content-Type: application/json' \
-d '{"code":"789113"}'
echo " (探测记录已清掉,789113 恢复空闲)"
else
echo " ✗ 还被占"
fi
echo
echo "===== 6. 最终状态 ====="
python3 - <<'PY'
import json
d = json.load(open('/root/lanremote-relay/data/relay_state.json'))
print(f" 绑定数: {len(d.get('codes', []))}")
PY
curl -s --max-time 8 http://127.0.0.1:8080/v1/health > /tmp/f.json 2>/dev/null
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/f.json'))
except Exception:
raise SystemExit
print(f" 在线设备 {len(d.get('devices', []))} 台 会话 {d.get('sessions')} "
f"内存 {d.get('memoryKB', 0) // 1024} MB")
PY
echo
for s in lanremote-relay lanremote-tunnel lanremote-watchdog.timer; do
printf " %-30s %-9s %s\n" "$s" \
"$(systemctl is-active $s 2>/dev/null)" \
"$(systemctl is-enabled $s 2>/dev/null)"
done
echo
echo " 公网地址: $(cat /root/lanremote-relay/public_url.txt 2>/dev/null)"
echo " 可达性: HTTP $(timeout 20 curl -4 -s -o /dev/null -w '%{http_code}' -H 'User-Agent: LanRemote/1.4.0' https://relay.xxmxxs.top/v1/health 2>/dev/null)"