From c9c4be52b07215e5b1eb7a8f8d08def0422a110a Mon Sep 17 00:00:00 2001 From: ratabb Date: Wed, 18 Jun 2025 17:47:53 +0700 Subject: [PATCH] Improve `box.iptables` logic with Android version check via major version parsing (#189) --- box/scripts/box.iptables | 14 ++++++++------ box/scripts/net.inotify | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/box/scripts/box.iptables b/box/scripts/box.iptables index 7ae3452..4ea7aa3 100755 --- a/box/scripts/box.iptables +++ b/box/scripts/box.iptables @@ -12,14 +12,16 @@ tun_forward="enable" clash_dns_forward="enable" fake_ip_range="" -va1=$(getprop ro.build.version.release) -va2="11" -if [ "$va1" -ge "$va2" ]; then +# ex: 7.1.1 +buildVersion=$(getprop ro.build.version.release) +minBuildVersion="11" +IPV="iptables" # Default +IP6V="ip6tables" # Default +# ex: 7.1.1 -> 7 +buildVersionMajor=${buildVersion%%.*} +if [ "$buildVersionMajor" -ge "$minBuildVersion" ]; then IPV="iptables -w 100" IP6V="ip6tables -w 100" -else - IPV="iptables" - IP6V="ip6tables" fi case "${bin_name}" in diff --git a/box/scripts/net.inotify b/box/scripts/net.inotify index 6f170c2..211dbee 100644 --- a/box/scripts/net.inotify +++ b/box/scripts/net.inotify @@ -6,14 +6,16 @@ events=$1 export PATH="/data/adb/magisk:/data/adb/ksu/bin:/data/adb/ap/bin:$PATH:/system/bin" -va1=$(getprop ro.build.version.release) -va2="11" -if [ "$va1" -ge "$va2" ]; then +# ex: 7.1.1 +buildVersion=$(getprop ro.build.version.release) +minBuildVersion="11" +IPV="iptables" # Default +IP6V="ip6tables" # Default +# ex: 7.1.1 -> 7 +buildVersionMajor=${buildVersion%%.*} +if [ "$buildVersionMajor" -ge "$minBuildVersion" ]; then IPV="iptables -w 100" IP6V="ip6tables -w 100" -else - IPV="iptables" - IP6V="ip6tables" fi iptables="${IPV}"