feat(master): 控制面板支持显式标注物理中枢节点别名,提升多舰队架构管理体验

This commit is contained in:
hotyue
2026-05-29 01:00:39 +00:00
parent 22e7eb24ed
commit b4f78d4813
2 changed files with 27 additions and 1 deletions

View File

@@ -254,9 +254,27 @@ if [ "$UPGRADE_MODE" == "false" ]; then
fi
fi
# [中枢身份生成] 提取宿主特征生成全局唯一标识
MASTER_IP=$( (curl -4 -s -m 3 api.ip.sb/ip || curl -4 -s -m 3 ifconfig.me) 2>/dev/null | tr -d '[:space:]' )
MASTER_HASH=$(echo "${MASTER_IP:-127.0.0.1}" | md5sum | cut -c 1-4 | tr 'a-z' 'A-Z')
MASTER_NODE="$(hostname | tr -cd 'a-zA-Z0-9' | cut -c 1-10)-${MASTER_HASH}"
echo -e "\n[2.2/4] 司令部展示别名设定 (用于面板区分多台 VPS)"
echo -e "💡 系统底层的不可变主键为: \033[33m${MASTER_NODE}\033[0m"
read -p "请输入中枢展示别名 (如'美西主控机', 回车使用默认): " CUSTOM_MASTER_ALIAS
if [ -n "$CUSTOM_MASTER_ALIAS" ]; then
MASTER_NODE_NAME=$(echo "$CUSTOM_MASTER_ALIAS" | tr -d '"'\''\`\$\|&;<>\n\r' | cut -c 1-20)
[ -z "$MASTER_NODE_NAME" ] && MASTER_NODE_NAME="$MASTER_NODE"
else
MASTER_NODE_NAME="$MASTER_NODE"
fi
echo -e "✅ 已锁定司令部展示别名: \033[32m$MASTER_NODE_NAME\033[0m"
cat > "${MASTER_DIR}/master.conf" << EOF
# IP-Sentinel Master 本地固化配置 (v${TARGET_VERSION})
MASTER_VERSION="$TARGET_VERSION"
MASTER_NODE_NAME="$MASTER_NODE_NAME"
TG_TOKEN="$TG_TOKEN"
DB_FILE="$DB_FILE"
MASTER_DIR="$MASTER_DIR"
@@ -272,6 +290,13 @@ if [ "$UPGRADE_MODE" == "true" ]; then
if ! grep -q "^ENABLE_MASTER_OTA=" "${MASTER_DIR}/master.conf"; then
echo "ENABLE_MASTER_OTA=\"false\"" >> "${MASTER_DIR}/master.conf"
fi
# [热修复] 为老版本司令部平滑补齐中枢标识
if ! grep -q "^MASTER_NODE_NAME=" "${MASTER_DIR}/master.conf"; then
MASTER_IP=$( (curl -4 -s -m 3 api.ip.sb/ip || curl -4 -s -m 3 ifconfig.me) 2>/dev/null | tr -d '[:space:]' )
MASTER_HASH=$(echo "${MASTER_IP:-127.0.0.1}" | md5sum | cut -c 1-4 | tr 'a-z' 'A-Z')
MASTER_NODE_NAME="$(hostname | tr -cd 'a-zA-Z0-9' | cut -c 1-10)-${MASTER_HASH}"
echo "MASTER_NODE_NAME=\"$MASTER_NODE_NAME\"" >> "${MASTER_DIR}/master.conf"
fi
fi
# ----------------------------------------------------------

View File

@@ -277,7 +277,8 @@ while true; do
else
BTNS="[[{\"text\":\"🌍 进入全球雷达 (管理节点)\",\"callback_data\":\"list_nodes\"}], [{\"text\":\"🚀 唤醒全局巡逻\",\"callback_data\":\"all_run\"}, {\"text\":\"📊 获取全局简报\",\"callback_data\":\"all_reports\"}], [{\"text\":\"🌟 前往 GitHub 点亮星标\",\"url\":\"https://github.com/hotyue/IP-Sentinel\"}]]"
fi
TEXT_MSG="🛡️ **IP-Sentinel 控制中枢**\n${VER_INFO}\n\n📊 节点状态: 共有 \`${NODE_COUNT}\` 台节点在线\n欢迎回来管理者。请下达系统指令"
DISP_MASTER="${MASTER_NODE_NAME:-未命名中枢}"
TEXT_MSG="🛡️ **IP-Sentinel 控制中枢**\n${VER_INFO}\n📍 中枢节点: \`${DISP_MASTER}\`\n\n📊 节点状态: 共有 \`${NODE_COUNT}\` 台节点在线\n欢迎回来管理者。请下达系统指令"
send_ui "$CHAT_ID" "$TEXT_MSG" "$BTNS"
;;