From e8a2e458bfcc264b29b474f126bd51335fda91c0 Mon Sep 17 00:00:00 2001 From: Jan Froch Date: Sun, 23 Feb 2025 19:39:49 +0100 Subject: [PATCH] luci-app-firewall: fix zone log option Changes the zone log checkbox to a multivalue selection as the underlying uci option is a bitfield. Signed-off-by: Jan Froch --- .../luci-static/resources/view/firewall/zones.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js index 47b31cf0c1..44d694ef5a 100644 --- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js +++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js @@ -293,11 +293,23 @@ return view.extend({ for (var i = 0; i < ctHelpers.length; i++) o.value(ctHelpers[i].name, E('%s (%s)%s'.format(ctHelpers[i].description, ctHelpers[i].name.toUpperCase(), ctHelpers[i].name.toUpperCase()))); - o = s.taboption('advanced', form.Flag, 'log', _('Enable logging on this zone')); + o = s.taboption('advanced', form.MultiValue, 'log', _('Enable logging'), _('Log matched packets on the selected tables to syslog.')); o.modalonly = true; + o.value('filter'); + o.value('mangle'); + o.placeholder = 'No table selected'; + const TABLES = { filter: 1, mangle: 2 }; + o.cfgvalue = function (section_id) { + let bitfield = this.super('load', [section_id]) || this.default; + return Object.keys(TABLES).filter(table => bitfield & TABLES[table]); + }; + o.write = function (section_id, value) { + let bitfield = L.toArray(value).reduce((acc, table) => acc | (TABLES[table] || 0), 0); + return this.super('write', [section_id, bitfield]); + }; o = s.taboption('advanced', form.Value, 'log_limit', _('Limit log messages')); - o.depends('log', '1'); + o.depends({log: [], "!reverse": true}); o.placeholder = '10/minute'; o.modalonly = true; -- 2.30.2