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

79 lines
2.3 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
# 装第二版看门狗:30 秒一轮(原来 5 分钟)。
set -u
RELAY_DIR=/root/lanremote-relay
echo "===== 1. 装脚本 ====="
chmod +x "$RELAY_DIR/watchdog.sh"
echo " $(ls -la $RELAY_DIR/watchdog.sh | awk '{print $5" 字节"}')"
echo
echo "===== 2. 服务 ====="
cat > /etc/systemd/system/lanremote-watchdog.service <<'EOF'
[Unit]
Description=LanRemote 隧道看门狗(看连接数,不是看公网)
After=lanremote-relay.service lanremote-tunnel.service
[Service]
Type=oneshot
ExecStart=/bin/bash /root/lanremote-relay/watchdog.sh
MemoryMax=64M
StandardOutput=append:/root/lanremote-relay/watchdog.log
StandardError=append:/root/lanremote-relay/watchdog.log
EOF
echo
echo "===== 3. 定时器:30 秒一轮 ====="
cat > /etc/systemd/system/lanremote-watchdog.timer <<'EOF'
[Unit]
Description=每 30 秒检查一次隧道连接数
[Timer]
OnBootSec=2min
OnUnitActiveSec=30s
AccuracySec=5s
Unit=lanremote-watchdog.service
[Install]
WantedBy=timers.target
EOF
systemctl daemon-reload
systemctl enable lanremote-watchdog.timer >/dev/null 2>&1
systemctl restart lanremote-watchdog.timer
echo " 已启用"
echo
echo "===== 4. 立刻跑一次 ====="
: > "$RELAY_DIR/watchdog.log"
systemctl start lanremote-watchdog.service
sleep 6
tail -5 "$RELAY_DIR/watchdog.log" 2>/dev/null | sed 's/^/ /' || echo " (没输出)"
echo
echo "===== 5. 定时器状态 ====="
systemctl list-timers lanremote-watchdog.timer --no-pager 2>/dev/null | head -3 | sed 's/^/ /'
echo
echo "===== 6. 当前连接数 ====="
echo -n " ha_connections = "
curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}'
echo -n " 看门狗状态: "
cat "$RELAY_DIR/watchdog.state" 2>/dev/null | tr '\n' ' '
echo
echo
echo "===== 7. 观察 2 分钟,看它有没有乱重启 ====="
BEFORE=$(systemctl show lanremote-tunnel -p NRestarts | cut -d= -f2)
sleep 120
AFTER=$(systemctl show lanremote-tunnel -p NRestarts | cut -d= -f2)
echo " 这 2 分钟里隧道自动重启次数: $AFTER(之前 $BEFORE)"
echo " 看门狗日志尾部:"
tail -6 "$RELAY_DIR/watchdog.log" 2>/dev/null | sed 's/^/ /'
echo
echo -n " 当前连接数: "
curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null \
| grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}'