diff --git a/Nlbench.sh b/Nlbench.sh index 46c4e7e..8494cf9 100644 --- a/Nlbench.sh +++ b/Nlbench.sh @@ -84,49 +84,37 @@ detect_region() { esac } -# iperf3测试函数 run_iperf3_test() { - local servers=( - # Europe - "ping.online.net" - "ping6.online.net" - "ping-90ms.online.net" - "ping6-90ms.online.net" - "iperf3.moji.fr" - "iperf.par2.as49434.net" - "paris.testdebit.info" - "lille.testdebit.info" - "lyon.testdebit.info" - "aix-marseille.testdebit.info" - "bordeaux.testdebit.info" - "nl.iperf.014.fr" - "ch.iperf.014.fr" - "iperf.eenet.ee" - "iperf.astra.in.ua" - "iperf.volia.net" - - # Asia - "speedtest.uztelecom.uz" - "iperf.it-north.net" - "iperf.biznetnetworks.com" - - # Oceania - "speedtest-iperf-akl.vetta.online" - - # Americas - "iperf.scottlinux.com" - "iperf.he.net" + declare -A regions=( + ["Europe"]="ping.online.net ping6.online.net iperf3.moji.fr iperf.par2.as49434.net paris.testdebit.info iperf.eenet.ee iperf.volia.net" + ["Asia"]="speedtest.uztelecom.uz iperf.it-north.net iperf.biznetnetworks.com" + ["Oceania"]="speedtest-iperf-akl.vetta.online" + ["Americas"]="iperf.scottlinux.com iperf.he.net" ) - for server in "${servers[@]}"; do - echo "测试服务器: $server" - if timeout 15 iperf3 -c "$server" -t 30 -P 3 2>/dev/null; then - echo "测试完成" - else - echo "测试失败或超时" - fi - echo "----------------------------------------" + echo "开始iperf3测试..." + + for region in "${!regions[@]}"; do + echo "测试 $region 地区..." + servers=(${regions[$region]}) + for server in "${servers[@]}"; do + echo " 检查服务器: $server" + if timeout 5 iperf3 -c "$server" -t 1 -P 1 >/dev/null 2>&1; then + echo " 服务器可用,开始测试..." + if timeout 15 iperf3 -c "$server" -t 10 -P 3; then + echo " 测试完成" + else + echo " 测试失败或超时" + fi + echo "----------------------------------------" + break # 找到可用服务器后,跳出当前地区的循环 + else + echo " 服务器忙或不可用,尝试下一个" + fi + done done + + echo "iperf3测试完成" } # 统计使用次数