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

105 lines
3.7 KiB
Bash

#!/bin/bash
# 修:重启中转会连带把隧道停掉,而且不会自己起来。
#
# 原因:
# 隧道的 unit 里写了
# Requires=lanremote-relay.service
# Requires 是**双向**的 —— 被依赖的服务一停,依赖它的也会被停。
# 于是重启中转时隧道被停,而没有任何东西会再把它拉起来,
# 公网入口就一直 530。
#
# 修法:
# 改成 Wants= + After=
# Wants 只表示"希望它也起来",单向,不会因为对方停了而停
# After 只表示启动顺序
# 这样中转重启时隧道继续跑(中间那一两秒会 502,随后自动恢复),
# 隧道的 Restart=always 也能管住自己的进程。
set -u
UNIT=/etc/systemd/system/lanremote-tunnel.service
echo "===== 1. 改之前 ====="
grep -E '^(Requires|Wants|After|Description)' "$UNIT" | sed 's/^/ /'
echo
echo "===== 2. 改成单向依赖 ====="
python3 - <<'PY'
from pathlib import Path
path = Path("/etc/systemd/system/lanremote-tunnel.service")
text = path.read_text()
text = text.replace("Requires=lanremote-relay.service\n", "")
if "Wants=network-online.target lanremote-relay.service" not in text:
text = text.replace("Wants=network-online.target",
"Wants=network-online.target lanremote-relay.service")
if "After=network-online.target lanremote-relay.service" not in text:
text = text.replace(
"After=network-online.target",
"After=network-online.target lanremote-relay.service")
# 补一句说明,免得以后有人又改回去
if "# 注意:这里用 Wants 不用 Requires" not in text:
text = text.replace(
"[Unit]\n",
"[Unit]\n# 注意:这里用 Wants 不用 Requires。\n"
"# Requires 是双向的 —— 重启中转会把隧道一起停掉,\n"
"# 而且没有东西会再把它拉起来,公网入口就一直 530。\n", 1)
path.write_text(text)
print(" 已改")
PY
echo
echo "===== 3. 改之后 ====="
grep -E '^(Requires|Wants|After)' "$UNIT" | sed 's/^/ /'
echo
echo "===== 4. 重新加载并启动 ====="
systemctl daemon-reload
systemctl restart lanremote-tunnel
sleep 35
echo " 隧道: $(systemctl is-active lanremote-tunnel)"
echo " 中转: $(systemctl is-active lanremote-relay)"
echo
echo " 已注册连接: $(grep -c 'Registered tunnel connection' /root/lanremote-relay/tunnel.log 2>/dev/null || echo 0)"
echo
echo "===== 5. 验证:重启中转,隧道应该活着 ====="
BEFORE=$(systemctl is-active lanremote-tunnel)
systemctl restart lanremote-relay
sleep 8
AFTER=$(systemctl is-active lanremote-tunnel)
echo " 重启中转前隧道: $BEFORE"
echo " 重启中转后隧道: $AFTER"
if [ "$AFTER" = "active" ]; then
echo " ✓ 修好了 —— 中转重启不再连带停掉隧道"
else
echo " ✗ 还是被连带停掉了"
fi
echo
echo "===== 6. 公网可达性(连打 10 次)====="
sleep 20
OK=0
for i in $(seq 1 10); do
C=$(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)
[ "$C" = "200" ] && { OK=$((OK + 1)); M="✓"; } || M="✗"
printf " %2d: %s HTTP %s\n" "$i" "$M" "${C:-超时}"
sleep 2
done
echo " 成功 $OK / 10"
echo
echo "===== 7. 最终状态 ====="
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 " 绑定数: $(python3 -c 'import json;print(len(json.load(open(\"/root/lanremote-relay/data/relay_state.json\")).get(\"codes\",[])))' 2>/dev/null)"