From 23efb4fefdc8acf49623b67b93079f79b3594b69 Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Fri, 25 Oct 2024 17:40:35 +0800
Subject: [PATCH 2/6] luci-app-firewall: add shortcut-fe option

Signed-off-by: sbwml <admin@cooluc.com>
---
 .../resources/view/firewall/zones.js          | 27 ++++++++++++++++---
 1 file changed, 24 insertions(+), 3 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 b41ebae..12626c5 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
@@ -104,18 +104,39 @@ return view.extend({
 			o.value('0', _("None"));
 			o.value('1', _("Software flow offloading"), _('Software based offloading for routing/NAT.'));
 			o.value('2', _("Hardware flow offloading"), _('Hardware based offloading for routing with/without NAT.') + ' ' + _(' Requires hardware NAT support.'));
+			if (L.hasSystemFeature('shortcutfe')) {
+				o.value('3', _("Shortcut-FE flow offloading"), _('Shortcut-FE based offloading for routing/NAT'));
+			}
 			o.optional = false;
 			o.load = function (section_id) {
 				var flow_offloading = uci.get('firewall', section_id, 'flow_offloading');
 				var flow_offloading_hw = uci.get('firewall', section_id, 'flow_offloading_hw');
-				return (flow_offloading === '1')
-					? (flow_offloading_hw === '1' ? '2' : '1')
-					: '0';
+				var shortcut_fe = uci.get('firewall', section_id, 'shortcut_fe');
+				if (flow_offloading === '1') {
+					return flow_offloading_hw === '1' ? '2' : '1';
+				} else {
+					return shortcut_fe === '1' ? '3' : '0';
+				}
 			};
 			o.write = function(section_id, value) {
+				uci.unset('firewall', section_id, 'shortcut_fe');
 				uci.set('firewall', section_id, 'flow_offloading', value === '0' ? null : '1');
 				uci.set('firewall', section_id, 'flow_offloading_hw', value === '2' ? '1' : null);
+				if (value === '3') {
+					uci.unset('firewall', section_id, 'flow_offloading');
+					uci.unset('firewall', section_id, 'flow_offloading_hw');
+					uci.set('firewall', section_id, 'shortcut_fe', value === '3' ? '1' : null);
+				}
 			};
+
+			/* Shortcut-FE flow connection manager */
+			o = s.option(form.ListValue, 'shortcut_fe_module',
+			_('Connection Manager'),
+			_('Set up the Shortcut-FE engine connection manager'));
+			o.value('shortcut-fe-cm', _('shortcut-fe-cm'));
+			o.value('fast-classifier', _('fast-classifier'));
+			o.default = 'shortcut-fe-cm';
+			o.depends('offloading_type', '3');
 		}
 
 
-- 
2.42.0

