luci-app-firewall: support 'direction' and 'device' parameters for rules
authorJo-Philipp Wich <jo@mein.io>
Thu, 16 Jan 2020 14:29:54 +0000 (15:29 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 16 Jan 2020 14:31:01 +0000 (15:31 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js

index a0d4cfc063b26e8bc4908033ce62128370406bac..8c50baa820532e7b14137d37f69adb29e8cb7a0d 100644 (file)
@@ -223,9 +223,34 @@ return L.view.extend({
                o.default = o.enabled;
                o.editable = true;
 
-               //ft.opt_enabled(s, Button);
-               //ft.opt_name(s, Value, _('Name'));
 
+               o = s.taboption('advanced', form.ListValue, 'direction', _('Match device'));
+               o.modalonly = true;
+               o.value('', _('unspecified'));
+               o.value('in', _('Inbound device'));
+               o.value('out', _('Outbound device'));
+               o.cfgvalue = function(section_id) {
+                       var val = uci.get('firewall', section_id, 'direction');
+                       switch (val) {
+                               case 'in':
+                               case 'ingress':
+                                       return 'in';
+
+                               case 'out':
+                               case 'egress':
+                                       return 'out';
+                       }
+
+                       return null;
+               };
+
+               o = s.taboption('advanced', widgets.DeviceSelect, 'device', _('Device name'),
+                       _('Specifies whether to tie this traffic rule to a specific inbound or outbound network device.'));
+               o.modalonly = true;
+               o.noaliases = true;
+               o.rmempty = false;
+               o.depends('direction', 'in');
+               o.depends('direction', 'out');
 
                o = s.taboption('advanced', form.ListValue, 'family', _('Restrict to address family'));
                o.modalonly = true;