fix(core): 替换容灾多宿主 IP 弹匣的拼接符(从逗号改为下划线),彻底解决因 Telegram 客户端及 API 特殊字符截断导致的多 IP 粘连失效问题

This commit is contained in:
hotyue
2026-06-01 12:27:00 +00:00
parent f57a4cd9e0
commit 56dc23009b
2 changed files with 9 additions and 9 deletions

View File

@@ -497,18 +497,18 @@ if [ "$UPGRADE_MODE" == "false" ]; then
# 注入次发弹药 (可用 IPv4)
if [[ -n "$DETECT_V4" ]] && [[ "$DETECT_V4" != "$PUBLIC_IP" ]]; then
COMM_IP="${COMM_IP},${DETECT_V4}"
COMM_IP="${COMM_IP}_${DETECT_V4}"
fi
# 注入保底弹药 (可用 IPv6带括号保护)
if [[ -n "$DETECT_V6" ]] && [[ "$DETECT_V6" != "$PUBLIC_IP" ]]; then
[[ "$DETECT_V6" != *"["* ]] && SAFE_V6="[${DETECT_V6}]" || SAFE_V6="$DETECT_V6"
COMM_IP="${COMM_IP},${SAFE_V6}"
COMM_IP="${COMM_IP}_${SAFE_V6}"
fi
SAFE_COMM_IP="$COMM_IP"
if [[ "$COMM_IP" == *","* ]]; then
if [[ "$COMM_IP" == *"_"* ]]; then
echo -e " \033[32m✅ 成功组装多宿主容灾通讯专线: $SAFE_COMM_IP\033[0m"
else
echo -e " \033[33m⚠ 本机仅有单一出口,建立单轨通讯模式: $SAFE_COMM_IP\033[0m"
@@ -659,14 +659,14 @@ if [ "$UPGRADE_MODE" == "true" ]; then
# 追加 V4 容灾备弹
if [[ -n "$RAW_V4" ]] && [[ "$NEW_COMM_IP" != *"$RAW_V4"* ]]; then
NEW_COMM_IP="${NEW_COMM_IP},${RAW_V4}"
NEW_COMM_IP="${NEW_COMM_IP}_${RAW_V4}"
fi
# 追加 V6 容灾备弹
if [[ -n "$RAW_V6" ]]; then
[[ "$RAW_V6" != *"["* ]] && SAFE_V6="[${RAW_V6}]" || SAFE_V6="$RAW_V6"
if [[ "$NEW_COMM_IP" != *"$SAFE_V6"* ]]; then
NEW_COMM_IP="${NEW_COMM_IP},${SAFE_V6}"
NEW_COMM_IP="${NEW_COMM_IP}_${SAFE_V6}"
fi
fi

View File

@@ -92,8 +92,8 @@ call_agent() {
local suffix="$4"
local res="FAILED"
# 拆解逗号分隔的 IP 列阵 (例如: [2a0b:...],66.181.x.x)
IFS=',' read -r -a ip_array <<< "$ips"
# 拆解下划线分隔的 IP 列阵 (例如: [2a0b...]_66.181.x.x)
IFS='_' read -r -a ip_array <<< "$ips"
for ip in "${ip_array[@]}"; do
if [ -n "$ip" ]; then
local url=$(generate_signed_url "$ip" "$port" "$path")
@@ -266,8 +266,8 @@ while true; do
db_exec "INSERT INTO nodes (chat_id, node_name, agent_ip, agent_port, last_seen, region, node_alias, enable_ota) VALUES ('$CHAT_ID', '$NODE_NAME', '$AGENT_IP', '$AGENT_PORT', CURRENT_TIMESTAMP, '$AGENT_REGION', '$NODE_ALIAS', '$AGENT_OTA') ON CONFLICT(chat_id, node_name) DO UPDATE SET agent_ip='$AGENT_IP', agent_port='$AGENT_PORT', last_seen=CURRENT_TIMESTAMP, region='$AGENT_REGION', node_alias='$NODE_ALIAS', enable_ota='$AGENT_OTA';"
# 动态人性化回执:在 TG 侧清晰地向管理者展示主备双通道的录入态势
MAIN_SHOW_IP=$(echo "$AGENT_IP" | cut -d',' -f1)
BACKUP_SHOW_IP=$(echo "$AGENT_IP" | cut -d',' -f2-)
MAIN_SHOW_IP=$(echo "$AGENT_IP" | cut -d'_' -f1)
BACKUP_SHOW_IP=$(echo "$AGENT_IP" | cut -d'_' -f2-)
if [ -n "$BACKUP_SHOW_IP" ]; then
SHOW_MSG="✅ **司令部确认 (v${MASTER_VERSION})**%0A节点 \`${NODE_ALIAS}\` 档案已录入!%0A🌐 主通讯:\`${MAIN_SHOW_IP}\`%0A📡 容灾备用:\`${BACKUP_SHOW_IP}\`"
else