#!/bin/bash # 验证:僵尸设备清掉了 + 公网稳定 set -u BASE=http://127.0.0.1:8080 PUB=https://relay.xxmxxs.top echo " 服务状态: relay=$(systemctl is-active lanremote-relay) tunnel=$(systemctl is-active lanremote-tunnel)" curl -s --max-time 15 "$BASE/v1/health" -o /tmp/h.json size=$(wc -c < /tmp/h.json) count=$(python3 -c "import json; print(len(json.load(open('/tmp/h.json')).get('devices',[])))" 2>/dev/null || echo "?") echo " health: ${size} 字节,设备 $count 台" echo echo " TCP keepalive:" for k in tcp_keepalive_time tcp_keepalive_intvl tcp_keepalive_probes; do printf " %-26s = %s\n" "$k" "$(sysctl -n net.ipv4.$k)" done echo " 隧道参数: $(grep -o 'ha-connections [0-9]*' /etc/systemd/system/lanremote-tunnel.service)" echo " 隧道连接数: $(curl -s --max-time 5 http://127.0.0.1:20241/metrics 2>/dev/null | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')" echo echo " 公网 15 次:" ok=0 for i in $(seq 1 15); do c=$(curl -s -o /dev/null -w '%{http_code}' --max-time 20 -H 'User-Agent: LanRemote/1.4.0' "$PUB/v1/health") [ "$c" = "200" ] && ok=$((ok+1)) printf " %2d: %s\n" "$i" "$c" sleep 1 done echo " 可用 $ok/15" echo echo " 官网公网:" curl -s -o /dev/null -w ' HTTP %{http_code} %{size_download} 字节 %{time_total}s\n' \ --max-time 25 -H 'User-Agent: LanRemote/1.4.0' "$PUB/"