Skip to content

Commit 3943d3c

Browse files
committed
Freeze 21.02 release to 21.02.4
1 parent b3ae782 commit 3943d3c

File tree

24 files changed

+2588
-22
lines changed

24 files changed

+2588
-22
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2017-2019 Stan Grishin (stangri@melmac.ca)
2+
# This is free software, licensed under the GNU General Public License v3.
3+
4+
include $(TOPDIR)/rules.mk
5+
6+
PKG_LICENSE:=GPL-3.0-or-later
7+
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
8+
PKG_VERSION:=0.3.4-8
9+
10+
LUCI_TITLE:=VPN Policy-Based Routing Service Web UI
11+
LUCI_DESCRIPTION:=Provides Web UI for vpn-policy-routing service.
12+
LUCI_DEPENDS:=+luci-compat +luci-mod-admin-full +vpn-policy-routing
13+
LUCI_PKGARCH:=all
14+
15+
include ../../luci.mk
16+
17+
# call BuildPackage - OpenWrt buildroot signature
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module("luci.controller.vpn-policy-routing", package.seeall)
2+
function index()
3+
if nixio.fs.access("/etc/config/vpn-policy-routing") then
4+
local e = entry({"admin", "vpn"}, firstchild(), _("VPN"), 60)
5+
e.dependent = false
6+
e.acl_depends = { "luci-app-vpn-policy-routing" }
7+
entry({"admin", "vpn", "vpn-policy-routing"}, cbi("vpn-policy-routing"), _("VPN Policy Routing"))
8+
entry({"admin", "vpn", "vpn-policy-routing", "action"}, call("vpn_policy_routing_action"), nil).leaf = true
9+
end
10+
end
11+
12+
function vpn_policy_routing_action(name)
13+
local packageName = "vpn-policy-routing"
14+
local http = require "luci.http"
15+
local sys = require "luci.sys"
16+
local uci = require "luci.model.uci".cursor()
17+
local util = require "luci.util"
18+
if name == "start" then
19+
sys.init.start(packageName)
20+
elseif name == "action" then
21+
util.exec("/etc/init.d/" .. packageName .. " restart >/dev/null 2>&1")
22+
elseif name == "stop" then
23+
sys.init.stop(packageName)
24+
elseif name == "enable" then
25+
uci:set(packageName, "config", "enabled", "1")
26+
uci:commit(packageName)
27+
elseif name == "disable" then
28+
uci:set(packageName, "config", "enabled", "0")
29+
uci:commit(packageName)
30+
end
31+
http.prepare_content("text/plain")
32+
http.write("0")
33+
end

openwrt-21.02/patches/package/luci-app-vpn-policy-routing/luasrc/model/cbi/vpn-policy-routing.lua

