#!/bin/bash # 1.8.2 最终验收(在设备上跑) set -u BASE=https://relay.xxmxxs.top UA='LanRemote/1.8.2' echo "════════ 1. 官网和三个成品(走公网,看缓存)════════" for p in / /download/ykxmz-setup-1.8.2.exe /download/ykxmz-server-1.8.2.zip /download/ykxmz-watch-1.8.2.apk; do hdr=$(curl -s -D - -o /dev/null --max-time 45 -H "User-Agent: $UA" "$BASE$p" 2>/dev/null | tr -d '\r') code=$(echo "$hdr" | head -1 | awk '{print $2}') len=$(echo "$hdr" | grep -i '^content-length' | awk '{print $2}') cf=$(echo "$hdr" | grep -i '^cf-cache-status' | awk '{print $2}') cc=$(echo "$hdr" | grep -i '^cache-control' | cut -d' ' -f2-) printf " %-38s HTTP %-4s %10s cf=%-6s %s\n" "$p" "$code" "$len" "${cf:-无}" "${cc:-无}" done echo echo "════════ 2. 对外清洁度(官网不能有管理页字眼)════════" curl -s --max-time 30 -H "User-Agent: $UA" "$BASE/" -o /tmp/site.html n=$(grep -cE 'zhongzhuanzhan|管理后台|管理页|管理入口|管理面板' /tmp/site.html || true) echo " 官网里管理页字眼: $n 处(应为 0)" echo " 官网大小: $(wc -c < /tmp/site.html) 字节" echo " 下载按钮:" grep -o 'href="/download/[^"]*"' /tmp/site.html | sort -u | sed 's/^/ /' echo echo "════════ 3. 管理页两个新功能 ════════" if [ -f /root/taf.py ]; then python3 /root/taf.py 2>&1 | tail -16 | sed 's/^/ /' else echo " (测试脚本不在设备上)" fi echo echo "════════ 4. 中转核心功能(长轮询 + 注册)════════" STAMP=$(date +%s) DEV="acc-$STAMP" CODE=$(printf "%06d" $(( STAMP % 1000000 ))) REG=$(curl -s --max-time 30 -X POST "$BASE/v1/agent/register" \ -H 'Content-Type: application/json' -H "User-Agent: $UA" \ -d "{\"deviceId\":\"$DEV\",\"code\":\"$CODE\",\"name\":\"验收\",\"version\":\"1.8.2\"}") TOKEN=$(echo "$REG" | python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))" 2>/dev/null) echo " 注册: $([ -n "$TOKEN" ] && echo 成功 || echo 失败)" if [ -n "$TOKEN" ]; then for i in 1 2; do out=$(curl -s -o /dev/null -w '%{http_code} %{time_total}' --max-time 200 \ -X POST "$BASE/v1/agent/poll" -H "X-Token: $TOKEN" -H "User-Agent: $UA") printf " 长轮询 %d: 码 %s 耗时 %.1fs(应约 61 秒)\n" \ "$i" "$(echo "$out" | awk '{print $1}')" "$(echo "$out" | awk '{print $2}')" done KEY=$(cat /root/lanremote-relay/data/admin_key.txt 2>/dev/null) curl -s --max-time 20 -X POST "http://127.0.0.1:8080/v1/admin/delete" \ -H "X-Admin: $KEY" -H 'Content-Type: application/json' \ -d "{\"deviceId\":\"$DEV\"}" > /dev/null 2>&1 echo " 探针已清理" fi echo echo "════════ 5. 公网可用率(20 次)════════" ok=0 for i in $(seq 1 20); do c=$(curl -s -o /dev/null -w '%{http_code}' --max-time 20 -H "User-Agent: $UA" "$BASE/v1/health") [ "$c" = "200" ] && ok=$((ok + 1)) sleep 1 done echo " 可用 $ok/20 = $((ok * 5))%" echo echo "════════ 6. 隧道和错误 ════════" for s in lanremote-relay lanremote-tunnel lanremote-tunnel-h2; do printf " %-24s %s\n" "$s" "$(systemctl is-active $s)" done echo " 中转错误行数(近 10 分钟): $(journalctl -u lanremote-relay --since '10 minutes ago' --no-pager 2>/dev/null | grep -icE 'traceback|nameerror|typeerror|AttributeError' || echo 0)" echo " 连接数: 20241=$(curl -s --max-time 4 http://127.0.0.1:20241/metrics 2>/dev/null | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}') 20242=$(curl -s --max-time 4 http://127.0.0.1:20242/metrics 2>/dev/null | grep '^cloudflared_tunnel_ha_connections' | awk '{print $2}')"