luci-app-firewall: initial firewall4 compatibility

Initial changes required for firewall4 compatibility:
* depend on uc-firewall instead of firewall
* detect installed version of firewall and hide incompatible features

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
Reviewed-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Stijn Tintel 2021-11-04 04:01:43 +02:00
parent dc0ed9ca93
commit 48599d8d1d
7 changed files with 48 additions and 36 deletions

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
LUCI_TITLE:=Firewall and Portforwarding application LUCI_TITLE:=Firewall and Portforwarding application
LUCI_DEPENDS:=+firewall LUCI_DEPENDS:=+uci-firewall
PKG_LICENSE:=Apache-2.0 PKG_LICENSE:=Apache-2.0

View file

@ -281,10 +281,12 @@ return view.extend({
fwtool.addLimitOption(s); fwtool.addLimitOption(s);
fwtool.addLimitBurstOption(s); fwtool.addLimitBurstOption(s);
if (!L.hasSystemFeature('firewall4')) {
o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'), o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'),
_('Passes additional arguments to iptables. Use with care!')); _('Passes additional arguments to iptables. Use with care!'));
o.modalonly = true; o.modalonly = true;
o.rmempty = true; o.rmempty = true;
}
return m.render(); return m.render();
} }

View file

@ -432,9 +432,11 @@ return view.extend({
fwtool.addLimitOption(s); fwtool.addLimitOption(s);
fwtool.addLimitBurstOption(s); fwtool.addLimitBurstOption(s);
if (!L.hasSystemFeature('firewall4')) {
o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'), o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'),
_('Passes additional arguments to iptables. Use with care!')); _('Passes additional arguments to iptables. Use with care!'));
o.modalonly = true; o.modalonly = true;
}
o = s.taboption('timed', form.MultiValue, 'weekdays', _('Week Days')); o = s.taboption('timed', form.MultiValue, 'weekdays', _('Week Days'));
o.modalonly = true; o.modalonly = true;

View file

@ -245,10 +245,12 @@ return view.extend({
fwtool.addLimitOption(s); fwtool.addLimitOption(s);
fwtool.addLimitBurstOption(s); fwtool.addLimitBurstOption(s);
if (!L.hasSystemFeature('firewall4')) {
o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'), o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'),
_('Passes additional arguments to iptables. Use with care!')); _('Passes additional arguments to iptables. Use with care!'));
o.modalonly = true; o.modalonly = true;
o.rmempty = true; o.rmempty = true;
}
o = s.taboption('timed', form.MultiValue, 'weekdays', _('Week Days')); o = s.taboption('timed', form.MultiValue, 'weekdays', _('Week Days'));
o.modalonly = true; o.modalonly = true;

View file

@ -269,6 +269,7 @@ return view.extend({
o.placeholder = '10/minute'; o.placeholder = '10/minute';
o.modalonly = true; o.modalonly = true;
if (!L.hasSystemFeature('firewall4')) {
o = s.taboption('extra', form.DummyValue, '_extrainfo'); o = s.taboption('extra', form.DummyValue, '_extrainfo');
o.rawhtml = true; o.rawhtml = true;
o.modalonly = true; o.modalonly = true;
@ -295,6 +296,7 @@ return view.extend({
uci.unset('firewall', section_id, 'extra'); uci.unset('firewall', section_id, 'extra');
uci.set('firewall', section_id, 'extra_dest', value); uci.set('firewall', section_id, 'extra_dest', value);
}; };
}
o = s.taboption('general', form.DummyValue, '_forwardinfo'); o = s.taboption('general', form.DummyValue, '_forwardinfo');
o.rawhtml = true; o.rawhtml = true;

View file

@ -56,6 +56,9 @@
"action": { "action": {
"type": "view", "type": "view",
"path": "firewall/custom" "path": "firewall/custom"
},
"depends": {
"fs": { "/usr/share/fw3/helpers.conf": "file" }
} }
} }
} }

View file

@ -207,6 +207,7 @@ local methods = {
local ok, fd local ok, fd
rv.firewall = fs.access("/sbin/fw3") rv.firewall = fs.access("/sbin/fw3")
rv.firewall4 = fs.access("/sbin/fw4")
rv.opkg = fs.access("/bin/opkg") rv.opkg = fs.access("/bin/opkg")
rv.offloading = fs.access("/sys/module/xt_FLOWOFFLOAD/refcnt") rv.offloading = fs.access("/sys/module/xt_FLOWOFFLOAD/refcnt")
rv.br2684ctl = fs.access("/usr/sbin/br2684ctl") rv.br2684ctl = fs.access("/usr/sbin/br2684ctl")