Lines changed: 376 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<%# Copyright 2020 Stan Grishin <stangri@melmac.ca> -%>
2+
3+
<%+vpn-policy-routing/css%>
4+
<%+vpn-policy-routing/js%>
5+
6+
<%-
7+
local packageName = "vpn-policy-routing"
8+
local uci = require "luci.model.uci".cursor()
9+
local sys = require "luci.sys"
10+
local serviceRunning, serviceEnabled = false, false;
11+
if sys.call("iptables -t mangle -L | grep -q VPR_PREROUTING") == 0 then
12+
serviceRunning = true
13+
end
14+
if uci:get(packageName, "config", "enabled") == "1" then
15+
serviceEnabled = true
16+
end
17+
18+
if serviceEnabled then
19+
btn_start_status = true
20+
btn_action_status = true
21+
btn_stop_status = true
22+
btn_enable_status = false
23+
btn_disable_status = true
24+
else
25+
btn_start_status = false
26+
btn_action_status = false
27+
btn_stop_status = false
28+
btn_enable_status = true
29+
btn_disable_status = false
30+
end
31+
if serviceRunning then
32+
btn_start_status = false
33+
btn_action_status = true
34+
btn_stop_status = true
35+
else
36+
btn_action_status = false
37+
btn_stop_status = false
38+
end
39+
-%>
40+
41+
<%+cbi/valueheader%>
42+
<input type="button" class="btn cbi-button cbi-button-apply" id="btn_start" name="start" value="<%:Start%>"
43+
onclick="button_action(this)" />
44+
<span id="btn_start_spinner" class="btn_spinner"></span>
45+
<input type="button" class="btn cbi-button cbi-button-apply" id="btn_action" name="action" value="<%:Restart%>"
46+
onclick="button_action(this)" />
47+
<span id="btn_action_spinner" class="btn_spinner"></span>
48+
<input type="button" class="btn cbi-button cbi-button-reset" id="btn_stop" name="stop" value="<%:Stop%>"
49+
onclick="button_action(this)" />
50+
<span id="btn_stop_spinner" class="btn_spinner"></span>
51+
&#160;
52+
&#160;
53+
&#160;
54+
&#160;
55+
<input type="button" class="btn cbi-button cbi-button-apply" id="btn_enable" name="enable" value="<%:Enable%>"
56+
onclick="button_action(this)" />
57+
<span id="btn_enable_spinner" class="btn_spinner"></span>
58+
<input type="button" class="btn cbi-button cbi-button-reset" id="btn_disable" name="disable" value="<%:Disable%>"
59+
onclick="button_action(this)" />
60+
<span id="btn_disable_spinner" class="btn_spinner"></span>
61+
<%+cbi/valuefooter%>
62+
63+
<%-if not btn_start_status then%>
64+
<script type="text/javascript">document.getElementById("btn_start").disabled = true;</script>
65+
<%-end%>
66+
<%-if not btn_action_status then%>
67+
<script type="text/javascript">document.getElementById("btn_action").disabled = true;</script>
68+
<%-end%>
69+
<%-if not btn_stop_status then%>
70+
<script type="text/javascript">document.getElementById("btn_stop").disabled = true;</script>
71+
<%-end%>
72+
<%-if not btn_enable_status then%>
73+
<script type="text/javascript">document.getElementById("btn_enable").disabled = true;</script>
74+
<%-end%>
75+
<%-if not btn_disable_status then%>
76+
<script type="text/javascript">document.getElementById("btn_disable").disabled = true;</script>
77+
<%-end%>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<style type="text/css">
2+
.btn_spinner
3+
{
4+
display: inline-block;
5+
width: 0px;
6+
height: 16px;
7+
margin: 0 0px;
8+
}
9+
</style>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<script type="text/javascript">
2+
//<![CDATA[
3+
function button_action(action) {
4+
var xhr = new XHR(false);
5+
var btn_start = document.getElementById("btn_start");
6+
var btn_action = document.getElementById("btn_action");
7+
var btn_stop = document.getElementById("btn_stop");
8+
var btn_enable = document.getElementById("btn_enable");
9+
var btn_disable = document.getElementById("btn_disable");
10+
var btn_spinner;
11+
switch (action.name) {
12+
case "start":
13+
btn_spinner = document.getElementById("btn_start_spinner");
14+
break;
15+
case "action":
16+
btn_spinner = document.getElementById("btn_action_spinner");
17+
break;
18+
case "stop":
19+
btn_spinner = document.getElementById("btn_stop_spinner");
20+
break;
21+
case "enable":
22+
btn_spinner = document.getElementById("btn_enable_spinner");
23+
break;
24+
case "disable":
25+
btn_spinner = document.getElementById("btn_disable_spinner");
26+
break;
27+
}
28+
btn_start.disabled = true;
29+
btn_action.disabled = true;
30+
btn_stop.disabled = true;
31+
btn_enable.disabled = true;
32+
btn_disable.disabled = true;
33+
spinner(btn_spinner, 1);
34+
xhr.get('<%=luci.dispatcher.build_url("admin", "vpn", "vpn-policy-routing", "action")%>/' + action.name, null,
35+
function (x) {
36+
if (!x) {
37+
return;
38+
}
39+
btn_start.disabled = false;
40+
btn_action.disabled = false;
41+
btn_stop.disabled = false;
42+
btn_enable.disabled = false;
43+
btn_disable.disabled = false;
44+
spinner(btn_spinner, 0);
45+
location.reload();
46+
});
47+
}
48+
function spinner(element, state) {
49+
if (state === 1) {
50+
element.style.width = "16px";
51+
element.innerHTML = '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" width="16" height="16" style="vertical-align:middle" />';
52+
}
53+
else {
54+
element.style.width = "0px";
55+
element.innerHTML = '';
56+
}
57+
}
58+
//]]>
59+
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<%#
2+
Copyright 2017-2020 Stan Grishin (stangri@melmac.ca)
3+
This is free software, licensed under the Apache License, Version 2.0
4+
-%>
5+
6+
<%+cbi/valueheader%>
7+
8+
<div style="font-weight:bold;">
9+
<%=self:cfgvalue(section):gsub('\n', '<br />' )%>
10+
</div>
11+
<br />
12+
13+
<div>
14+
<%- local readmeURL = "https://docs.openwrt.melmac.net/vpn-policy-routing/" -%>
15+
<%=translatef("The %s indicates default gateway. See the %sREADME%s for details.", "<strong></strong>", "<a href=\"" .. readmeURL .. "#a-word-about-default-routing" .. "\" target=\"_blank\">", "</a>")%>
16+
</div>
17+
18+
<%+cbi/valuefooter%>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<%#
2+
Copyright 2017-2019 Stan Grishin (stangri@melmac.ca)
3+
This is free software, licensed under the Apache License, Version 2.0
4+
-%>
5+
6+
<%+cbi/valueheader%>
7+
8+
<div style="font-weight:bold;">
9+
<%=self:cfgvalue(section):gsub('\n', '<br />' )%>
10+
</div>
11+
12+
<%+cbi/valuefooter%>

0 commit comments

Comments
 (0)