From 8ca5be8974332157f88f8b60d2b255c731010020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=AA=E7=8B=90?= Date: Wed, 24 Jul 2024 01:52:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8Bclash=20dns=E7=AB=AF=E5=8F=A3?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E4=B8=8D=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- box/scripts/box.iptables | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/box/scripts/box.iptables b/box/scripts/box.iptables index 19300ae..1837aed 100755 --- a/box/scripts/box.iptables +++ b/box/scripts/box.iptables @@ -27,7 +27,8 @@ case "${bin_name}" in clash_mode=$(busybox awk '!/^ *#/ && /mode: / { print $2;found=1; exit } END{ if(!found) print "rules" }' "${clash_config}" 2>/dev/null) clash_enhanced_mode=$(busybox awk '!/^ *#/ && /enhanced-mode: / { print $2;found=1; exit } END{ if(!found) print "fake-ip" }' "${clash_config}" 2>/dev/null) [ ${clash_enhanced_mode} != "fake-ip" ] && fake_ip_range=$(busybox awk '!/^ *#/ && /fake-ip-range:/ { print $2; found=1; exit } END { if (!found) print "198.18.0.1/16" }' "${clash_config}" 2>/dev/null) - clash_dns_port=$(busybox awk '!/^ *#/ && /listen:/ { split($0, arr, ":"); print arr[3]; found=1; exit } END{ if(!found) print "1053" }' "${clash_config}" 2>/dev/null) + clash_dns_port=$(sed -n '/^dns:/,/^[^ ]/p' "${clash_config}" | grep -E '^[^#]*listen:.*:[0-9]+' | grep -Eo '[0-9]+' | tail -n 1) + clash_dns_port=${clash_dns_port:-1053} if [[ "${network_mode}" == @(mixed|tun) ]]; then tun_device=$(busybox awk '!/^ *#/ && /device: / { print $2;found=1; exit } END{ if(!found) print "utun" }' "${clash_config}" 2>/dev/null) fi