From 85775e956cfc7caee4238055c8de02c7e15ef6e8 Mon Sep 17 00:00:00 2001 From: William Fleurant Date: Mon, 3 Sep 2018 00:50:34 +0000 Subject: [PATCH] luci-app-cjdns: luci admin support for cjdns-v20.2 (#394) * luci-app-cjdns: luci admin support for cjdns-v20.2 * adds layer 2 and 3 address display column * fixes switch label pinger * get version from addr string * parse addr string for peerStats publicKey Signed-off-by: William Fleurant * luci-app-cjdns: bump release, update repo-url and license year Signed-off-by: William Fleurant * luci-app-cjdns: support views for 17.01 and 18.06 - fixed user/name column - removed latency column - combind peerstats functions - fix css on overview page - table displays with `cbi_update_table` with fallback - columns ordered similar to peerStats.js output - normalized XHR polling to mimic wireless.htm by jow@openwrt Signed-off-by: William Fleurant Signed-off-by: William Fleurant --- luci-app-cjdns/Makefile | 6 +- luci-app-cjdns/luasrc/controller/cjdns.lua | 35 ++-- luci-app-cjdns/luasrc/view/cjdns/status.htm | 171 +++++++------------- 3 files changed, 84 insertions(+), 128 deletions(-) diff --git a/luci-app-cjdns/Makefile b/luci-app-cjdns/Makefile index 793b4ec..9c92151 100644 --- a/luci-app-cjdns/Makefile +++ b/luci-app-cjdns/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2014,2015 Hyperboria.net +# Copyright (C) 2014,2018 Hyperboria.net # # You may redistribute this program and/or modify it under the terms of # the GNU General Public License as published by the Free Software Foundation, @@ -18,7 +18,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-cjdns PKG_VERSION:=1.3 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_LICENSE:=GPL-3.0 @@ -29,7 +29,7 @@ define Package/luci-app-cjdns CATEGORY:=LuCI SUBMENU:=3. Applications TITLE:=Encrypted near-zero-conf mesh routing protocol - URL:=https://github.com/hyperboria/cjdns + URL:=https://github.com/cjdelisle/cjdns MAINTAINER:=Lars Gierth DEPENDS:=+cjdns +luci-base endef diff --git a/luci-app-cjdns/luasrc/controller/cjdns.lua b/luci-app-cjdns/luasrc/controller/cjdns.lua index 63644cb..362d84a 100644 --- a/luci-app-cjdns/luasrc/controller/cjdns.lua +++ b/luci-app-cjdns/luasrc/controller/cjdns.lua @@ -51,15 +51,16 @@ function act_peers() end for i,peer in pairs(response.peers) do - peer.ipv6 = publictoip6(peer.publicKey) - if peer.user == nil then - peer.user = '' - uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer) - if peer.publicKey == udp_peer.public_key then - peer.user = udp_peer.user - end - end) - end + local peertable = peerstats_join(peer.addr) + peer.ipv6 = peertable['ipv6'] + peer.version = peertable['version'] + peer.label = peertable['label'] + peer.pubkey = peertable['pubkey'] + uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer) + if peer.pubkey == udp_peer.public_key then + peer.user = udp_peer.user + end + end) peers[#peers + 1] = peer end @@ -97,9 +98,13 @@ function act_ping() luci.http.write_json(response) end -function publictoip6(publicKey) - local process = io.popen("/usr/bin/publictoip6 " .. publicKey, "r") - local ipv6 = process:read() - process:close() - return ipv6 -end +function peerstats_join(addrLine) + local pubkey = addrLine:sub(addrLine:len() - 53) + local process = io.popen("/usr/bin/publictoip6 " .. pubkey, "r") + local ipv6 = process:read() + local label = 'label' + process:close() + local version = addrLine:match("^(v%w+)%.") or 'v0' + local label = addrLine:sub(version:len() + 2, version:len() + 20) + return { pubkey=pubkey, ipv6=ipv6, label=label, version=version } +end \ No newline at end of file diff --git a/luci-app-cjdns/luasrc/view/cjdns/status.htm b/luci-app-cjdns/luasrc/view/cjdns/status.htm index 9d43e85..3da5d7c 100644 --- a/luci-app-cjdns/luasrc/view/cjdns/status.htm +++ b/luci-app-cjdns/luasrc/view/cjdns/status.htm @@ -1,116 +1,67 @@ - - -
- Active cjdns peers - - - - - - - - - - - - -
User/NameIPv6StatusVersionRx / TxLatency
Querying Admin API
-
+
+
+ <%:Active cjdns peers%> + + + + + + + + + +
AddressIPv6VersionStatusRx / TxUser/Name
+
+
\ No newline at end of file -- 2.30.2