Update Nlbench_pro.sh

This commit is contained in:
Jensfrank 2024-07-02 14:33:32 +08:00 committed by GitHub
parent 776aa9b3da
commit 2eb74fc482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# 定义版本 # 定义版本
VERSION="1.0.1" VERSION="1.0.2"
# 定义颜色 # 定义颜色
RED='\033[0;31m' RED='\033[0;31m'
@ -10,6 +10,7 @@ YELLOW='\033[1;33m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限 # 检查 root 权限并获取 sudo 权限
check_root() {
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。" echo "此脚本需要 root 权限运行。"
if ! sudo -v; then if ! sudo -v; then
@ -18,6 +19,7 @@ if [ "$(id -u)" != "0" ]; then
fi fi
echo "已获取 sudo 权限。" echo "已获取 sudo 权限。"
fi fi
}
# 检查并安装依赖 # 检查并安装依赖
install_dependencies() { install_dependencies() {
@ -33,6 +35,7 @@ install_dependencies() {
local dependencies=( local dependencies=(
"curl" "curl"
"wget" "wget"
"iperf3"
) )
for dep in "${dependencies[@]}"; do for dep in "${dependencies[@]}"; do
@ -197,10 +200,14 @@ generate_output() {
echo echo
echo "[tab=\"iperf3\"]" echo "[tab=\"iperf3\"]"
echo "\`\`\`" echo "\`\`\`"
iperf3 -c iperf.online -P 8 -t 10
echo "\`\`\`" echo "\`\`\`"
echo "[/tab]" echo "[/tab]"
echo echo
echo "[tab=\"Ping.pe\"]" echo "[tab=\"Ping.pe\"]"
echo "\`\`\`"
curl -s https://ping.pe/$ipv4_address | grep -E 'AS|Country|City'
echo "\`\`\`"
echo "[/tab]" echo "[/tab]"
echo echo
echo "[tab=\"哪吒 ICMP\"]" echo "[tab=\"哪吒 ICMP\"]"
@ -220,8 +227,7 @@ main() {
ip_address ip_address
# 创建输出文件 # 创建输出文件
output_file="nodeloc_vps_test_$(date +%Y%m%d%H%M%S).md" output_file="nodeloc_vps_test_$(date +%Y%m%d%H%M%S)"
echo "[tabs]" > "$output_file"
# 显示欢迎信息 # 显示欢迎信息
clear clear
@ -258,17 +264,14 @@ main() {
echo "3. IP质量" echo "3. IP质量"
echo "4. 流媒体解锁" echo "4. 流媒体解锁"
echo "5. 响应测试" echo "5. 响应测试"
echo "6. 三网测速" echo "6. 三网测速(多线程)"
echo "7. 回程路由" echo "7. 三网测速(单线程)"
echo "8. 回程路由"
echo "请耐心等待,测试可能需要一些时间..." echo "请耐心等待,测试可能需要一些时间..."
run_yabs for i in {1..8}; do
run_fusion_monster run_test $i "$output_file"
run_ip_quality done
run_media_unlock
run_response_test
run_speed_test
run_traceroute
elif [ "$mode_choice" == "2" ]; then elif [ "$mode_choice" == "2" ]; then
echo "输入要测试的脚本编号(用逗号分隔,如 1,2,3" echo "输入要测试的脚本编号(用逗号分隔,如 1,2,3"
echo "1. Yabs" echo "1. Yabs"
@ -276,8 +279,9 @@ main() {
echo "3. IP质量" echo "3. IP质量"
echo "4. 流媒体解锁" echo "4. 流媒体解锁"
echo "5. 响应测试" echo "5. 响应测试"
echo "6. 三网测速" echo "6. 三网测速(多线程)"
echo "7. 回程路由" echo "7. 三网测速(单线程)"
echo "8. 回程路由"
read -p "输入选择: " script_choices read -p "输入选择: " script_choices
echo "您选择了以下测试:" echo "您选择了以下测试:"
@ -289,39 +293,35 @@ main() {
3) echo "- IP质量" ;; 3) echo "- IP质量" ;;
4) echo "- 流媒体解锁" ;; 4) echo "- 流媒体解锁" ;;
5) echo "- 响应测试" ;; 5) echo "- 响应测试" ;;
6) echo "- 三网测速" ;; 6) echo "- 三网测速(多线程)" ;;
7) echo "- 回程路由" ;; 7) echo "- 三网测速(单线程)" ;;
8) echo "- 回程路由" ;;
*) echo "- 无效选择: $i" ;; *) echo "- 无效选择: $i" ;;
esac esac
done done
echo "请耐心等待,测试可能需要一些时间..." echo "请耐心等待,测试可能需要一些时间..."
for i in "${ADDR[@]}"; do for i in "${ADDR[@]}"; do
case $i in if [[ $i =~ ^[1-8]$ ]]; then
1) run_yabs ;; run_test $i "$output_file"
2) run_fusion_monster ;; else
3) run_ip_quality ;; echo "跳过无效选择: $i"
4) run_media_unlock ;; fi
5) run_response_test ;;
6) run_speed_test ;;
7) run_traceroute ;;
*) echo "跳过无效选择: $i" ;;
esac
done done
else else
echo "无效选择,退出程序。" echo "无效选择,退出程序。"
exit 1 exit 1
fi fi
# 添加缺失的标签 # 生成最终输出
for tab in "YABS" "融合怪" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "回程路由" "去程路由" "iperf3" "Ping.pe" "哪吒 ICMP" "其他"; do generate_output "$output_file" > "${output_file}.md"
if ! grep -q "\[tab=\"$tab\"\]" "$output_file"; then
echo -e "\n[tab=\"$tab\"]\n\n[/tab]" >> "$output_file"
fi
done
echo "[/tabs]" >> "$output_file" # 清理临时文件
echo "测试完成,结果已保存到 $output_file" rm -f "${output_file}_"*
echo "测试完成,结果已保存到 ${output_file}.md"
echo "您可以使用文本编辑器打开该文件查看详细结果。" echo "您可以使用文本编辑器打开该文件查看详细结果。"
} }
# 运行主函数
main main