#!/bin/bash # 手动跑一下看 --protocol http2 为什么退出。 set -u echo "===== 停掉服务 =====" systemctl stop lanremote-tunnel 2>/dev/null || true sleep 2 echo echo "===== 前台跑 25 秒,看报什么错 =====" echo " (http2)" timeout 25 cloudflared tunnel --no-autoupdate --edge-ip-version 4 \ --protocol http2 --config /root/.cloudflared/config.yml run lanremote 2>&1 \ | head -25 | sed 's/^/ /' echo echo "===== 对比:quic(之前能用的)=====" timeout 25 cloudflared tunnel --no-autoupdate --edge-ip-version 4 \ --config /root/.cloudflared/config.yml run lanremote 2>&1 \ | head -25 | sed 's/^/ /' echo echo "===== 恢复服务(用默认 QUIC)=====" python3 - <<'PY' from pathlib import Path unit = Path("/etc/systemd/system/lanremote-tunnel.service") text = unit.read_text() if "--protocol http2" in text: text = text.replace(" --protocol http2", "") unit.write_text(text) print(" 已去掉 --protocol http2(回退到默认 QUIC)") for line in text.splitlines(): if line.startswith("ExecStart"): print(" " + line) PY systemctl daemon-reload systemctl restart lanremote-tunnel sleep 20 echo " 服务: $(systemctl is-active lanremote-tunnel)" echo echo " 验证:" for i in 1 2 3 4 5; 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) printf " 第 %d 次: HTTP %s\n" "$i" "${C:-超时}" [ "$C" = "200" ] && break sleep 5 done