n2n_v2 & luci-app-n2n_v2: Fix stop error info for supernode and add n2n_v2 running status view (#3539)

* n2n_v2: Fix stop error info for supernode

* luci-app-n2n_v2: Add n2n_v2 running status view

* n2n: Bump pkg release version
This commit is contained in:
Xiaok 2020-03-04 23:28:16 +08:00 committed by GitHub
parent 2c22779b42
commit 19c07d3c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 3 deletions

View File

@ -10,7 +10,7 @@ LUCI_TITLE:=n2n_v2 VPN Configuration module
LUCI_DEPENDS:=+n2n_v2
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=2
PKG_RELEASE:=3
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -11,8 +11,16 @@ function index()
end
entry({"admin", "vpn"}, firstchild(), "VPN", 45).dependent = false
entry({"admin", "vpn", "n2n_v2", "status"}, call("n2n_status")).leaf = true
local page
page = entry({"admin", "vpn", "n2n_v2"}, cbi("n2n_v2"), _("N2N v2 VPN"), 45)
page.dependent = true
end
function n2n_status()
local status = {}
status.running = luci.sys.call("pgrep edge >/dev/null")==0
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -8,6 +8,8 @@ local fs = require "nixio.fs"
m = Map("n2n_v2", translate("N2N v2 VPN"),
translatef("n2n is a layer-two peer-to-peer virtual private network (VPN) which allows users to exploit features typical of P2P applications at network instead of application level."))
m:section(SimpleSection).template = "n2n_v2/status"
s = m:section(TypedSection, "edge", translate("N2N Edge Settings"))
s.anonymous = true
s.addremove = true

View File

@ -0,0 +1,20 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url([[admin]], [[vpn]], [[n2n_v2]], [[status]])%>', null,
function(x, data) {
var status = document.getElementById('n2n_status');
if (data && status) {
if (data.running) {
status.innerHTML = "<em><b style='color:green;'>N2N v2 VPN <%:RUNNING%></b></em>";
} else {
status.innerHTML = "<em><b style='color:red;'>N2N v2 VPN <%:NOT RUNNING%></b></em>";
}
}
}
);
//]]>
</script>
<fieldset class="cbi-section">
<p id="n2n_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -52,3 +52,9 @@ msgstr "Supernode节点端口"
msgid "Encryption key"
msgstr "加密密钥"
msgid "<b style='color:green;'>N2N v2 VPN is running.</b>"
msgstr "<b style='color:green;'>N2N v2 VPN 运行中</b>"
msgid "<b style='color:red;'>N2N v2 VPN is not running.</b>"
msgstr "<b style='color:red;'>N2N v2 VPN 未运行</b>"

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=n2n_v2
PKG_VERSION:=2.4
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_REV=25563f31d9aba5f61b3e2fb42941b66dad1f531f
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(PKG_REV).tar.bz2

View File

@ -60,5 +60,5 @@ start() {
stop() {
config_load 'n2n_v2'
killall -9 edge
killall -9 supernode
ps | grep supernode | grep -v grep 2>&1 >/dev/null && killall -9 supernode
}