mirror of
https://github.com/fscarmen/sing-box.git
synced 2026-08-10 17:55:16 +08:00
fix: GitHub API 403 rate limit error caused sing-box download failure.
This commit is contained in:
+26
-18
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# 当前脚本版本号
|
# 当前脚本版本号
|
||||||
VERSION='v1.2.17 (2025.04.25)'
|
VERSION='v1.2.17 (2025.05.11)'
|
||||||
|
|
||||||
# 各变量默认值
|
# 各变量默认值
|
||||||
GH_PROXY='https://ghfast.top/'
|
GH_PROXY='https://ghfast.top/'
|
||||||
@@ -18,6 +18,7 @@ NODE_TAG=("xtls-reality" "hysteria2" "tuic" "ShadowTLS" "shadowsocks" "trojan" "
|
|||||||
CONSECUTIVE_PORTS=${#PROTOCOL_LIST[@]}
|
CONSECUTIVE_PORTS=${#PROTOCOL_LIST[@]}
|
||||||
CDN_DOMAIN=("skk.moe" "ip.sb" "time.is" "cfip.xxxxxxxx.tk" "bestcf.top" "cdn.2020111.xyz" "xn--b6gac.eu.org")
|
CDN_DOMAIN=("skk.moe" "ip.sb" "time.is" "cfip.xxxxxxxx.tk" "bestcf.top" "cdn.2020111.xyz" "xn--b6gac.eu.org")
|
||||||
SUBSCRIBE_TEMPLATE="https://raw.githubusercontent.com/fscarmen/client_template/main"
|
SUBSCRIBE_TEMPLATE="https://raw.githubusercontent.com/fscarmen/client_template/main"
|
||||||
|
DEFAULT_NEWEST_VERSION='1.12.0-beta.11'
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
@@ -638,15 +639,8 @@ check_install() {
|
|||||||
|
|
||||||
if [ "${STATUS[0]}" = "$(text 26)" ] && [ ! -s ${WORK_DIR}/sing-box ]; then
|
if [ "${STATUS[0]}" = "$(text 26)" ] && [ ! -s ${WORK_DIR}/sing-box ]; then
|
||||||
{
|
{
|
||||||
# FORCE_VERSION 用于在 sing-box 某个主程序出现 bug 时,强制为指定版本,以防止运行出错
|
# 获取需要下载的 sing-box 版本
|
||||||
local FORCE_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://raw.githubusercontent.com/fscarmen/sing-box/refs/heads/main/force_version | sed 's/^[vV]//g; s/\r//g')
|
ONLINE=$(get_sing_box_version)
|
||||||
if grep -q '.' <<< "$FORCE_VERSION"; then
|
|
||||||
local ONLINE="$FORCE_VERSION"
|
|
||||||
else
|
|
||||||
local VERSION_LATEST=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v-]' '/tag_name/{print $5}' | sort -Vr | sed -n '1p')
|
|
||||||
local ONLINE=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
|
|
||||||
ONLINE=${ONLINE:-'1.12.0'}
|
|
||||||
fi
|
|
||||||
wget --no-check-certificate --continue ${GH_PROXY}https://github.com/SagerNet/sing-box/releases/download/v$ONLINE/sing-box-$ONLINE-linux-$SING_BOX_ARCH.tar.gz -qO- | tar xz -C $TEMP_DIR sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box >/dev/null 2>&1
|
wget --no-check-certificate --continue ${GH_PROXY}https://github.com/SagerNet/sing-box/releases/download/v$ONLINE/sing-box-$ONLINE-linux-$SING_BOX_ARCH.tar.gz -qO- | tar xz -C $TEMP_DIR sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box >/dev/null 2>&1
|
||||||
[ -s $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box ] && mv $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box $TEMP_DIR
|
[ -s $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box ] && mv $TEMP_DIR/sing-box-$ONLINE-linux-$SING_BOX_ARCH/sing-box $TEMP_DIR
|
||||||
wget --no-check-certificate --continue -qO $TEMP_DIR/jq ${GH_PROXY}https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$JQ_ARCH >/dev/null 2>&1 && chmod +x $TEMP_DIR/jq >/dev/null 2>&1
|
wget --no-check-certificate --continue -qO $TEMP_DIR/jq ${GH_PROXY}https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-$JQ_ARCH >/dev/null 2>&1 && chmod +x $TEMP_DIR/jq >/dev/null 2>&1
|
||||||
@@ -811,6 +805,25 @@ del_port_hopping_nat(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 获取 sing-box 最新版本
|
||||||
|
get_sing_box_version() {
|
||||||
|
# FORCE_VERSION 用于在 sing-box 某个主程序出现 bug 时,强制为指定版本,以防止运行出错
|
||||||
|
local FORCE_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://raw.githubusercontent.com/fscarmen/sing-box/refs/heads/main/force_version | sed 's/^[vV]//g; s/\r//g')
|
||||||
|
if grep -q '.' <<< "$FORCE_VERSION"; then
|
||||||
|
local RESULT_VERSION="$FORCE_VERSION"
|
||||||
|
else
|
||||||
|
# 先判断 github api 返回 http 状态码是否为 200,有时候 IP 会被限制,导致获取不到最新版本
|
||||||
|
local API_RESPONSE=$(wget --no-check-certificate --server-response --tries=2 --timeout=3 -qO- "${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases" 2>&1 | grep -E '^[ ]+HTTP/|tag_name')
|
||||||
|
if ! grep -q 'HTTP.* 200' <<< "$API_RESPONSE"; then
|
||||||
|
local VERSION_LATEST=$(awk -F '["v-]' '/tag_name/{print $5}' <<< "$API_RESPONSE" | sort -Vr | sed -n '1p')
|
||||||
|
local RESULT_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
|
||||||
|
else
|
||||||
|
local RESULT_VERSION="$DEFAULT_NEWEST_VERSION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "$RESULT_VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
# 添加端口跳跃
|
# 添加端口跳跃
|
||||||
add_port_hopping_nat() {
|
add_port_hopping_nat() {
|
||||||
local PORT_HOPPING_START=$1
|
local PORT_HOPPING_START=$1
|
||||||
@@ -3248,16 +3261,11 @@ uninstall() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Sing-box 的最新版本
|
# Sing-box 的最新版本
|
||||||
version() {
|
version() {
|
||||||
# FORCE_VERSION 用于在 sing-box 某个主程序出现 bug 时,强制为指定版本,以防止运行出错
|
# 获取需要下载的 sing-box 版本
|
||||||
local FORCE_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://raw.githubusercontent.com/fscarmen/sing-box/refs/heads/main/force_version | sed 's/^[vV]//g; s/\r//g')
|
ONLINE=$(get_sing_box_version)
|
||||||
if grep -q '.' <<< "$FORCE_VERSION"; then
|
|
||||||
local ONLINE="$FORCE_VERSION"
|
|
||||||
else
|
|
||||||
local VERSION_LATEST=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v-]' '/tag_name/{print $5}' | sort -Vr | sed -n '1p')
|
|
||||||
local ONLINE=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
|
|
||||||
fi
|
|
||||||
|
|
||||||
grep -q '.' <<< "$ONLINE" || error " $(text 100) \n"
|
grep -q '.' <<< "$ONLINE" || error " $(text 100) \n"
|
||||||
local LOCAL=$(${WORK_DIR}/sing-box version | awk '/version/{print $NF}')
|
local LOCAL=$(${WORK_DIR}/sing-box version | awk '/version/{print $NF}')
|
||||||
|
|||||||
Reference in New Issue
Block a user