luci-app-firewall: Add ipset field to snats
authorPaul Dee <itsascambutmailmeanyway@gmail.com>
Fri, 17 Feb 2023 11:50:00 +0000 (12:50 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 29 Mar 2023 13:33:37 +0000 (15:33 +0200)
Signed-off-by: Paul Dee <itsascambutmailmeanyway@gmail.com>
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js

index a36dfee6bbbbe22bbaaf6050dfbc9386518f7099..6ccb07556904fd98a630c3065a1184b25e1296ba 100644 (file)
@@ -313,6 +313,17 @@ return view.extend({
                o.depends({ proto: 'tcp', '!contains': true });
                o.depends({ proto: 'udp', '!contains': true });
 
+               var have_fw4 = L.hasSystemFeature('firewall4')
+               if (!have_fw4) {
+                       o = s.taboption('advanced', form.Value, 'ipset', _('Use ipset'));
+                       uci.sections('firewall', 'ipset', function(s) {
+                               if (typeof(s.name) == 'string')
+                                       this.value(s.name, s.comment ? '%s (%s)'.format(s.name, s.comment) : s.name);
+                       });
+                       o.modalonly = true;
+                       o.rmempty = true;
+               }
+
                o = s.taboption('advanced', widgets.DeviceSelect, 'device', _('Outbound device'),
                        _('Matches forwarded traffic using the specified outbound network device.'));
                o.noaliases = true;
@@ -323,7 +334,7 @@ return view.extend({
                fwtool.addLimitOption(s);
                fwtool.addLimitBurstOption(s);
 
-               if (!L.hasSystemFeature('firewall4')) {
+               if (!have_fw4) {
                        o = s.taboption('advanced', form.Value, 'extra', _('Extra arguments'),
                                _('Passes additional arguments to iptables. Use with care!'));
                        o.modalonly = true;