|
|
@@ -11,13 +11,13 @@ DEFAULT_VERSION="v1.2"
|
|
|
# 国内使用 GitHub 代理加速
|
|
|
# 支持通过环境变量 GITHUB_PROXY 覆盖默认代理
|
|
|
# 备用代理列表(按优先级排序)
|
|
|
-GITHUB_PROXY_LIST="${GITHUB_PROXY:-https://mirror.ghproxy.com https://gh.ddlc.top https://ghfast.top https://github.moeyy.xyz}"
|
|
|
+GITHUB_PROXY_LIST="${GITHUB_PROXY:-https://ghfast.top https://gh.ddlc.top https://mirror.ghproxy.com https://github.moeyy.xyz}"
|
|
|
|
|
|
-# 测试代理是否可用
|
|
|
+# 测试代理是否可用(快速检测)
|
|
|
test_proxy() {
|
|
|
local proxy=$1
|
|
|
local test_url="${proxy}/https://api.github.com/repos/aiprodcoder/MIXAPI/releases/latest"
|
|
|
- wget -qO- --timeout=10 "$test_url" >/dev/null 2>&1
|
|
|
+ wget -qO- --timeout=5 --tries=1 "$test_url" >/dev/null 2>&1
|
|
|
return $?
|
|
|
}
|
|
|
|
|
|
@@ -36,18 +36,21 @@ get_working_proxy() {
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
-# 获取最新版本号(带重试机制)
|
|
|
+# 获取最新版本号(带重试机制,快速超时)
|
|
|
get_latest_version() {
|
|
|
local proxy
|
|
|
for proxy in $GITHUB_PROXY_LIST; do
|
|
|
local api_url="${proxy}/https://api.github.com/repos/aiprodcoder/MIXAPI/releases/latest"
|
|
|
- local version=$(wget -qO- --timeout=15 "$api_url" 2>/dev/null | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p')
|
|
|
+ echo "尝试获取版本: $api_url" >&2
|
|
|
+ local version=$(wget -qO- --timeout=8 --tries=1 "$api_url" 2>/dev/null | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p')
|
|
|
if [ -n "$version" ]; then
|
|
|
# 保存可用的代理供后续使用
|
|
|
WORKING_PROXY="$proxy"
|
|
|
+ echo "获取版本成功: $version (代理: $proxy)" >&2
|
|
|
echo "$version"
|
|
|
return 0
|
|
|
fi
|
|
|
+ echo "代理失败: $proxy" >&2
|
|
|
done
|
|
|
echo ""
|
|
|
return 1
|
|
|
@@ -89,18 +92,22 @@ download_version() {
|
|
|
if [ -n "$WORKING_PROXY" ]; then
|
|
|
local url="${WORKING_PROXY}/${github_path}"
|
|
|
echo "下载地址: ${url}"
|
|
|
- wget -qO "$target" --timeout=60 "$url" 2>/dev/null
|
|
|
+ wget -qO "$target" --timeout=30 --tries=2 "$url" 2>/dev/null
|
|
|
if [ $? -eq 0 ] && [ -s "$target" ]; then
|
|
|
chmod +x "$target"
|
|
|
return 0
|
|
|
fi
|
|
|
+ echo "首选代理下载失败,尝试其他代理..."
|
|
|
fi
|
|
|
|
|
|
# 遍历所有代理尝试下载
|
|
|
for proxy in $GITHUB_PROXY_LIST; do
|
|
|
+ # 跳过已经失败的首选代理
|
|
|
+ [ "$proxy" = "$WORKING_PROXY" ] && continue
|
|
|
+
|
|
|
local url="${proxy}/${github_path}"
|
|
|
echo "尝试下载: ${url}"
|
|
|
- wget -qO "$target" --timeout=60 "$url" 2>/dev/null
|
|
|
+ wget -qO "$target" --timeout=30 --tries=1 "$url" 2>/dev/null
|
|
|
|
|
|
if [ $? -eq 0 ] && [ -s "$target" ]; then
|
|
|
chmod +x "$target"
|