From 84832395bd2c55f9302e953e29f662ac27664a63 Mon Sep 17 00:00:00 2001 From: hotyue <52734432+hotyue@users.noreply.github.com> Date: Mon, 13 Apr 2026 12:00:00 +0000 Subject: [PATCH] =?UTF-8?q?fix(daemon):=20=F0=9F=94=87=20=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E5=85=AC=E7=BD=91=20IP=20=E5=85=9C=E5=BA=95=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E5=BD=BB=E5=BA=95=E6=8B=A6=E6=88=AA=E5=9B=A0?= =?UTF-8?q?=20API=20=E6=8E=A2=E6=B5=8B=E5=A4=B1=E8=B4=A5=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E5=B9=BD=E7=81=B5=E6=B3=A8=E5=86=8C=E9=A3=8E=E6=9A=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/agent_daemon.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/agent_daemon.sh b/core/agent_daemon.sh index 14d3fa1..bd4b410 100755 --- a/core/agent_daemon.sh +++ b/core/agent_daemon.sh @@ -1,7 +1,7 @@ #!/bin/bash # ========================================================== -# 脚本名称: agent_daemon.sh (受控节点 Webhook 守护进程 V3.0.3) +# 脚本名称: agent_daemon.sh (受控节点 Webhook 守护进程 V3.3.1) # 核心功能: 智能防打扰注册、进程自检、模块级路由分发(403拦截) # ========================================================== @@ -24,14 +24,18 @@ if pgrep -f "webhook.py $AGENT_PORT" > /dev/null; then exit 0 fi -# 1. [v3.0.1修复] 严格按照 install.sh 锁定的网络协议 (v4/v6) 获取 IP +# 1. 尝试获取实时公网 IP RAW_IP=$(curl -${IP_PREF:-4} -s -m 5 api.ip.sb/ip | tr -d '[:space:]') -# 为新获取到的 v6 自动加方括号,以确保与之前锁定的格式对齐比对 -if [[ "$RAW_IP" == *":"* ]] && [[ "$RAW_IP" != *"["* ]]; then - AGENT_IP="[${RAW_IP}]" +# [v3.3.1 修改] 为新获取到的 v6 自动加方括号;如果网络波动没抓到,强制信任本地 config 中的公网面孔 +if [ -n "$RAW_IP" ]; then + if [[ "$RAW_IP" == *":"* ]] && [[ "$RAW_IP" != *"["* ]]; then + AGENT_IP="[${RAW_IP}]" + else + AGENT_IP="$RAW_IP" + fi else - AGENT_IP="$RAW_IP" + AGENT_IP="${PUBLIC_IP:-${BIND_IP:-Unknown}}" fi if [ -n "$AGENT_IP" ]; then