-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: BERENYI Balazs <balazs@wee.hu>
- Loading branch information
BERENYI Balazs
committed
Dec 17, 2020
1 parent
a650949
commit 02fe1ef
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# This is free software, licensed under the Apache License, Version 2.0 . | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
LUCI_TITLE:=SoftEther Status | ||
LUCI_DEPENDS:=+softethervpn5-client | ||
LUCI_PKGARCH:=all | ||
|
||
PKG_LICENSE:=Apache-2.0 | ||
|
||
include ../../luci.mk | ||
|
||
# call BuildPackage - OpenWrt buildroot signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<%+header%> | ||
<h2>SoftEther Status</h2> | ||
<% | ||
local function table_merge(table1, table2) | ||
for k,v in pairs(table2) do | ||
table1[k] = v | ||
end | ||
return table1 | ||
end | ||
|
||
local function get_account_list() | ||
local accounts = {} | ||
local ac_list = io.popen("vpncmd localhost /client /csv /cmd:accountlist | tail -n +4 2> /dev/null ") | ||
if ac_list then | ||
local line | ||
for line in ac_list:lines() do | ||
local line = string.split(line, ",") | ||
local d = {} | ||
d["Status"] = line[2] | ||
accounts[line[1]] = d | ||
end | ||
end | ||
return accounts | ||
end | ||
|
||
local function get_account_status(ac_name) | ||
local t = {} | ||
local csv = io.popen("vpncmd localhost /client /csv /cmd:accountstatusget " .. ac_name .. " | tail -n +4 2> /dev/null ") | ||
if csv then | ||
local line | ||
for line in csv:lines() do | ||
local line = string.split(line, ",") | ||
if table.getn(line) == 2 then | ||
t[line[1]] = line[2] | ||
end | ||
end | ||
end | ||
return t | ||
end | ||
|
||
local function dump_account(account, properties) | ||
luci.http.write("<div class=\"tr cbi-section-table-row\">") | ||
luci.http.write("<div class=\"td\" style=\"width: 20%;vertical-align: top;\"><strong>Account:</strong> " .. account .. "</div>") | ||
luci.http.write("<div class=\"td\">") | ||
for i,v in pairs(properties) do | ||
luci.http.write("<strong>" .. i .. ":</strong> " .. v .. "</br>") | ||
end | ||
luci.http.write("</div>") -- td | ||
luci.http.write("</div>") -- tr | ||
end | ||
|
||
-- Gather stuff | ||
local accounts = get_account_list() | ||
for acc_name, acc_properties in pairs(accounts) do | ||
local acc_status = get_account_status(acc_name) | ||
table_merge(acc_properties, acc_status) | ||
end | ||
|
||
-- Render stuff | ||
luci.http.write("<div class=\"cbi-section\">") | ||
luci.http.write("<div class=\"cbi-section-node\">") | ||
luci.http.write("<div class=\"table cbi-section-table\">") | ||
for acc_name, acc_properties in pairs(accounts) do | ||
dump_account(acc_name, acc_properties) | ||
end | ||
luci.http.write("</div>") -- table | ||
luci.http.write("</div>") -- section-node | ||
luci.http.write("</div>") -- section | ||
%> | ||
<%+footer%> |
10 changes: 10 additions & 0 deletions
10
applications/luci-app-softether/root/usr/share/luci/menu.d/luci-app-softether.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"admin/status/softether": { | ||
"title": "SoftEther Status", | ||
"order": 94, | ||
"action": { | ||
"type": "template", | ||
"path": "softether" | ||
} | ||
} | ||
} |