Compare commits

..

No commits in common. "main" and "v1.1.3" have entirely different histories.
main ... v1.1.3

7 changed files with 1998 additions and 841 deletions

View File

@ -1,10 +1,9 @@
#!/bin/bash
# 定义版本
CURRENT_VERSION="2025-01-21 v1.2.7" # 最新版本号
SCRIPT_URL="https://raw.githubusercontent.com/nodeloc/nodeloc_vps_test/main/Nlbench.sh"
VERSION_URL="https://raw.githubusercontent.com/nodeloc/nodeloc_vps_test/main/version.sh"
CLOUD_SERVICE_BASE="https://bench.nodeloc.cc"
CURRENT_VERSION="2024-08-19 v1.1.3" # 最新版本号
SCRIPT_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/Nlbench.sh"
VERSION_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh"
# 定义颜色
RED='\033[0;31m'
@ -202,6 +201,7 @@ update_system() {
# 定义支持的操作系统类型
SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux")
# 安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
@ -223,49 +223,50 @@ install_dependencies() {
fi
case "${os_type,,}" in
debian|ubuntu)
export DEBIAN_FRONTEND=noninteractive
echo "iperf3 iperf3/autostart boolean false" | sudo debconf-set-selections
install_cmd="apt-get install -yq"
sudo apt-get update -yq
;;
centos|rhel|fedora)
install_cmd="dnf install -y"
sudo dnf makecache
gentoo)
install_cmd="emerge"
for dep in "${dependencies[@]}"; do
if ! emerge -p $dep &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd $dep; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
alpine)
install_cmd="apk add --no-cache"
;;
gentoo)
install_cmd="emerge --quiet"
;;
arch|manjaro)
install_cmd="pacman -S --noconfirm"
sudo pacman -Sy --noconfirm
install_cmd="apk add"
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
*)
echo -e "${RED}未知的包管理器。请手动安装依赖项。${NC}"
return 1
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
esac
# 安装依赖项
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 获取IP地址和ISP信息
ip_address_and_isp() {
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)
@ -320,9 +321,25 @@ detect_region() {
esac
}
# 服务器 VPS 信息
AUXILIARY_VPS="107.189.11.25"
IPERF_PORT=5201
TEST_DURATION=30
run_iperf3_test() {
echo -e "${GREEN}服务端VPS位于卢森堡${NC}"
echo -e "${GREEN}连接到服务端进行iperf3测试。。。${NC}"
timeout ${TEST_DURATION}s iperf3 -c $AUXILIARY_VPS -p $IPERF_PORT -t $TEST_DURATION
if [ $? -eq 0 ]; then
echo -e "${YELLOW}iperf3 测试完成${NC}"
else
echo -e "${RED}iperf3 测试失败或超时${NC}"
fi
}
# 统计使用次数
sum_run_times() {
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fnodeloc%2Fnodeloc_vps_test%2Fblob%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Feverett7623%2Fnodeloc_vps_test%2Fblob%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
if [[ -n "$COUNT" ]]; then
daily_count=$(cut -d " " -f1 <<< "$COUNT")
total_count=$(cut -d " " -f3 <<< "$COUNT")
@ -349,10 +366,50 @@ run_script() {
sed -i 's/\.\.\./\.\.\.\n/g' "$temp_file"
sed -i '/\.\.\./d' "$temp_file"
sed -i '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_yabs"
cp "$temp_file" "${output_file}_yabs"
;;
# Geekbench5
2)
# 获取系统总内存包括swap单位为MB
total_memory_mb=$(free -m | awk '/^Mem:/{print $2}')
total_swap_mb=$(free -m | awk '/^Swap:/{print $2}')
total_memory_swap=$((total_memory_mb + total_swap_mb))
# 设置Geekbench 5所需的最小内存MB
min_required_memory=1024
if [ "$total_memory_swap" -lt "$min_required_memory" ]; then
echo "本机内存和Swap总计小于${min_required_memory}MB不满足GB5测试条件。"
echo "系统总内存: ${total_memory_mb}MB"
echo "Swap大小: ${total_swap_mb}MB"
echo "总计: ${total_memory_swap}MB"
echo "将跳过Geekbench 5测试进行其他测试项目。"
sleep 3
# 跳过Geekbench 5测试继续执行其他测试
# 可以在这里调用其他测试函数或脚本
else
echo -e "运行${YELLOW}Geekbench 5...${NC}"
bash <(curl -sL gb5.top) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\x1B\[.*?[mGKH]//g' "$temp_file"
sed -i 's/\r//' "$temp_file"
sed -i '/^$/d' "$temp_file"
sed -i -n '/当前时间:/,${p}' "$temp_file"
cp "$temp_file" "${output_file}_gb5"
fi
;;
# 融合怪
3)
echo -e "运行${YELLOW}融合怪...${NC}"
curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh -m 1 <<< "y" | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\.\.\.\./\.\.\.\.\.\.\n/g' "$temp_file"
sed -i '1,/\.\.\.\.\.\./d' "$temp_file"
sed -i -n '/--------------------- A Bench Script By spiritlhl ----------------------/,${s/^.*\(--------------------- A Bench Script By spiritlhl ----------------------\)/\1/;p}' "$temp_file"
cp "$temp_file" "${output_file}_fusion"
;;
# IP质量
2)
4)
echo -e "运行${YELLOW}IP质量测试...${NC}"
echo y | bash <(curl -Ls IP.Check.Place) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
@ -363,7 +420,7 @@ run_script() {
cp "$temp_file" "${output_file}_ip_quality"
;;
# 流媒体解锁
3)
5)
echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
local region=$(detect_region)
bash <(curl -L -s media.ispvps.com) <<< "$region" | tee "$temp_file"
@ -374,21 +431,21 @@ run_script() {
cp "$temp_file" "${output_file}_streaming"
;;
# 响应测试
4)
6)
echo -e "运行${YELLOW}响应测试...${NC}"
bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
cp "$temp_file" "${output_file}_response"
;;
# 多线程测速
5)
7)
echo -e "运行${YELLOW}多线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "3" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "3" | tee "$temp_file"
else
echo "使用IPv4测试选项"
bash <(curl -sL https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "1" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "1" | tee "$temp_file"
fi
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
@ -398,14 +455,14 @@ run_script() {
cp "$temp_file" "${output_file}_multi_thread"
;;
# 单线程测速
6)
8)
echo -e "运行${YELLOW}单线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "17" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "17" | tee "$temp_file"
else
echo "使用IPv4测试选项"
bash <(curl -sL https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "2" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "2" | tee "$temp_file"
fi
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
@ -414,8 +471,17 @@ run_script() {
sed -i '/^$/d' "$temp_file"
cp "$temp_file" "${output_file}_single_thread"
;;
# iperf3测试
9)
echo -e "运行${YELLOW}iperf3测试...${NC}"
run_iperf3_test | tee "$temp_file"
sed -i -e 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/\[ ID\] /d' "$temp_file"
sed -i '/^$/d' "$temp_file"
cp "$temp_file" "${output_file}_iperf3"
;;
# 回程路由
7)
10)
echo -e "运行${YELLOW}回程路由测试...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
@ -435,56 +501,37 @@ run_script() {
# 生成最终的 Markdown 输出
generate_markdown_output() {
local base_output_file=$1
local temp_output_file="${base_output_file}.md"
local sections=("YABS" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "回程路由")
local file_suffixes=("yabs" "ip_quality" "streaming" "response" "multi_thread" "single_thread" "route")
local final_output_file="${base_output_file}.md"
local sections=("YABS" "Geekbench5" "融合怪" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "iperf3" "回程路由")
local file_suffixes=("yabs" "gb5" "fusion" "ip_quality" "streaming" "response" "multi_thread" "single_thread" "iperf3" "route")
local empty_tabs=("去程路由" "Ping.pe" "哪吒 ICMP" "其他")
# 修改这里,添加 UTF-8 编码设置
echo "[tabs]" | iconv -f UTF-8 -t UTF-8//IGNORE > "$temp_output_file"
echo "[tabs]" > "$final_output_file"
# 输出有内容的标签
for i in "${!sections[@]}"; do
section="${sections[$i]}"
suffix="${file_suffixes[$i]}"
if [ -f "${base_output_file}_${suffix}" ]; then
echo "[tab=\"$section\"]" | iconv -f UTF-8 -t UTF-8//IGNORE >> "$temp_output_file"
echo "\`\`\`" >> "$temp_output_file"
cat "${base_output_file}_${suffix}" | iconv -f UTF-8 -t UTF-8//IGNORE >> "$temp_output_file"
echo "\`\`\`" >> "$temp_output_file"
echo "[/tab]" >> "$temp_output_file"
echo "[tab=\"$section\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
cat "${base_output_file}_${suffix}" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
rm "${base_output_file}_${suffix}"
fi
done
# 添加保留的空白标签
#for tab in "${empty_tabs[@]}"; do
# echo "[tab=\"$tab\"]" >> "$temp_output_file"
# echo "[/tab]" >> "$temp_output_file"
#done
for tab in "${empty_tabs[@]}"; do
echo "[tab=\"$tab\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
done
echo "[/tabs]" >> "$temp_output_file"
echo "[/tabs]" >> "$final_output_file"
# 上传文件 获取回调
local plain_uploaded_file=$(cat "${temp_output_file}" | curl -s -X POST --data-binary @- "${CLOUD_SERVICE_BASE}")
local plain_uploaded_file_path=$(echo "$plain_uploaded_file" | grep -oP "(?<=${CLOUD_SERVICE_BASE}).*")
local plain_uploaded_file_filename=$(basename "${plain_uploaded_file_path}")
if [ -n "$plain_uploaded_file" ]; then
local base_url=$(echo "${CLOUD_SERVICE_BASE}" | sed 's:/*$::')
local remote_url="${base_url}/result${plain_uploaded_file_path}"
echo -e "${remote_url}\r\nPlain ${plain_uploaded_file}" > "${plain_uploaded_file_filename}.url"
echo "测试结果已上传,您可以在以下链接查看:"
echo "${remote_url}"
echo "Plain ${plain_uploaded_file}"
echo "结果链接已保存到 ${plain_uploaded_file_filename}.url"
else
echo "上传失败. 结果已保存在本地文件 ${temp_output_file}"
fi
rm "$temp_output_file"
read -p "按回车键继续..." < /dev/tty
echo "所有测试完成,结果已保存在 $final_output_file 中。"
read -p "按回车键继续..."
clear
}
@ -499,68 +546,55 @@ run_all_scripts() {
clear
}
# 执行选定的脚本
run_selected_scripts() {
clear
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
echo -e "${YELLOW}Nodeloc VPS 自动测试脚本 $VERSION${NC}"
echo "1. Yabs"
echo "2. IP质量"
echo "3. 流媒体解锁"
echo "4. 响应测试"
echo "5. 多线程测试"
echo "6. 单线程测试"
echo "7. 回程路由"
echo "2. Geekbench5"
echo "3. 融合怪"
echo "4. IP质量"
echo "5. 流媒体解锁"
echo "6. 响应测试"
echo "7. 多线程测试"
echo "8. 单线程测试"
echo "9. iperf3"
echo "10. 回程路由"
echo "0. 返回"
while true; do
read -p "请输入要执行的脚本编号用英文逗号分隔例如1,2,3):" script_numbers < /dev/tty
if [[ "$script_numbers" =~ ^(0|10|[1-7])(,(0|10|[1-7]))*$ ]]; then
read -p "请输入要执行的脚本编号用英文逗号分隔例如1,2,3):" script_numbers
if [[ "$script_numbers" =~ ^(0|10|[1-9])(,(0|10|[1-9]))*$ ]]; then
break
else
echo -e "${RED}无效输入请输入0-7之间的数字,用英文逗号分隔。${NC}"
echo -e "${RED}无效输入请输入0-10之间的数字,用英文逗号分隔。${NC}"
fi
done
if [[ "$script_numbers" == "0" ]]; then
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
if [ "$script_numbers" == "0" ]; then
clear
show_welcome
return # 确保退出函数,不再继续执行
else
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
generate_markdown_output "$base_output_file"
fi
# 分割用户输入为数组
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
# 所有脚本执行完毕后生成 Markdown 输出
generate_markdown_output "$base_output_file"
}
# 主菜单
main_menu() {
echo -e "${GREEN}测试项目:${NC}YabsIP质量流媒体解锁响应测试多线程测试单线程测试回程路由。"
echo -e "${GREEN}测试项目:${NC}YabsGeekbench5融合怪IP质量流媒体解锁响应测试多线程测试"
echo " 单线程测试iperf3回程路由。"
echo -e "${YELLOW}1. 执行所有测试脚本${NC}"
echo -e "${YELLOW}2. 选择特定测试脚本${NC}"
echo -e "${YELLOW}0. 退出${NC}"
# 提示输入并读取,从终端读取输入
read -p "请选择操作 [0-2]: " choice < /dev/tty
read -p "请选择操作 [0-2]: " choice
# 确保输入非空
if [[ -z "$choice" ]]; then
echo -e "${RED}输入为空,请重新输入。${NC}"
sleep 2s
clear
main_menu
return
fi
# 检查输入是否合法
case $choice in
1)
run_all_scripts
@ -574,23 +608,21 @@ main_menu() {
;;
*)
echo -e "${RED}无效选择,请重新输入。${NC}"
sleep 2s
sleep 3s
clear
main_menu
show_welcome
;;
esac
}
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo -e "${GREEN}Nodeloc聚合测试脚本 $CURRENT_VERSION ${NC}"
echo -e "${GREEN}GitHub地址: https://github.com/nodeloc/nodeloc_vps_test${NC}"
echo -e "${GREEN}Nodeloc社区: https://www.nodeloc.com/${NC}"
echo -e "${GREEN}GitHub地址: https://github.com/everett7623/nodeloc_vps_test${NC}"
echo -e "${GREEN}VPS选购: https://www.nodeloc.com/vps${NC}"
echo ""
echo -e "${colors[0]} _ _ ___ ____ _____ _ ___ ____ __ ______ ____ ${NC}"
echo -e "${colors[1]} | \ | |/ _ \| _ \| ____| | / _ \ / ___| \ \ / / _ \/ ___| ${NC}"

