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

97 lines
3.4 KiB
Bash
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.
#!/bin/bash
# 清理中转上的测试设备,确认用户的配对码没被占。
set -u
KEY=$(cat /root/lanremote-relay/data/admin_key.txt 2>/dev/null)
echo "===== 1. 当前中转上有哪些设备 ====="
curl -s --max-time 8 http://127.0.0.1:8080/v1/health > /tmp/h.json 2>/dev/null
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/h.json'))
except Exception:
print(" 读不到健康信息")
raise SystemExit
devices = d.get("devices", [])
if not devices:
print(" (一台都没有)")
for x in devices:
print(f" {x.get('code')} {x.get('name')} "
f"online={x.get('online')} deviceId={x.get('deviceId')}")
print(f" 共 {len(devices)} 台")
PY
echo
echo "===== 2. 抹掉测试设备(名字里带 test/测试 的)====="
python3 - <<'PY'
import json, subprocess
try:
d = json.load(open('/tmp/h.json'))
except Exception:
raise SystemExit
key = open('/root/lanremote-relay/data/admin_key.txt').read().strip()
removed = 0
for x in d.get("devices", []):
name = str(x.get("name") or "")
dev = str(x.get("deviceId") or "")
if ("test" in dev.lower() or "测试" in name or "多地址" in name):
code = x.get("code")
out = subprocess.run(
["curl", "-s", "--max-time", "8", "-X", "POST",
"http://127.0.0.1:8080/v1/admin/forget",
"-H", f"X-Admin: {key}",
"-H", "Content-Type: application/json",
"-d", json.dumps({"code": code})],
capture_output=True, text=True).stdout
print(f" 抹掉 {code} ({name}) -> {out.strip()[:60]}")
removed += 1
print(f" 共抹掉 {removed} 台")
PY
echo
echo "===== 3. 现在还有哪些 ====="
curl -s --max-time 8 http://127.0.0.1:8080/v1/health > /tmp/h2.json 2>/dev/null
python3 - <<'PY'
import json
try:
d = json.load(open('/tmp/h2.json'))
except Exception:
raise SystemExit
for x in d.get("devices", []):
print(f" {x.get('code')} {x.get('name')}")
print(f" 共 {len(d.get('devices', []))} 台")
PY
echo
echo "===== 4. 789113 能不能用 ====="
RESULT=$(curl -s --max-time 8 -X POST http://127.0.0.1:8080/v1/agent/register \
-H 'Content-Type: application/json' \
-d '{"deviceId":"probe-check-789113","code":"789113","name":"探测","version":"1.4.0"}')
echo " $RESULT" | head -c 200
echo
if echo "$RESULT" | grep -q '"ok": *true'; then
echo " ✓ 789113 可以用"
# 探测完立刻抹掉,别占着
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 现在是空闲的)"
elif echo "$RESULT" | grep -q 'codeTaken'; then
echo " ✗ 789113 被别的设备占了 —— 需要处理"
else
echo " ? 结果看不懂"
fi
echo
echo "===== 5. 服务状态 ====="
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)"
echo " 内存: $(free -m | awk 'NR==2{printf "已用 %s MB / 可用 %s MB", $3, $7}')"