#!/bin/bash # 阶段 2 第一步:确认被控端到底走的哪条路。 # # 关键点:电脑(192.168.10.103) 和随身 WiFi(192.168.10.105) 在同一局域网, # 被控端的默认中转地址是 "192.168.10.105:8080;https://relay.xxmxxs.top" # —— 应该**第一个就通**,直接走局域网,完全不碰隧道。 # 如果它走了隧道,那就是白白承受 40% 丢包。 set -u echo "===== 1. 从被控端(这台设备)看局域网能不能到 192.168.10.105:8080 =====" echo -n " LAN 直连 relay: HTTP " timeout 5 curl -s -o /dev/null -w '%{http_code}\n' \ http://192.168.10.105:8080/v1/health 2>/dev/null || echo "不通" echo echo "===== 2. 延迟对比 =====" echo -n " 局域网 relay: " timeout 5 curl -s -o /dev/null -w '%{time_total}s\n' \ http://192.168.10.105:8080/v1/health 2>/dev/null || echo "不通" echo -n " 公网隧道: " timeout 15 curl -4 -s -o /dev/null -w '%{time_total}s\n' \ -H 'User-Agent: LanRemote/1.4.0' \ https://relay.xxmxxs.top/v1/health 2>/dev/null || echo "不通" echo echo "===== 3. 被控端进程(在这台设备上看不到,看服务端记录)=====" echo " 中转记录的在线设备:" timeout 8 curl -s http://127.0.0.1:8080/v1/health 2>/dev/null \ | python3 -c ' import json, sys try: d = json.load(sys.stdin) except Exception: print(" 读不到") sys.exit() for dev in d.get("devices", []): print(f" {dev.get(\"name\")} 配对码={dev.get(\"code\")} " f"在线={dev.get(\"online\")} lanIps={dev.get(\"lanIps\")} " f"闲置={dev.get(\"idleSeconds\")}s") if not d.get("devices"): print(" (没有设备)") ' 2>/dev/null echo echo "===== 4. 局域网直连的可用率(20 次)=====" ok=0 for i in $(seq 1 20); do c=$(timeout 5 curl -s -o /dev/null -w '%{http_code}' \ http://192.168.10.105:8080/v1/health 2>/dev/null) [ "$c" = "200" ] && ok=$((ok+1)) sleep 0.5 done echo " 局域网 $ok/20 = $((ok*5))%" echo echo "===== 5. 对比:公网隧道(20 次)=====" ok2=0 for i in $(seq 1 20); do c=$(timeout 12 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" ] && ok2=$((ok2+1)) sleep 1 done echo " 公网 $ok2/20 = $((ok2*5))%" echo echo "===== 结论 =====" if [ "$ok" -ge 18 ]; then echo " 局域网这条路很稳($ok/20)—— 被控端应该优先用它" echo " 默认地址里局域网排第一(192.168.10.105:8080;https://...)," echo " 所以正常情况根本不会碰隧道。" else echo " 局域网也不稳,要再看看" fi