From 423a765e5fd3d3ca28f3bc005c8c102bf71167f1 Mon Sep 17 00:00:00 2001 From: hotyue <52734432+hotyue@users.noreply.github.com> Date: Wed, 15 Apr 2026 05:58:28 +0000 Subject: [PATCH] =?UTF-8?q?feat(core):=20=E5=BC=95=E5=85=A5=20KV=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=88=86=E8=A7=A3=E6=B3=95=EF=BC=8C=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=20Agent=20=E4=B8=8E=20Master=20=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=8B=AC=E7=AB=8B=E8=A7=A3=E8=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/install.sh | 6 +++--- core/tg_report.sh | 4 ++-- master/install_master.sh | 6 ++++-- master/tg_master.sh | 4 ++-- version.txt | 3 ++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/install.sh b/core/install.sh index b117f7f..f1ded62 100755 --- a/core/install.sh +++ b/core/install.sh @@ -12,10 +12,10 @@ REPO_RAW_URL="https://raw.githubusercontent.com/hotyue/IP-Sentinel/main" INSTALL_DIR="/opt/ip_sentinel" CONFIG_FILE="${INSTALL_DIR}/config.conf" -# [核心: 动态获取全局版本控制锚点 (Single Source of Truth)] -TARGET_VERSION=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | tr -d '[:space:]') +# [核心: 动态提取 Agent 专属版本锚点 (KV 解析法)] +TARGET_VERSION=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | grep "^AGENT_VERSION=" | cut -d'=' -f2 | tr -d '[:space:]') # 🛡️ 兜底防线:如果网络波动拉取失败,启用内置的安全兜底版本 -TARGET_VERSION=${TARGET_VERSION:-"3.5.0"} +TARGET_VERSION=${TARGET_VERSION:-"3.5.1"} # 轻量级版本号比对函数 (例如: version_lt "3.3.1" "3.4.0" 返回 true) version_lt() { diff --git a/core/tg_report.sh b/core/tg_report.sh index c936181..2126917 100755 --- a/core/tg_report.sh +++ b/core/tg_report.sh @@ -165,9 +165,9 @@ fi # 从配置文件提取当前本地版本,若无则默认为未知 LOCAL_VER="${AGENT_VERSION:-未知}" -# 极轻量级探针: 抓取 GitHub 云端的 version.txt (超时 3 秒) +# 极轻量级探针: 抓取 GitHub 云端的 version.txt (超时 3 秒,KV解析法) REPO_RAW_URL="https://raw.githubusercontent.com/hotyue/IP-Sentinel/main" -REMOTE_VER=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | tr -d '[:space:]') +REMOTE_VER=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | grep "^AGENT_VERSION=" | cut -d'=' -f2 | tr -d '[:space:]') # 构建底部引擎状态块 MSG="$MSG diff --git a/master/install_master.sh b/master/install_master.sh index 72efac8..7bbd357 100755 --- a/master/install_master.sh +++ b/master/install_master.sh @@ -10,8 +10,10 @@ REPO_RAW_URL="https://raw.githubusercontent.com/hotyue/IP-Sentinel/main" # 临时改为私库地址用于测试 # REPO_RAW_URL="https://git.94211762.xyz/hotyue/IP-Sentinel/raw/branch/main" -# [核心: 动态获取全局版本控制锚点 (Single Source of Truth)] -TARGET_VERSION=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | tr -d '[:space:]') +# [核心: 动态提取 Master 专属版本锚点 (KV 解析法)] +# 通过 grep 定位 MASTER_VERSION 行,再通过 cut 提取等号右侧的值 +TARGET_VERSION=$(curl -s -m 3 "${REPO_RAW_URL}/version.txt" | grep "^MASTER_VERSION=" | cut -d'=' -f2 | tr -d '[:space:]') + # 🛡️ 兜底防线:如果网络波动拉取失败,启用内置的安全兜底版本 TARGET_VERSION=${TARGET_VERSION:-"3.5.0"} diff --git a/master/tg_master.sh b/master/tg_master.sh index 93e5d82..df73b7f 100755 --- a/master/tg_master.sh +++ b/master/tg_master.sh @@ -152,8 +152,8 @@ while true; do # ========================================== case "$TEXT" in "/start"|"/menu") - # [v3.4.0 核心] 抓取云端最新版本 - REMOTE_VER=$(curl -s -m 2 "${REPO_RAW_URL}/version.txt" | tr -d '[:space:]') + # [核心: 抓取云端最新 Master 版本 (KV 解析法)] + REMOTE_VER=$(curl -s -m 2 "${REPO_RAW_URL}/version.txt" | grep "^MASTER_VERSION=" | cut -d'=' -f2 | tr -d '[:space:]') VER_INFO="当前版本: \`v${MASTER_VERSION}\`" if [ -n "$REMOTE_VER" ] && [ "$REMOTE_VER" != "$MASTER_VERSION" ]; then diff --git a/version.txt b/version.txt index e5b8203..bf5f54e 100644 --- a/version.txt +++ b/version.txt @@ -1 +1,2 @@ -3.5.0 \ No newline at end of file +AGENT_VERSION=3.5.1 +MASTER_VERSION=3.5.0 \ No newline at end of file