View File

@ -1,10 +1,9 @@
#!/bin/bash
# 定义版本
CURRENT_VERSION="2025-01-21 v1.2.7" # 最新版本号
SCRIPT_URL="https://ghfast.top/https://raw.githubusercontent.com/nodeloc/nodeloc_vps_test/main/Nlbench.sh"
VERSION_URL="https://ghfast.top/https://raw.githubusercontent.com/nodeloc/nodeloc_vps_test/main/version.sh"
CLOUD_SERVICE_BASE="https://bench.nodeloc.cc"
CURRENT_VERSION="2024-07-19 v1.0.6" # 最新版本号
SCRIPT_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/Nlbench_beta.sh"
VERSION_URL="https://raw.githubusercontent.com/everett7623/nodeloc_vps_test/main/version.sh"
# 定义颜色
RED='\033[0;31m'
@ -202,6 +201,7 @@ update_system() {
# 定义支持的操作系统类型
SUPPORTED_OS=("ubuntu" "debian" "linuxmint" "elementary" "pop" "centos" "rhel" "fedora" "rocky" "almalinux" "openeuler" "opensuse" "sles" "arch" "manjaro" "alpine" "gentoo" "cloudlinux")
# 安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
@ -214,7 +214,7 @@ install_dependencies() {
update_system || echo -e "${RED}系统更新失败。继续安装依赖项。${NC}"
# 安装依赖
local dependencies=("curl" "wget" "iperf3" "bc")
local dependencies=("curl" "wget" "iperf3")
# 检查是否为支持的操作系统
if [[ ! " ${SUPPORTED_OS[@]} " =~ " ${os_type} " ]]; then
@ -223,45 +223,48 @@ install_dependencies() {
fi
case "${os_type,,}" in
debian|ubuntu)
export DEBIAN_FRONTEND=noninteractive # 禁用交互
echo "iperf3 iperf3/autostart boolean false" | sudo debconf-set-selections
install_cmd="apt-get install -yq"
sudo apt-get update -yq
;;
centos|rhel|fedora)
install_cmd="dnf install -y"
sudo dnf makecache
gentoo)
install_cmd="emerge"
for dep in "${dependencies[@]}"; do
if ! emerge -p $dep &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd $dep; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
alpine)
install_cmd="apk add --no-cache"
;;
gentoo)
install_cmd="emerge --quiet"
;;
arch|manjaro)
install_cmd="pacman -S --noconfirm"
sudo pacman -Sy --noconfirm
install_cmd="apk add"
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
*)
echo -e "${RED}未知的包管理器。请手动安装依赖项。${NC}"
return 1
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
;;
esac
# 安装依赖项
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &>/dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo $install_cmd "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 获取IP地址和ISP信息
@ -318,9 +321,25 @@ detect_region() {
esac
}
# 服务器 VPS 信息
AUXILIARY_VPS="205.185.119.208"
IPERF_PORT=5201
TEST_DURATION=30
run_iperf3_test() {
echo -e "${GREEN}服务端VPS位于美国拉斯维加斯${NC}"
echo -e "${GREEN}连接到服务端进行iperf3测试。。。${NC}"
timeout ${TEST_DURATION}s iperf3 -c $AUXILIARY_VPS -p $IPERF_PORT -t $TEST_DURATION
if [ $? -eq 0 ]; then
echo -e "${YELLOW}iperf3 测试完成${NC}"
else
echo -e "${RED}iperf3 测试失败或超时${NC}"
fi
}
# 统计使用次数
sum_run_times() {
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fnodeloc%2Fnodeloc_vps_test%2Fblob%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Feverett7623%2Fnodeloc_vps_test%2Fblob%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
if [[ -n "$COUNT" ]]; then
daily_count=$(cut -d " " -f1 <<< "$COUNT")
total_count=$(cut -d " " -f3 <<< "$COUNT")
@ -347,10 +366,50 @@ run_script() {
sed -i 's/\.\.\./\.\.\.\n/g' "$temp_file"
sed -i '/\.\.\./d' "$temp_file"
sed -i '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_yabs"
cp "$temp_file" "${output_file}_yabs"
;;
# Geekbench5
2)
# 获取系统总内存包括swap单位为MB
total_memory_mb=$(free -m | awk '/^Mem:/{print $2}')
total_swap_mb=$(free -m | awk '/^Swap:/{print $2}')
total_memory_swap=$((total_memory_mb + total_swap_mb))
# 设置Geekbench 5所需的最小内存MB
min_required_memory=1024
if [ "$total_memory_swap" -lt "$min_required_memory" ]; then
echo "本机内存和Swap总计小于${min_required_memory}MB不满足GB5测试条件。"
echo "系统总内存: ${total_memory_mb}MB"
echo "Swap大小: ${total_swap_mb}MB"
echo "总计: ${total_memory_swap}MB"
echo "将跳过Geekbench 5测试进行其他测试项目。"
sleep 3
# 跳过Geekbench 5测试继续执行其他测试
# 可以在这里调用其他测试函数或脚本
else
echo -e "运行${YELLOW}Geekbench 5...${NC}"
bash <(curl -sL gb5.top) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\x1B\[.*?[mGKH]//g' "$temp_file"
sed -i 's/\r//' "$temp_file"
sed -i '/^$/d' "$temp_file"
sed -i -n '/当前时间:/,${p}' "$temp_file"
cp "$temp_file" "${output_file}_gb5"
fi
;;
# 融合怪
3)
echo -e "运行${YELLOW}融合怪...${NC}"
curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh -m 1 <<< "y" | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\.\.\.\./\.\.\.\.\.\.\n/g' "$temp_file"
sed -i '1,/\.\.\.\.\.\./d' "$temp_file"
sed -i -n '/--------------------- A Bench Script By spiritlhl ----------------------/,${s/^.*\(--------------------- A Bench Script By spiritlhl ----------------------\)/\1/;p}' "$temp_file"
cp "$temp_file" "${output_file}_fusion"
;;
# IP质量
2)
4)
echo -e "运行${YELLOW}IP质量测试...${NC}"
echo y | bash <(curl -Ls IP.Check.Place) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
@ -361,7 +420,7 @@ run_script() {
cp "$temp_file" "${output_file}_ip_quality"
;;
# 流媒体解锁
3)
5)
echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
local region=$(detect_region)
bash <(curl -L -s media.ispvps.com) <<< "$region" | tee "$temp_file"
@ -372,21 +431,21 @@ run_script() {
cp "$temp_file" "${output_file}_streaming"
;;
# 响应测试
4)
6)
echo -e "运行${YELLOW}响应测试...${NC}"
bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh) | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
cp "$temp_file" "${output_file}_response"
;;
# 多线程测速
5)
7)
echo -e "运行${YELLOW}多线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL https://ghfast.top/https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "3" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "3" | tee "$temp_file"
else
echo "使用IPv4测试选项"
bash <(curl -sL https://ghfast.top/https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "1" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "1" | tee "$temp_file"
fi
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
@ -396,14 +455,14 @@ run_script() {
cp "$temp_file" "${output_file}_multi_thread"
;;
# 单线程测速
6)
8)
echo -e "运行${YELLOW}单线程测速...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
bash <(curl -sL https://ghfast.top/https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "17" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "17" | tee "$temp_file"
else
echo "使用IPv4测试选项"
bash <(curl -sL https://ghfast.top/https://raw.githubusercontent.com/i-abc/Speedtest/main/speedtest.sh) <<< "2" | tee "$temp_file"
bash <(curl -sL bash.icu/speedtest) <<< "2" | tee "$temp_file"
fi
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
@ -412,15 +471,24 @@ run_script() {
sed -i '/^$/d' "$temp_file"
cp "$temp_file" "${output_file}_single_thread"
;;
# iperf3测试
9)
echo -e "运行${YELLOW}iperf3测试...${NC}"
run_iperf3_test | tee "$temp_file"
sed -i -e 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/\[ ID\] /d' "$temp_file"
sed -i '/^$/d' "$temp_file"
cp "$temp_file" "${output_file}_iperf3"
;;
# 回程路由
7)
10)
echo -e "运行${YELLOW}回程路由测试...${NC}"
if [ "$use_ipv6" = true ]; then
echo "使用IPv6测试选项"
wget -N --no-check-certificate https://ghfast.top/https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "4" | tee "$temp_file"
wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "4" | tee "$temp_file"
else
echo "使用IPv4测试选项"
wget -N --no-check-certificate https://ghfast.top/https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "1" | tee "$temp_file"
wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "1" | tee "$temp_file"
fi
sed -i -e 's/\x1B\[[0-9;]*[JKmsu]//g' -e '/No:1\/9 Traceroute to/,$!d' -e '/测试项/,+9d' -e '/信息/d' -e '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_route"
@ -433,59 +501,41 @@ run_script() {
# 生成最终的 Markdown 输出
generate_markdown_output() {
local base_output_file=$1
local temp_output_file="${base_output_file}.md"
local sections=("YABS" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "回程路由")
local file_suffixes=("yabs" "ip_quality" "streaming" "response" "multi_thread" "single_thread" "route")
local final_output_file="${base_output_file}.md"
local sections=("YABS" "Geekbench5" "融合怪" "IP质量" "流媒体" "响应" "多线程测速" "单线程测速" "iperf3" "回程路由")
local file_suffixes=("yabs" "gb5" "fusion" "ip_quality" "streaming" "response" "multi_thread" "single_thread" "iperf3" "route")
local empty_tabs=("去程路由" "Ping.pe" "哪吒 ICMP" "其他")
# 修改这里,添加 UTF-8 编码设置
echo "[tabs]" | iconv -f UTF-8 -t UTF-8//IGNORE > "$temp_output_file"
echo "[tabs]" > "$final_output_file"
# 输出有内容的标签
for i in "${!sections[@]}"; do
section="${sections[$i]}"
suffix="${file_suffixes[$i]}"
if [ -f "${base_output_file}_${suffix}" ]; then
echo "[tab=\"$section\"]" | iconv -f UTF-8 -t UTF-8//IGNORE >> "$temp_output_file"
echo "\`\`\`" >> "$temp_output_file"
cat "${base_output_file}_${suffix}" | iconv -f UTF-8 -t UTF-8//IGNORE >> "$temp_output_file"
echo "\`\`\`" >> "$temp_output_file"
echo "[/tab]" >> "$temp_output_file"
echo "[tab=\"$section\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
cat "${base_output_file}_${suffix}" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
rm "${base_output_file}_${suffix}"
fi
done
# 添加保留的空白标签
#for tab in "${empty_tabs[@]}"; do
# echo "[tab=\"$tab\"]" >> "$temp_output_file"
# echo "[/tab]" >> "$temp_output_file"
#done
for tab in "${empty_tabs[@]}"; do
echo "[tab=\"$tab\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
done
echo "[/tabs]" >> "$temp_output_file"
echo "[/tabs]" >> "$final_output_file"
# 上传文件 获取回调
local plain_uploaded_file=$(cat "${temp_output_file}" | curl -s -X POST --data-binary @- "${CLOUD_SERVICE_BASE}")
local plain_uploaded_file_path=$(echo "$plain_uploaded_file" | grep -oP "(?<=${CLOUD_SERVICE_BASE}).*")
local plain_uploaded_file_filename=$(basename "${plain_uploaded_file_path}")
if [ -n "$plain_uploaded_file" ]; then
local base_url=$(echo "${CLOUD_SERVICE_BASE}" | sed 's:/*$::')
local remote_url="${base_url}/result${plain_uploaded_file_path}"
echo -e "${remote_url}\r\nPlain ${plain_uploaded_file}" > "${plain_uploaded_file_filename}.url"
echo "测试结果已上传,您可以在以下链接查看:"
echo "${remote_url}"
echo "Plain ${plain_uploaded_file}"
echo "结果链接已保存到 ${plain_uploaded_file_filename}.url"
else
echo "上传失败. 结果已保存在本地文件 ${temp_output_file}"
fi
rm "$temp_output_file"
read -p "按回车键继续..." < /dev/tty
echo "所有测试完成,结果已保存在 $final_output_file 中。"
read -p "按回车键继续..."
clear
}
# 执行全部脚本
run_all_scripts() {
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
@ -497,68 +547,55 @@ run_all_scripts() {
clear
}
# 执行选定的脚本
run_selected_scripts() {
clear
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
echo -e "${YELLOW}Nodeloc VPS 自动测试脚本 $VERSION${NC}"
echo "1. Yabs"
echo "2. IP质量"
echo "3. 流媒体解锁"
echo "4. 响应测试"
echo "5. 多线程测试"
echo "6. 单线程测试"
echo "7. 回程路由"
echo "2. Geekbench5"
echo "3. 融合怪"
echo "4. IP质量"
echo "5. 流媒体解锁"
echo "6. 响应测试"
echo "7. 多线程测试"
echo "8. 单线程测试"
echo "9. iperf3"
echo "10. 回程路由"
echo "0. 返回"
while true; do
read -p "请输入要执行的脚本编号用英文逗号分隔例如1,2,3):" script_numbers < /dev/tty
if [[ "$script_numbers" =~ ^(0|10|[1-7])(,(0|10|[1-7]))*$ ]]; then
read -p "请输入要执行的脚本编号用英文逗号分隔例如1,2,3):" script_numbers
if [[ "$script_numbers" =~ ^(0|10|[1-9])(,(0|10|[1-9]))*$ ]]; then
break
else
echo -e "${RED}无效输入请输入0-7之间的数字,用英文逗号分隔。${NC}"
echo -e "${RED}无效输入请输入0-10之间的数字,用英文逗号分隔。${NC}"
fi
done
if [[ "$script_numbers" == "0" ]]; then
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
if [ "$script_numbers" == "0" ]; then
clear
show_welcome
return # 确保退出函数,不再继续执行
else
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
generate_markdown_output "$base_output_file"
fi
# 分割用户输入为数组
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
# 所有脚本执行完毕后生成 Markdown 输出
generate_markdown_output "$base_output_file"
}
# 主菜单
main_menu() {
echo -e "${GREEN}测试项目:${NC}YabsIP质量流媒体解锁响应测试多线程测试单线程测试回程路由。"
echo -e "${GREEN}测试项目:${NC}YabsGeekbench5融合怪IP质量流媒体解锁响应测试多线程测试"
echo " 单线程测试iperf3回程路由。"
echo -e "${YELLOW}1. 执行所有测试脚本${NC}"
echo -e "${YELLOW}2. 选择特定测试脚本${NC}"
echo -e "${YELLOW}0. 退出${NC}"
# 提示输入并读取,从终端读取输入
read -p "请选择操作 [0-2]: " choice < /dev/tty
read -p "请选择操作 [0-2]: " choice
# 确保输入非空
if [[ -z "$choice" ]]; then
echo -e "${RED}输入为空,请重新输入。${NC}"
sleep 2s
clear
main_menu
return
fi
# 检查输入是否合法
case $choice in
1)
run_all_scripts
@ -572,23 +609,21 @@ main_menu() {
;;
*)
echo -e "${RED}无效选择,请重新输入。${NC}"
sleep 2s
sleep 3s
clear
main_menu
show_welcome
;;
esac
}
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo -e "${GREEN}Nodeloc聚合测试脚本 $CURRENT_VERSION ${NC}"
echo -e "${GREEN}GitHub地址: https://github.com/nodeloc/nodeloc_vps_test${NC}"
echo -e "${GREEN}Nodeloc社区: https://www.nodeloc.com/${NC}"
echo -e "${GREEN}GitHub地址: https://github.com/everett7623/nodeloc_vps_test${NC}"
echo -e "${GREEN}VPS选购: https://www.nodeloc.com/vps${NC}"
echo ""
echo -e "${colors[0]} _ _ ___ ____ _____ _ ___ ____ __ ______ ____ ${NC}"
echo -e "${colors[1]} | \ | |/ _ \| _ \| ____| | / _ \ / ___| \ \ / / _ \/ ___| ${NC}"
@ -628,3 +663,6 @@ main() {
# 运行主函数
main
# 运行主函数
main

407
Nlbench_pro.sh Normal file
View File

@ -0,0 +1,407 @@
#!/bin/bash
# 定义版本
VERSION="1.0.2"
# 定义颜色
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# 检查 root 权限并获取 sudo 权限
if [ "$(id -u)" != "0" ]; then
echo "此脚本需要 root 权限运行。"
if ! sudo -v; then
echo "无法获取 sudo 权限,退出脚本。"
exit 1
fi
echo "已获取 sudo 权限。"
fi
# 检查并安装依赖
install_dependencies() {
echo -e "${YELLOW}正在检查并安装必要的依赖项...${NC}"
# 更新包列表
if ! sudo apt-get update; then
echo -e "${RED}无法更新包列表。请检查您的网络连接和系统设置。${NC}"
exit 1
fi
# 安装依赖
local dependencies=(
"curl"
"wget"
)
for dep in "${dependencies[@]}"; do
if ! command -v "$dep" &> /dev/null; then
echo -e "${YELLOW}正在安装 $dep...${NC}"
if ! sudo apt-get install -y "$dep"; then
echo -e "${RED}无法安装 $dep。请手动安装此依赖项。${NC}"
fi
else
echo -e "${GREEN}$dep 已安装。${NC}"
fi
done
echo -e "${GREEN}依赖项检查和安装完成。${NC}"
clear
}
# 获取IP地址
ip_address() {
ipv4_address=$(curl -s --max-time 5 ipv4.ip.sb)
if [ -z "$ipv4_address" ]; then
ipv4_address=$(ip -4 addr show | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '127.0.0.1' | head -n1)
fi
ipv6_address=$(curl -s --max-time 5 ipv6.ip.sb)
if [ -z "$ipv6_address" ]; then
ipv6_address=$(ip -6 addr show | grep -oP '(?<=inet6\s)[\da-f:]+' | grep -v '^::1' | grep -v '^fe80' | head -n1)
fi
}
# 检测VPS地理位置
detect_region() {
local country
country=$(curl -s ipinfo.io/country)
case $country in
"TW") echo "1" ;; # 台湾
"HK") echo "2" ;; # 香港
"JP") echo "3" ;; # 日本
"US" | "CA") echo "4" ;; # 北美
"BR" | "AR" | "CL") echo "5" ;; # 南美
"GB" | "DE" | "FR" | "NL" | "SE" | "NO" | "FI" | "DK" | "IT" | "ES" | "CH" | "AT" | "BE" | "IE" | "PT" | "GR" | "PL" | "CZ" | "HU" | "RO" | "BG" | "HR" | "SI" | "SK" | "LT" | "LV" | "EE") echo "6" ;; # 欧洲
"AU" | "NZ") echo "7" ;; # 大洋洲
"KR") echo "8" ;; # 韩国
"SG" | "MY" | "TH" | "ID" | "PH" | "VN") echo "9" ;; # 东南亚
"IN") echo "10" ;; # 印度
"ZA" | "NG" | "EG" | "KE" | "MA" | "TN" | "GH" | "CI" | "SN" | "UG" | "ET" | "MZ" | "ZM" | "ZW" | "BW" | "MW" | "NA" | "RW" | "SD" | "DJ" | "CM" | "AO") echo "11" ;; # 非洲
*) echo "0" ;; # 跨国平台
esac
}
# 统计使用次数
sum_run_times() {
local COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Feverett7623%2Fnodeloc_vps_test%2Fmain%2FNlbench.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
if [[ -n "$COUNT" ]]; then
daily_count=$(cut -d " " -f1 <<< "$COUNT")
total_count=$(cut -d " " -f3 <<< "$COUNT")
else
echo "Failed to fetch usage counts."
daily_count=0
total_count=0
fi
}
# 调用函数获取统计数据
sum_run_times
# 更新系统
update_system() {
if command -v apt &>/dev/null; then
apt-get update && apt-get upgrade -y
elif command -v dnf &>/dev/null; then
dnf check-update && dnf upgrade -y
elif command -v yum &>/dev/null; then
yum check-update && yum upgrade -y
elif command -v apk &>/dev/null; then
apk update && apk upgrade
else
echo -e "${RED}不支持的Linux发行版${NC}"
return 1
fi
return 0
}
# 执行单个脚本并输出结果到文件
run_script() {
local script_number=$1
local output_file=$2
local temp_file=$(mktemp)
case $script_number in
# YABS
1)
echo -e "运行${YELLOW}YABS...${NC}"
wget -qO- yabs.sh | bash | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\./\.\.\.\n/g' "$temp_file"
sed -i '/\.\.\./d' "$temp_file"
sed -i '/^\s*$/d' "$temp_file"
cp "$temp_file" "${output_file}_yabs"
;;
# 融合怪
2)
echo -e "运行${YELLOW}融合怪...${NC}"
curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh -m 1 <<< "y" | tee "$temp_file"
sed -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i 's/\.\.\.\.\.\./\.\.\.\.\.\.\n/g' "$temp_file"
sed -i '1,/\.\.\.\.\.\./d' "$temp_file"
sed -i '1,/\.\.\.\.\.\./d' "$temp_file"
cp "$temp_file" "${output_file}_fusion"
;;
# IP质量
3)
echo -e "运行${YELLOW}IP质量测试...${NC}"
bash <(curl -Ls IP.Check.Place) | tee "$temp_file"
sed 's/\x1B\[[0-9;]*[JKmsu]//g; /\.\.\.\.\.\.\.\.\.\./d' "$temp_file" > "${output_file}_ip_quality"
;;
# 流媒体解锁
4)
echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
local region=$(detect_region)
bash <(curl -L -s media.ispvps.com) <<< "$region" |tee "$temp_file"
sed 's/\x1B\[[0-9;]*[JKmsu]//g; 1,/脚本适配/d' "$temp_file" > "${output_file}_streaming"
;;
# 响应测试
5)
echo -e "运行${YELLOW}响应测试...${NC}"
bash <(curl -sL https://nodebench.mereith.com/scripts/curltime.sh) |tee "$temp_file"
sed 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file" > "${output_file}_response"
;;
# 多线程测速
6)
echo -e "运行${YELLOW}多线程测速...${NC}"
bash <(curl -sL bash.icu/speedtest) <<< "1" |tee "$temp_file"
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
sed -i -r 's/(⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)/\n/g' "$temp_file"
sed -i -r '/测试进行中/d' "$temp_file"
cp "$temp_file" "${output_file}_multi_thread"
;;
# 单线程测速
7)
echo -e "运行${YELLOW}单线程测速...${NC}"
bash <(curl -sL bash.icu/speedtest) <<< "2" |tee "$temp_file"
sed -r -i 's/\x1B\[[0-9;]*[JKmsu]//g' "$temp_file"
sed -i -r '1,/序号\:/d' "$temp_file"
sed -i -r 's/(⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏)/\n/g' "$temp_file"
sed -i -r '/测试进行中/d' "$temp_file"
cp "$temp_file" "${output_file}_single_thread"
;;
# 回程路由
8)
echo -e "运行${YELLOW}回程路由测试...${NC}"
wget -N --no-check-certificate https://raw.githubusercontent.com/Chennhaoo/Shell_Bash/master/AutoTrace.sh && chmod +x AutoTrace.sh && bash AutoTrace.sh <<< "1" |tee "$temp_file"
sed -e 's/\x1B\[[0-9;]*[JKmsu]//g' -e ' /测试项/,+9d' -e '/信息/d' -e '/^\s*$/d' "$temp_file" > "${output_file}_route"
;;
esac
rm "$temp_file"
echo -e "${GREEN}测试完成。${NC}"
}
# 生成最终的 Markdown 输出
generate_markdown_output() {
local base_output_file=$1
local final_output_file="${base_output_file}.md"
echo "[tabs]" > "$final_output_file"
echo "[tab=\"YABS\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_yabs" ]; then
cat "${base_output_file}_yabs" >> "$final_output_file"
rm "${base_output_file}_yabs"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"融合怪\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_fusion" ]; then
cat "${base_output_file}_fusion" >> "$final_output_file"
rm "${base_output_file}_fusion"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"IP质量\"]" >> "$final_output_file"
if [ -f "${base_output_file}_ip_quality" ]; then
cat "${base_output_file}_ip_quality" >> "$final_output_file"
rm "${base_output_file}_ip_quality"
fi
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"流媒体\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_streaming" ]; then
cat "${base_output_file}_streaming" >> "$final_output_file"
rm "${base_output_file}_streaming"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"响应\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_response" ]; then
cat "${base_output_file}_response" >> "$final_output_file"
rm "${base_output_file}_response"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"多线程测速\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_multi_thread" ]; then
cat "${base_output_file}_multi_thread" >> "$final_output_file"
rm "${base_output_file}_multi_thread"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"单线程测速\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_single_thread" ]; then
cat "${base_output_file}_single_thread" >> "$final_output_file"
rm "${base_output_file}_single_thread"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"回程路由\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
if [ -f "${base_output_file}_route" ]; then
cat "${base_output_file}_route" >> "$final_output_file"
rm "${base_output_file}_route"
fi
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"去程路由\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"iperf3\"]" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
echo "\`\`\`" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"Ping.pe\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"哪吒 ICMP\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[tab=\"其他\"]" >> "$final_output_file"
echo "[/tab]" >> "$final_output_file"
echo "[/tabs]" >> "$final_output_file"
echo "所有测试完成,结果已保存在 $final_output_file 中。"
read -p "按回车键继续..."
clear
}
# 执行全部脚本
run_all_scripts() {
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
echo "开始执行全部测试脚本..."
for i in {1..8}; do
run_script $i "$base_output_file"
done
generate_markdown_output "$base_output_file"
clear
}
# 执行选定的脚本
run_selected_scripts() {
clear
local base_output_file="NLvps_results_$(date +%Y%m%d_%H%M%S)"
echo -e "${YELLOW}Nodeloc VPS 自动测试脚本 $VERSION${NC}"
echo "1. Yabs"
echo "2. 融合怪"
echo "3. IP质量"
echo "4. 流媒体解锁"
echo "5. 响应测试"
echo "6. 多线程测试"
echo "7. 单线程测试"
echo "8. 回程路由"
echo "0. 返回"
read -p "请输入要执行的脚本编号用逗号分隔例如1,2,3):" script_numbers
IFS=',' read -ra selected_scripts <<< "$script_numbers"
echo "开始执行选定的测试脚本..."
if [ $script_numbers == "0" ]
then
clear
show_welcome
else
for number in "${selected_scripts[@]}"; do
clear
run_script "$number" "$base_output_file"
done
generate_markdown_output "$base_output_file"
fi
}
# 主菜单
main_menu() {
echo -e "${YELLOW}Nodeloc VPS 自动测试脚本 $VERSION${NC}"
echo -e "${GREEN}测试项目:${NC}Yabs融合怪IP质量流媒体解锁响应测试多线程测试单线程测试回程路由。"
echo -e "${YELLOW}1. 执行所有测试脚本${NC}"
echo -e "${YELLOW}2. 选择特定测试脚本${NC}"
echo -e "${YELLOW}0. 退出${NC}"
read -p "请选择操作 [0-2]: " choice
case $choice in
1)
run_all_scripts
;;
2)
run_selected_scripts
;;
0)
echo -e "${RED}感谢使用NodeLoc聚合测试脚本已退出脚本期待你的下次使用${NC}"
exit 0
;;
*)
echo -e "${RED}无效选择,请重新输入。${NC}"
sleep 3s
clear
show_welcome
;;
esac
}
# 输出欢迎信息
show_welcome() {
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
echo "Nodeloc_VPS_自动脚本测试 $VERSION"
echo "GitHub地址: https://github.com/everett7623/nodeloc_vps_test"
echo "VPS选购: https://www.nodeloc.com/vps"
echo ""
echo -e "${YELLOW}# # ##### #### ###### # #### #### # # #### ####${NC}"
echo -e "${YELLOW}## # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # ##### # # # # # # #### ####${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# # # # # # # # # # # # # # # # # #${NC}"
echo -e "${YELLOW}# ## ##### #### ###### ###### #### #### #### # ####${NC}"
echo ""
echo "支持Ubuntu/Debian"
echo ""
echo -e "今日运行次数: ${RED}$daily_count${NC} 次,累计运行次数: ${RED}$total_count${NC}"
echo ""
echo -e "${RED}---------------------------------By'Jensfrank---------------------------------${NC}"
echo ""
}
# 主函数
main() {
# 检查并安装依赖
install_dependencies
# 获取统计数据
sum_run_times
# 主循环
while true; do
show_welcome
main_menu
done
}
# 运行主函数
main

