From d4e0ec8fb0c5d7bb713e69dfac6ab2fe3e2bbb7d Mon Sep 17 00:00:00 2001 From: Feng Yu Date: Sun, 5 Jul 2026 21:31:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(ecs):=20singbox=20=E5=88=86=E6=94=AF?= =?UTF-8?q?=E8=A1=A5=E9=BD=90=20ecs=5Faddress=20=E5=88=A4=E7=A9=BA,?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=BB=88=E7=AB=AF=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit singbox_modify.sh 之前 ecs_address 为空时仍写入 client_subnet:"", 导致 sing-box 启动时 netip.ParsePrefix("") 报 'no /' FATAL, 服务无法启动。根因是 get_ecsip.sh 在部分环境(如梅林 resolv.conf 无 # Interface wan 标记、members.3322.org 被限流)下拿不到公网 IP。 - singbox_modify.sh: 与 mihomo 分支对齐,加 [ -n ecs_address ] 判空, 失败时不写字段并 logger 告警 - clash_modify.sh: logger 补颜色码 33(黄色),使告警同样打印到终端, 原来无颜色码只写日志文件用户无感知 --- scripts/starts/clash_modify.sh | 2 +- scripts/starts/singbox_modify.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/starts/clash_modify.sh b/scripts/starts/clash_modify.sh index 8e539fa7..0424b35e 100644 --- a/scripts/starts/clash_modify.sh +++ b/scripts/starts/clash_modify.sh @@ -21,7 +21,7 @@ prepare_clash_base_config() { if [ -n "$ecs_address" ];then dns_fallback=$(echo "$dns_fallback, " | sed "s|, |#ecs-override=true\&ecs=$ecs_address, |g" | sed 's|, $||') else - logger "自动获取ecs网段失败!" + logger "自动获取ecs网段失败!" 33 fi } } diff --git a/scripts/starts/singbox_modify.sh b/scripts/starts/singbox_modify.sh index ebd19c3a..b430ec95 100644 --- a/scripts/starts/singbox_modify.sh +++ b/scripts/starts/singbox_modify.sh @@ -113,7 +113,11 @@ prepare_dns_config() { #ecs优化 [ "$ecs_subnet" = ON ] && { . "$CRASHDIR"/libs/get_ecsip.sh - client_subnet='"client_subnet": "'"$ecs_address"'",' + if [ -n "$ecs_address" ]; then + client_subnet='"client_subnet": "'"$ecs_address"'",' + else + logger "自动获取ecs网段失败!" 33 + fi } #根据dns模式生成 [ "$dns_mod" = "redir_host" ] && {