Update nodeloc_vps_autotest.sh

This commit is contained in:
Jensfrank 2024-06-26 20:21:13 +08:00 committed by GitHub
parent 708091f650
commit e6c310e991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -63,14 +63,21 @@ install_dependencies() {
echo -e "${GREEN}依赖项检查和安装完成。${NC}" echo -e "${GREEN}依赖项检查和安装完成。${NC}"
} }
# 函数:运行命令并捕获输出 # 统计使用次数
run_and_capture() { sum_run_times() {
local output local COUNT
output=$(eval "$1" 2>&1) COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.sh" 2>&1 | grep -m1 -oE "[0-9]+[ ]+/[ ]+[0-9]+")
echo "$output" 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
} }
# 函数检测VPS地理位置 # 检测VPS地理位置
detect_region() { detect_region() {
local country local country
country=$(curl -s ipinfo.io/country) country=$(curl -s ipinfo.io/country)
@ -90,18 +97,18 @@ detect_region() {
esac esac
} }
# 流媒体解锁测试函数 # 函数:运行命令并捕获输出
run_streaming_test() { run_and_capture() {
local region local output
region=$(detect_region) output=$(eval "$1" 2>&1)
echo "运行${YELLOW}流媒体解锁测试...${NC}" echo "$output"
streaming_result=$(run_and_capture "echo '$region' | bash <(curl -L -s media.ispvps.com)")
} }
# 格式化结果为 Markdown # Markdown输出结果
format_results() { format_results()
echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}" {
result="[tabs] echo -e "${YELLOW}此报告由Nodeloc_VPS_自动脚本测试生成...${NC}"
result="[tabs]
[tab=\"YABS\"] [tab=\"YABS\"]
\`\`\` \`\`\`
$yabs_result $yabs_result
@ -185,19 +192,7 @@ copy_to_clipboard() {
fi fi
} }
# 统计使用次数
sum_run_times() {
local COUNT
COUNT=$(wget --no-check-certificate -qO- --tries=2 --timeout=2 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/everett7623/nodeloc_vps_test/blob/main/nodeloc_vps_autotest.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
}
# 输出欢迎信息 # 输出欢迎信息
show_welcome() { show_welcome() {
@ -254,7 +249,9 @@ run_all_tests() {
# 流媒体解锁 # 流媒体解锁
echo -e "运行${YELLOW}流媒体解锁测试...${NC}" echo -e "运行${YELLOW}流媒体解锁测试...${NC}"
run_streaming_test local region
region=$(detect_region)
streaming_result=$(run_and_capture "echo '$region' | bash <(curl -L -s media.ispvps.com)")
# 响应测试 # 响应测试
echo -e "运行${YELLOW}响应测试...${NC}" echo -e "运行${YELLOW}响应测试...${NC}"