1281
README.md

File diff suppressed because it is too large Load Diff

View File

@ -1,494 +0,0 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>测试结果页面</title>
</head>
<body>
<div class="loading">
正在加载文件
</div>
<div class="tabs"></div>
<button class="copy-btn" data-clipboard-target="#copy-target">
复制论坛代码/Copy BBCode
</button>
<textarea id="copy-target"></textarea>
<style>
html {
--body-bg: #fff;
--muted-color: #546e7a;
--border-radius: 5px;
--primary-color: #0d47a1;
--control-bg: #bbdefb;
}
html,
body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
.copy-btn {
padding: 7px;
border-radius: var(--border-radius);
background: #0d47a1;
color: #fff;
vertical-align: bottom;
outline: 0;
border: unset;
box-shadow: 1px 1px 2px black;
cursor: pointer;
position: fixed;
left: 5px;
bottom: 5px;
}
.copy-btn:active {
box-shadow: 1px 1px 2px black inset;
}
#copy-target {
margin-top: 50px;
z-index: -1;
display: none;
}
.loading,
.error {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 100px;
text-align: center;
font-size: large;
z-index: 999;
}
.error {
background-color: #ffcdd2;
}
.loading {
background-color: #e3f2fd;
}
</style>
<style>
.tabs {
position: relative;
clear: both;
padding-top: 44px;
white-space: nowrap;
overflow: auto;
height: 28px;
max-width: 1000px;
margin: 0 auto;
}
.tabs .tab {
display: inline-block;
}
.tabs .tab:first-of-type label {
border-top-left-radius: var(--border-radius);
}
.tabs .tab:last-of-type label {
border-top-right-radius: var(--border-radius);
}
.tabs .tab label {
background: var(--body-bg);
padding: 10px 10px 7px;
border: 1px solid var(--muted-color);
margin-left: -1px;
position: relative;
left: 1px;
}
.tabs .tab [type="radio"] {
display: none;
}
.tabs .content-tab {
display: none;
position: fixed;
top: 72px;
left: 0;
background: var(--body-bg);
right: 0;
bottom: 100px;
padding: 10px 20px;
border: 1px solid var(--muted-color);
border-radius: 0 var(--border-radius) var(--border-radius)
var(--border-radius);
overflow-y: auto;
max-width: 1000px;
margin: 0 auto;
}
.tabs [type="radio"]:checked ~ label {
background: var(--control-bg);
border-bottom: 3px solid var(--primary-color);
}
.tabs [type="radio"]:checked ~ label ~ .content-tab {
display: block;
}
</style>
<script src="https://fastly.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
<script src="https://fastly.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
<script>
function getFilePath(fileName) {
// 从 URL 中提取路径部分
const urlSegments = location.pathname.split('/');
// 动态获取年份和月份
const year = urlSegments[2]; // 第二部分为年份
const month = urlSegments[3]; // 第三部分为月份
// 构造文件路径
return `/${year}/${month}/${fileName}`;
}
const fileNameMatch =
new URLSearchParams(window.location.search).get("filename") ||
location.pathname.split("/").pop();
if (fileNameMatch) {
const fileName = decodeURIComponent(fileNameMatch);
const filePath = getFilePath(fileName);
console.log(filePath);
$.ajax({
url: filePath,
success: render
});
}
function render(data) {
$("#copy-target").val(data);
$(".loading").remove();
$(".tabs").append(
$("<div>")
.addClass("tab")
.append(
$("<input>")
.attr("type", "radio")
.attr("id", `taball`)
.attr("name", "tabs")
.attr("checked", "checked")
)
.append($("<label>").attr("for", `taball`).text("全部/All"))
.append(
$("<div>")
.addClass("content-tab")
.append(
$("<code>")
.addClass("language-bbcode")
.append($("<pre>").text(data))
)
)
);
const tags = Array.from(
data.matchAll(/\[TAB=([^\]]*)\]([^]*?)\[\/tab\]/gi)
);
tags.forEach((tagMatching, i) => {
if (tagMatching[1] && tagMatching[2]) {
const tab = $("<div>")
.addClass("tab")
.append(
$("<input>")
.attr("type", "radio")
.attr("id", `tab-${i}`)
.attr("name", "tabs")
)
.append(
$("<label>").attr("for", `tab-${i}`).text(tagMatching[1])
);
const codeContentMatching = /```([^\s]*?)([^]*)```/.exec(
tagMatching[2]
);
const contentEl = $("<div>").addClass("content-tab");
if (codeContentMatching) {
const code = $("<code>").append(
$("<pre>").text(codeContentMatching[2])
);
if (codeContentMatching[1]) {
contentEl.addClass("language-" + codeContentMatching[1]);
}
contentEl.append(code);
} else {
contentEl.text(tagMatching[2]);
}
tab.append(contentEl);
$(".tabs").append(tab);
}
});
hljs.highlightAll();
new ClipboardJS(".copy-btn");
}
function fail() {
$(".loading").attr("class", "error").text("无法加载数据文件请检查URL");
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>测试结果页面</title>
</head>
<body>
<div class="loading">
正在加载文件
</div>
<div class="tabs"></div>
<div class="footer">
<button class="copy-btn" data-clipboard-target="#copy-target">
复制代码 / Copy
</button>
<button class="link-btn" id="visit-forum">
访问论坛 / Visit forum
</button>
</div>
<textarea id="copy-target"></textarea>
<style>
html {
--body-bg: #fff;
--muted-color: #546e7a;
--border-radius: 5px;
--primary-color: #0d47a1;
--control-bg: #bbdefb;
}
html,
body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: url('https://s.rmimg.com/2025/01/21/b5af503d48d3cacdddd5089dabe4a76c.jpg') no-repeat center center fixed;
background-size: cover;
font-family: Arial, sans-serif;
overflow: hidden;
}
.copy-btn {
padding: 7px;
border-radius: var(--border-radius);
background: #0d47a1;
color: #fff;
vertical-align: bottom;
outline: 0;
border: unset;
box-shadow: 1px 1px 2px black;
cursor: pointer;
}
.link-btn {
padding: 7px;
border-radius: var(--border-radius);
background: #0da148;
color: #fff;
vertical-align: bottom;
outline: 0;
border: unset;
box-shadow: 1px 1px 2px black;
cursor: pointer;
}
.copy-btn:active {
box-shadow: 1px 1px 2px black inset;
}
#copy-target {
margin-top: 50px;
z-index: -1;
width: 0px;
height: 0px;
}
.loading,
.error {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 100px;
text-align: center;
font-size: large;
z-index: 999;
}
.error {
background-color: #ffcdd2;
}
.loading {
background-color: #e3f2fd;
}
</style>
<style>
.footer{
position: fixed;
bottom: 50px;
width: 1000px;
max-width: 100%;
left: 50%;
transform: translateX(-50%);
clear: both;
}
.tabs {
position: relative;
clear: both;
padding-top: 44px;
white-space: nowrap;
height: 28px;
max-width: 1041px;
margin: 0 auto;
}
.tabs .tab {
display: inline-block;
}
.tabs .tab:first-of-type label {
border-top-left-radius: var(--border-radius);
}
.tabs .tab:last-of-type label {
border-top-right-radius: var(--border-radius);
}
.tabs .tab label {
background: var(--body-bg);
padding: 10px 10px 7px;
border: 1px solid var(--muted-color);
margin-left: -1px;
position: relative;
left: 1px;
opacity: 68%;
}
.tabs .tab [type="radio"] {
display: none;
}
.tabs .content-tab {
display: none;
position: fixed;
top: 72px;
left: 0;
background: #000;
right: 0;
color: #fff;
bottom: 100px;
padding: 10px 20px;
border: 1px solid var(--muted-color);
border-radius: 0 var(--border-radius) var(--border-radius)
var(--border-radius);
overflow-y: auto;
max-width: 1000px;
margin: 0 auto;
opacity: 0.68;
}
.tabs [type="radio"]:checked ~ label {
background: var(--control-bg);
border-bottom: 3px solid var(--primary-color);
}
.tabs [type="radio"]:checked ~ label ~ .content-tab {
display: block;
}
</style>
<script src="https://fastly.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>
<script src="https://fastly.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<script src="https://fastly.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
<script>
document.getElementById('visit-forum').addEventListener('click', function () {
window.location.href = "https://www.nodeloc.com";
});
function getFilePath(fileName) {
// 从 URL 中提取路径部分
const urlSegments = location.pathname.split('/');
// 动态获取年份和月份
const year = urlSegments[2]; // 第二部分为年份
const month = urlSegments[3]; // 第三部分为月份
// 构造文件路径
return `/${year}/${month}/${fileName}`;
}
const fileNameMatch =
new URLSearchParams(window.location.search).get("filename") ||
location.pathname.split("/").pop();
if (fileNameMatch) {
const fileName = decodeURIComponent(fileNameMatch);
const filePath = getFilePath(fileName);
console.log(filePath);
$.ajax({
url: filePath,
success: render
});
}
function render(data) {
$("#copy-target").val(data);
$(".loading").remove();
$(".tabs").append(
$("<div>")
.addClass("tab")
.append(
$("<input>")
.attr("type", "radio")
.attr("id", `taball`)
.attr("name", "tabs")
.attr("checked", "checked")
)
.append($("<label>").attr("for", `taball`).text("全部/All"))
.append(
$("<div>")
.addClass("content-tab")
.append(
$("<code>")
.addClass("language-bbcode")
.append($("<pre>").text(data))
)
)
);
const tags = Array.from(
data.matchAll(/\[TAB=([^\]]*)\]([^]*?)\[\/tab\]/gi)
);
tags.forEach((tagMatching, i) => {
if (tagMatching[1] && tagMatching[2]) {
const tab = $("<div>")
.addClass("tab")
.append(
$("<input>")
.attr("type", "radio")
.attr("id", `tab-${i}`)
.attr("name", "tabs")
)
.append(
$("<label>").attr("for", `tab-${i}`).text(tagMatching[1].replace(/"/g, ""))
);
const codeContentMatching = /```([^\s]*?)([^]*)```/.exec(
tagMatching[2]
);
const contentEl = $("<div>").addClass("content-tab");
if (codeContentMatching) {
const code = $("<code>").append(
$("<pre>").text(codeContentMatching[2])
);
if (codeContentMatching[1]) {
contentEl.addClass("language-" + codeContentMatching[1]);
}
contentEl.append(code);
} else {
contentEl.text(tagMatching[2]);
}
tab.append(contentEl);
$(".tabs").append(tab);
}
});
hljs.highlightAll();
new ClipboardJS(".copy-btn");
}
function fail() {
$(".loading").attr("class", "error").text("无法加载数据文件请检查URL");
}
</script>
</body>
</html>

View File

@ -1,61 +0,0 @@
<?php
function getHttpType(): string
{
return ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https'))
? 'https://' : 'http://';
}
// 检查是否有上传内容
$uploadData = file_get_contents('php://input');
if ($uploadData === false || empty($uploadData)) {
http_response_code(404);
die("Error 404: No data uploaded or invalid request.");
}
// 限制文件大小为 5MB
if (strlen($uploadData) > 5242880) {
http_response_code(500);
die("Error 500: File is too large. Maximum file size is 5MB.");
}
// 验证上传的文件是否为 txt 格式
$fileType = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $uploadData);
if ($fileType !== 'text/plain') {
http_response_code(500);
die("Error 500: Only plain text files (.txt) are allowed.");
}
// 清理控制字符
$uploadData = str_ireplace("\033[?25h", "", $uploadData);
// 获取当前年份和月份
$year = date('Y');
$month = date('m');
// 构造存储目录
$basePath = __DIR__ . "/";
$directory = $basePath . $year . "/" . $month . "/";
// 创建目录(如果不存在)
if (!is_dir($directory) && !mkdir($directory, 0755, true)) {
http_response_code(500);
die("Error 500: Failed to create directory.");
}
// 生成唯一文件名
$fileName = "NL" . time() . "-" . strtoupper(substr(md5($uploadData), 0, 6)) . ".txt";
// 构造文件 URL
$baseUrl = rtrim(getHttpType() . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']), '/'); // 去掉末尾多余的斜杠
$filePath = $directory . $fileName;
// 保存文件
if (file_put_contents($filePath, $uploadData) === false) {
http_response_code(500);
die("Error 500: Failed to save the file.");
}
// 返回文件 URL
echo $baseUrl . "/$year/$month/" . $fileName;

View File

@ -16,11 +16,3 @@
# 2024-08-08 v1.1.1 - 去除回程路由的ip等信息。
# 2024-08-13 v1.1.2 - 优化tab标签。
# 2024-08-19 v1.1.3 - 优化系统更新代码。
# 2024-08-28 v1.1.4 - 优化系统更新代码。
# 2024-09-07 v1.2.0 - 优化代码。
# 2024-09-07 v1.2.1 - 优化代码。
# 2024-09-07 v1.2.2 - 优化代码。
# 2024-09-08 v1.2.4 - 兼容新的接口。
# 2024-09-21 v1.2.5 - 修改bug。
# 2024-09-21 v1.2.6 - 删除融合怪。
# 2025-01-21 v1.2.7 - 改用Curl命令优化国内连接