Files
ykxmz/_build/reset_relay_state.sh
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

107 lines
3.5 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
# 把中转的状态文件清空 —— 让用户的电脑能干净地认领 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)"