Skip to content

Commit 1672bb7

Browse files
taamarinШоколад
authored andcommitted
refactor box.iptables: Improve readability and structure
1 parent 982a1aa commit 1672bb7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

box/scripts/box.iptables

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ fi
2828
case "${bin_name}" in
2929
"clash")
3030
clash_mode=$(busybox awk '!/^ *#/ && /mode: / { print $2;found=1; exit } END{ if(!found) print "rules" }' "${clash_config}" 2>/dev/null)
31+
3132
clash_enhanced_mode=$(busybox awk '!/^ *#/ && /enhanced-mode: / { print $2;found=1; exit } END{ if(!found) print "fake-ip" }' "${clash_config}" 2>/dev/null)
32-
[ ${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)
33+
34+
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)
35+
3336
clash_dns_port=$(sed -n '/^dns:/,/^[^ ]/p' "${clash_config}" | grep -E '^[^#]*listen:.*:[0-9]+' | grep -Eo '[0-9]+' | tail -n 1)
3437
clash_dns_port=${clash_dns_port:-1053}
38+
3539
if [[ "${network_mode}" == @(mixed|tun) ]]; then
3640
tun_device=$(busybox awk '!/^ *#/ && /device: / { print $2;found=1; exit } END{ if(!found) print "utun" }' "${clash_config}" 2>/dev/null)
3741
fi

0 commit comments

Comments
 (0)