luci-mid-status: nftables.js: minor cleanups and enhancements
authorJo-Philipp Wich <[email protected]>
Tue, 13 Dec 2022 22:49:11 +0000 (23:49 +0100)
committerJo-Philipp Wich <[email protected]>
Mon, 3 Apr 2023 11:45:03 +0000 (13:45 +0200)
 - Recognize `log` expression as action
 - Recognize `meta time` expression
 - Remove debug tooltip from `reject` targets

Signed-off-by: Jo-Philipp Wich <[email protected]>
(cherry picked from commit bad783a6d2484489ea07ac786a03e729f089c244)

modules/luci-mod-status/htdocs/luci-static/resources/view/status/nftables.js

index 7b1a3badb2d3755d0ec347267f0bbb9ff656f802..d891526d04eabb68ed68b834ee9a66a0d3274c29 100644 (file)
@@ -24,6 +24,7 @@ var expr_translations = {
 
        'meta.mark': _('Packet mark', 'nft meta mark'),
 
+       'meta.time': _('Packet receive time', 'nft meta time'),
        'meta.hour': _('Current time', 'nft meta hour'),
        'meta.day': _('Current weekday', 'nft meta day'),
 
@@ -94,6 +95,7 @@ var action_translations = {
        'accept': _('Accept packet', 'nft accept action'),
        'drop': _('Drop packet', 'nft drop action'),
        'jump': _('Continue in <strong><a href="#%q.%q">%h</a></strong>', 'nft jump action'),
+       'log': _('Log event "<strong>%h</strong>…"', 'nft log action'),
 
        'reject.tcp reset': _('Reject packet with <strong>TCP reset</strong>', 'nft reject with tcp reset'),
        'reject.icmp': _('Reject IPv4 packet with <strong>ICMP type %h</strong>', 'nft reject with icmp type'),
@@ -153,6 +155,7 @@ return view.extend({
                                case 'masquerade':
                                case 'return':
                                case 'flow':
+                               case 'log':
                                        return true;
                                }
                        }
@@ -354,8 +357,7 @@ return view.extend({
                        var k = 'reject.%s'.format(spec.type);
 
                        return E('span', {
-                               'class': 'ifacebadge',
-                               'data-tooltip': JSON.stringify(spec)
+                               'class': 'ifacebadge'
                        }, (action_translations[k] || k).format(this.exprToString(spec.expr)));
 
                case 'accept':
@@ -444,6 +446,11 @@ return view.extend({
                                'class': 'ifacebadge'
                        }, action_translations.flow.format(spec.flowtable.replace(/^@/, '')));
 
+               case 'log':
+                       return E('span', {
+                               'class': 'ifacebadge'
+                       }, action_translations.log.format(spec.prefix));
+
                default:
                        return E('span', {
                                'class': 'ifacebadge',