From 6e60bb9d0edc44cb4f02e76a1edde78c41a99760 Mon Sep 17 00:00:00 2001 From: Stijn Segers Date: Sat, 6 Jan 2018 21:02:40 +0100 Subject: luci-app-wireguard: add LuCI Wireguard status to 17.01 as well Signed-off-by: Stijn Segers --- luci-app-wireguard/luasrc/view/wireguard.htm | 209 +++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 luci-app-wireguard/luasrc/view/wireguard.htm (limited to 'luci-app-wireguard/luasrc/view/wireguard.htm') diff --git a/luci-app-wireguard/luasrc/view/wireguard.htm b/luci-app-wireguard/luasrc/view/wireguard.htm new file mode 100644 index 000000000..5af6232ae --- /dev/null +++ b/luci-app-wireguard/luasrc/view/wireguard.htm @@ -0,0 +1,209 @@ +<%# + Copyright 2016-2017 Dan Luedtke + Licensed to the public under the Apache License 2.0. +-%> + +<% + local data = { } + local last_device = "" + + local wg_dump = io.popen("wg show all dump") + if wg_dump then + local line + for line in wg_dump:lines() do + local line = string.split(line, "\t") + if not (last_device == line[1]) then + last_device = line[1] + data[line[1]] = { + name = line[1], + public_key = line[3], + listen_port = line[4], + fwmark = line[5], + peers = { } + } + else + local peer = { + public_key = line[2], + endpoint = line[4], + allowed_ips = { }, + latest_handshake = line[6], + transfer_rx = line[7], + transfer_tx = line[8], + persistent_keepalive = line[9] + } + if not (line[4] == '(none)') then + for ipkey, ipvalue in pairs(string.split(line[5], ",")) do + if #ipvalue > 0 then + table.insert(peer['allowed_ips'], ipvalue) + end + end + end + table.insert(data[line[1]].peers, peer) + end + end + end + + if luci.http.formvalue("status") == "1" then + luci.http.prepare_content("application/json") + luci.http.write_json(data) + return + end +-%> + +<%+header%> + + + + +

WireGuard Status

+ +
+<%- +for ikey, iface in pairs(data) do + -%> + <%:Interface%> <%=ikey%> + + + + + + <%- + for pkey, peer in pairs(iface.peers) do + -%> + + + + + <%- + end + -%> +
<%:Configuration%> + + + + +
+   + + <%:Collecting data...%> +
+
<%:Peer%> + + + + +
+
+ ? +
+ <%:Collecting data...%> +
+
+ <%- +end +-%> +
+ +<%+footer%> -- cgit v1.2.3