From c4655542575351103ef33e2903facbd281a88bbf Mon Sep 17 00:00:00 2001 From: 3344 Date: Mon, 2 Mar 2026 16:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20xu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xu | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/xu b/xu index 34fa824..539b4b2 100644 --- a/xu +++ b/xu @@ -4,7 +4,7 @@ # 标题:X-UI 全能安装脚本 (全面中文化定制版) # 更新:1. 增加双重密码验证机制 (模式1/模式2独立密码) # 2. 新增官方流程模式 (自选账号密码端口) -# 3. 保持自定义核心下载链路,彻底脱离 GitHub +# 3. 采用“智能防卡死机制”代替死板的绝对超时 # ========================================== # --- 颜色配置 --- @@ -226,7 +226,7 @@ DOWNLOAD_URL_2="https://ghproxy.net/https://github.com/vaxilu/x-ui/releases/down DOWNLOAD_URL_3="https://github.moeyy.xyz/https://github.com/vaxilu/x-ui/releases/download/v2.8.10/${FILE_NAME}" # ========================================== -# 6. 智能下载管理器 +# 6. 智能下载管理器 (动态防卡死机制) # ========================================== download_manager() { local file=$1 @@ -237,23 +237,31 @@ download_manager() { echo -e "\n${Yellow}>> 正在尝试拉取链接: ${url}${Font}" rm -f "$file" + # 优先级 1: Axel (移除死板超时,依赖内部机制,只要在下载就不停) if command -v axel >/dev/null 2>&1; then - echo -e "${Green}>> [策略1] 启用 Axel 引擎 (限制30秒)...${Font}" - if timeout 30 axel -n 16 -k -o "$file" "$url"; then return 0; fi - echo -e "${Red}Axel 超时或失败,切换下一个引擎...${Font}" + echo -e "${Green}>> [策略1] 启用 Axel 引擎 (速度正常不断开)...${Font}" + if axel -n 16 -k -o "$file" "$url"; then return 0; fi + echo -e "${Red}Axel 连接失败或异常中断,切换下一个引擎...${Font}" fi + # 优先级 2: Aria2 (最低速度防卡死) if command -v aria2c >/dev/null 2>&1; then - echo -e "${Green}>> [策略2] 启用 Aria2 引擎 (限制30秒)...${Font}" - if timeout 30 aria2c -x 16 -s 16 -k 1M -o "$file" "$url"; then return 0; fi - echo -e "${Red}Aria2 超时或失败,切换下一个引擎...${Font}" + echo -e "${Green}>> [策略2] 启用 Aria2 引擎 (检测到有数据不断开)...${Font}" + # --connect-timeout=15: 15秒连不上直接换 + # --lowest-speed-limit=10K: 若速度掉到10K以下持续一定时间,说明网络死掉,此时才换 + if aria2c -x 16 -s 16 -k 1M --connect-timeout=15 --lowest-speed-limit=10K -o "$file" "$url"; then return 0; fi + echo -e "${Red}Aria2 连接失败或彻底卡死,切换下一个引擎...${Font}" fi - echo -e "${Yellow}>> [策略3] 启用 Wget 单线程下载 (限制30秒)...${Font}" - if wget $NET_OPT --no-check-certificate --timeout=30 --tries=1 -O "$file" "$url"; then return 0; fi + # 优先级 3: Wget (读写超时防卡死) + echo -e "${Yellow}>> [策略3] 启用 Wget 单线程下载 (有数据传输不断开)...${Font}" + # --read-timeout=30: 只要不断流,不管下多久都不会切;断流30秒无响应才会切 + if wget $NET_OPT --no-check-certificate --connect-timeout=15 --read-timeout=30 --tries=2 -O "$file" "$url"; then return 0; fi - echo -e "${Yellow}>> [策略4] 启用 Curl 保底下载 (限制30秒)...${Font}" - if curl $NET_OPT -L -k --connect-timeout 10 --max-time 30 --retry 1 -o "$file" "$url"; then return 0; fi + # 优先级 4: Curl (保底防卡死) + echo -e "${Yellow}>> [策略4] 启用 Curl 保底下载...${Font}" + # --speed-time 30 --speed-limit 1024: 速度低于1KB/s持续30秒才判定为卡死 + if curl $NET_OPT -L -k --connect-timeout 15 --speed-time 30 --speed-limit 1024 --retry 2 -o "$file" "$url"; then return 0; fi echo -e "${Red}>> 当前链接下载失败,正在切换备用节点...${Font}" done