luci-mod-status: Fix legacy rule detection false positive
Some checks failed
LuCI repo CodeQL Analysis / Analyze JavaScript and JSON (javascript-typescript) (push) Has been cancelled

Refine legacy rule detection to avoid false positives generated by the
iptables-nft compatibility layer on fw4 systems.

The logic now prioritizes `iptables-legacy-save` for accuracy, while
retaining `iptables-save` as a fallback to ensure backward
compatibility with fw3.

Signed-off-by: Tokisaki-Galaxy <starmaster@outlook.sg>
This commit is contained in:
Tokisaki-Galaxy
2025-10-07 14:40:03 +08:00
committed by Paul Donald
parent 805b2db670
commit 63d55a7ec1
2 changed files with 11 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Status Pages
LUCI_DEPENDS:=+luci-base +libiwinfo +rpcd-mod-iwinfo
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_BUILD_DEPENDS:=iwinfo
PKG_LICENSE:=Apache-2.0

View File

@@ -146,8 +146,16 @@ return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(fs.exec_direct('/usr/sbin/nft', [ '--terse', '--json', 'list', 'ruleset' ], 'json'), {}),
L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-save'), ''),
L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-save'), '')
fs.stat('/usr/sbin/iptables-legacy-save').then(function(stat) {
return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-legacy-save'), '');
}).catch(function(err) {
return L.resolveDefault(fs.exec_direct('/usr/sbin/iptables-save'), '');
}),
fs.stat('/usr/sbin/ip6tables-legacy-save').then(function(stat) {
return L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-legacy-save'), '');
}).catch(function(err) {
return L.resolveDefault(fs.exec_direct('/usr/sbin/ip6tables-save'), '');
})
]);
},