summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-firewall/htdocs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-11-03 20:34:57 +0100
committerJo-Philipp Wich <jo@mein.io>2019-11-03 20:34:57 +0100
commit9e57fbb2c3f9c44cdf0a57e6fb9c1df32c84d52b (patch)
tree29cc9751eca9a0254d45a19a615271f368b53b0d /applications/luci-app-firewall/htdocs
parenta43b1c6468e8fd931c721e83f9f18955509cfdaa (diff)
luci-base, luci-app-firewall: port custom rules to client side view
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-firewall/htdocs')
-rw-r--r--applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js
new file mode 100644
index 0000000000..4b4b140086
--- /dev/null
+++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js
@@ -0,0 +1,31 @@
+'use strict';
+'require fs';
+
+return L.view.extend({
+ load: function() {
+ return L.resolveDefault(fs.read('/etc/firewall.user'), '');
+ },
+
+ handleSave: function(ev) {
+ var value = (document.querySelector('textarea').value || '').trim().replace(/\r\n/g, '\n') + '\n';
+
+ return fs.write('/etc/firewall.user', value).then(function(rc) {
+ document.querySelector('textarea').value = value;
+ L.ui.addNotification(null, E('p', _('Contents have been saved.')), 'info');
+ fs.exec('/etc/init.d/firewall', ['restart']);
+ }).catch(function(e) {
+ L.ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message)));
+ });
+ },
+
+ render: function(fwuser) {
+ return E([
+ E('h2', _('Firewall - Custom Rules')),
+ E('p', {}, _('Custom rules allow you to execute arbitrary iptables commands which are not otherwise covered by the firewall framework. The commands are executed after each firewall restart, right after the default ruleset has been loaded.')),
+ E('p', {}, E('textarea', { 'style': 'width:100%', 'rows': 10 }, [ fwuser != null ? fwuser : '' ]))
+ ]);
+ },
+
+ handleSaveApply: null,
+ handleReset: null
+});