summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-bcp38
diff options
context:
space:
mode:
authorHannu Nyman <hannu.nyman@iki.fi>2023-02-13 19:07:42 +0200
committerGitHub <noreply@github.com>2023-02-13 19:07:42 +0200
commit7b810bea11866865ee667bf2c2939140914b1447 (patch)
treeb22efe0a07a205bce0b0efab4041780ef0b69910 /applications/luci-app-bcp38
parentb43eef2ba839925b1b910969a217fc25e484465f (diff)
parenta159d98f97b56f80d3211c56f19d8b3db0adaec4 (diff)
Merge pull request #6234 from ne20002/luci-app-bcp38
luci-app-bcp38: migration to JavaScript
Diffstat (limited to 'applications/luci-app-bcp38')
-rw-r--r--applications/luci-app-bcp38/Makefile2
-rw-r--r--applications/luci-app-bcp38/htdocs/luci-static/resources/view/bcp38/form.js50
-rw-r--r--applications/luci-app-bcp38/luasrc/model/cbi/bcp38.lua68
-rw-r--r--applications/luci-app-bcp38/root/usr/share/luci/menu.d/luci-app-bcp38.json5
4 files changed, 53 insertions, 72 deletions
diff --git a/applications/luci-app-bcp38/Makefile b/applications/luci-app-bcp38/Makefile
index a8a6e7402e..b1aeaf4bf4 100644
--- a/applications/luci-app-bcp38/Makefile
+++ b/applications/luci-app-bcp38/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=BCP38 LuCI interface
-LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full +bcp38
+LUCI_DEPENDS:=+luci-base +bcp38
PKG_MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
PKG_LICENSE:=Apache-2.0
diff --git a/applications/luci-app-bcp38/htdocs/luci-static/resources/view/bcp38/form.js b/applications/luci-app-bcp38/htdocs/luci-static/resources/view/bcp38/form.js
new file mode 100644
index 0000000000..9e14047698
--- /dev/null
+++ b/applications/luci-app-bcp38/htdocs/luci-static/resources/view/bcp38/form.js
@@ -0,0 +1,50 @@
+'use strict';
+'require view';
+'require form';
+'require tools.widgets as widgets';
+
+return view.extend({
+ render: function() {
+ var m, s, o;
+
+ m = new form.Map('bcp38', _('BCP38'),
+ _('This function blocks packets with private address destinations ' +
+ 'from going out onto the internet as per ' +
+ '<a href="http://tools.ietf.org/html/bcp38">BCP 38</a>. ' +
+ 'For IPv6, only source specific default routes are installed, so ' +
+ 'no BCP38 firewall routes are needed.'));
+
+
+ s = m.section(form.TypedSection, 'bcp38', _('BCP38 config'));
+ s.anonymous = true;
+
+ o = s.option(form.Flag, 'enabled', _('Enable'));
+ o.default = '0';
+ o.rmempty = false;
+
+ o = s.option(form.Flag, 'detect_upstream', _('Auto-detect upstream IP'),
+ _('Attempt to automatically detect if the upstream IP ' +
+ 'will be blocked by the configuration, and add an exception if it will. ' +
+ 'If this does not work correctly, you can add exceptions manually below.'));
+ o.rmempty = false;
+
+ o = s.option(widgets.DeviceSelect, 'interface', _('Interface name'),
+ _('Interface to apply the blocking to should be the upstream WAN interface).'));
+ o.modalonly = true;
+ o.noaliases = true;
+ o.multiple = false;
+ o.rmempty = false;
+
+ o = s.option(form.DynamicList, 'match', _('Blocked IP ranges'));
+ o.datatype = 'ip4addr';
+
+ o = s.option(form.DynamicList, 'nomatch', _('Allowed IP ranges'),
+ _('Takes precedence over blocked ranges. ' +
+ 'Use to whitelist your upstream network if you\'re behind a double NAT ' +
+ 'and the auto-detection doesn\'t work.'));
+ o.datatype = 'ip4addr';
+
+ return m.render();
+ },
+});
+
diff --git a/applications/luci-app-bcp38/luasrc/model/cbi/bcp38.lua b/applications/luci-app-bcp38/luasrc/model/cbi/bcp38.lua
deleted file mode 100644
index 731c3350eb..0000000000
--- a/applications/luci-app-bcp38/luasrc/model/cbi/bcp38.lua
+++ /dev/null
@@ -1,68 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2014 Toke Høiland-Jørgensen <toke@toke.dk>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-
-local wa = require "luci.tools.webadmin"
-local net = require "luci.model.network".init()
-local sys = require "luci.sys"
-local ifaces = sys.net:devices()
-
-m = Map("bcp38", translate("BCP38"),
- translate("This function blocks packets with private address destinations " ..
- "from going out onto the internet as per " ..
- "<a href=\"http://tools.ietf.org/html/bcp38\">BCP 38</a>. " ..
- "For IPv6, only source specific default routes are installed, so " ..
- "no BCP38 firewall routes are needed."))
-
-s = m:section(TypedSection, "bcp38", translate("BCP38 config"))
-s.anonymous = true
--- BASIC
-e = s:option(Flag, "enabled", translate("Enable"))
-e.rmempty = false
-
-a = s:option(Flag, "detect_upstream", translate("Auto-detect upstream IP"),
- translate("Attempt to automatically detect if the upstream IP " ..
- "will be blocked by the configuration, and add an exception if it will. " ..
- "If this does not work correctly, you can add exceptions manually below."))
-a.rmempty = false
-
-n = s:option(ListValue, "interface", translate("Interface name"), translate("Interface to apply the blocking to " ..
- "(should be the upstream WAN interface)."))
-
-for _, iface in ipairs(ifaces) do
- if not (iface == "lo" or iface:match("^ifb.*")) then
- local nets = net:get_interface(iface)
- nets = nets and nets:get_networks() or {}
- for k, v in pairs(nets) do
- nets[k] = nets[k].sid
- end
- nets = table.concat(nets, ",")
- n:value(iface, ((#nets > 0) and "%s (%s)" % {iface, nets} or iface))
- end
-end
-n.rmempty = false
-
-ma = s:option(DynamicList, "match",
- translate("Blocked IP ranges"))
-
-ma.datatype = "ip4addr"
-
-nm = s:option(DynamicList, "nomatch",
- translate("Allowed IP ranges"), translate("Takes precedence over blocked ranges. "..
- "Use to whitelist your upstream network if you're behind a double NAT " ..
- "and the auto-detection doesn't work."))
-
-nm.datatype = "ip4addr"
-
-
-return m
diff --git a/applications/luci-app-bcp38/root/usr/share/luci/menu.d/luci-app-bcp38.json b/applications/luci-app-bcp38/root/usr/share/luci/menu.d/luci-app-bcp38.json
index e83ad69b3c..2a41ed6c66 100644
--- a/applications/luci-app-bcp38/root/usr/share/luci/menu.d/luci-app-bcp38.json
+++ b/applications/luci-app-bcp38/root/usr/share/luci/menu.d/luci-app-bcp38.json
@@ -3,9 +3,8 @@
"title": "BCP38",
"order": 50,
"action": {
- "type": "cbi",
- "path": "bcp38",
- "post": { "cbi.submit": true }
+ "type": "view",
+ "path": "bcp38/form"
},
"depends": {
"acl": [ "luci-app-bcp38" ]