refactor(shell): 代理测试失败时尝试 Google

This commit is contained in:
2026-06-19 12:29:47 +08:00
parent 60be84cb95
commit 259fb246b8
+9 -1
View File
@@ -79,7 +79,7 @@ function proxy_test() {
return 1
fi
# 2. 通过代理访问 GitHub(翻墙连通性测试)
# 2. 通过代理访问 GitHub(翻墙连通性测试),不通则试 Google
echo -n "代理访问 https://github.com: "
code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 8 \
-x "${HTTP_PROXY_URL}" https://github.com 2>/dev/null)
@@ -87,6 +87,14 @@ function proxy_test() {
echo -e "\033[32m✓ HTTP ${code}\033[0m"
else
echo -e "\033[31m✗ 失败(${code:-N/A}\033[0m"
echo -n "代理访问 https://www.google.com: "
code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 8 \
-x "${HTTP_PROXY_URL}" https://www.google.com 2>/dev/null)
if [ -n "$code" ] && [ "$code" -ge 200 ] && [ "$code" -lt 400 ]; then
echo -e "\033[32m✓ HTTP ${code}\033[0m"
else
echo -e "\033[31m✗ 失败(${code:-N/A}\033[0m"
fi
fi
# 3. 显示当前出口 IP(直连,便于与走代理后的 IP 对比)