diff --git a/scripts/libs/get_ecsip.sh b/scripts/libs/get_ecsip.sh index fa0b68a52..ba8e10a20 100644 --- a/scripts/libs/get_ecsip.sh +++ b/scripts/libs/get_ecsip.sh @@ -6,8 +6,9 @@ get_ecs_address() { [ -n "$ip" ] && return done . "$CRASHDIR"/libs/web_get_lite.sh - for web in http://members.3322.org/dyndns/getip http://4.ipw.cn http://ipinfo.io/ip; do - ip=$(web_get_lite "$web" 0) + #轮询公网IP,提取并校验为合法IPv4才采用,否则继续尝试下一个 + for web in http://ddns.oray.com/checkip http://members.3322.org/dyndns/getip http://ipinfo.io/ip; do + ip=$(web_get_lite "$web" 0 | grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' | tail -1) [ -n "$ip" ] && return done } diff --git a/scripts/starts/clash_modify.sh b/scripts/starts/clash_modify.sh index 8e539fa7e..0424b35e8 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 3a9180cdb..b3d448515 100644 --- a/scripts/starts/singbox_modify.sh +++ b/scripts/starts/singbox_modify.sh @@ -112,7 +112,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" ] && {