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 <william@netblazr.com>
This commit is contained in:
parent
d82d299a27
commit
d1dffb3c04
2 changed files with 25 additions and 6 deletions
|
@ -51,7 +51,9 @@ function act_peers()
|
||||||
end
|
end
|
||||||
|
|
||||||
for i,peer in pairs(response.peers) do
|
for i,peer in pairs(response.peers) do
|
||||||
peer.ipv6 = publictoip6(peer.publicKey)
|
peer.ipv6 = publictoip6(peer.addr)
|
||||||
|
peer.version = pstatver(peer.addr)
|
||||||
|
peer.label = pstatlabel(peer.addr)
|
||||||
if peer.user == nil then
|
if peer.user == nil then
|
||||||
peer.user = ''
|
peer.user = ''
|
||||||
uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer)
|
uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer)
|
||||||
|
@ -97,9 +99,23 @@ function act_ping()
|
||||||
luci.http.write_json(response)
|
luci.http.write_json(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
function publictoip6(publicKey)
|
function publictoip6(addrLine)
|
||||||
local process = io.popen("/usr/bin/publictoip6 " .. publicKey, "r")
|
local t = string.sub(addrLine, string.len(addrLine) - 53)
|
||||||
|
local process = io.popen("/usr/bin/publictoip6 " .. t, "r")
|
||||||
local ipv6 = process:read()
|
local ipv6 = process:read()
|
||||||
process:close()
|
process:close()
|
||||||
return ipv6
|
return ipv6
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function pstatver(addrLine)
|
||||||
|
for str in string.gmatch(addrLine, "([^"..".".."]+)") do
|
||||||
|
if str then return str else return '-' end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function pstatlabel(addrLine)
|
||||||
|
local t={}; local i=0; for str in string.gmatch(addrLine, "([^"..".".."]+)") do
|
||||||
|
if i >= 1 and i <= 4 then t[#t+1] = str end i = i + 1
|
||||||
|
end
|
||||||
|
return table.concat(t, ".")
|
||||||
|
end
|
||||||
|
|
|
@ -36,12 +36,13 @@
|
||||||
|
|
||||||
var status = interface + ', ' + peer.state.toLowerCase();
|
var status = interface + ', ' + peer.state.toLowerCase();
|
||||||
|
|
||||||
if (peer.version === 0) {
|
if ((typeof peer.version === 'undefined') || (peer.version == false)) {
|
||||||
var version = '-';
|
var version = '-';
|
||||||
} else {
|
} else {
|
||||||
var version = 'v' + peer.version;
|
var version = peer.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var link = peer.lladdr;
|
||||||
var rxtx = lbbytes(peer.bytesIn) + ' / ' + lbbytes(peer.bytesOut);
|
var rxtx = lbbytes(peer.bytesIn) + ' / ' + lbbytes(peer.bytesOut);
|
||||||
|
|
||||||
var row = table.insertRow(-1);
|
var row = table.insertRow(-1);
|
||||||
|
@ -50,13 +51,14 @@
|
||||||
row.insertCell(-1).textContent = peer.ipv6;
|
row.insertCell(-1).textContent = peer.ipv6;
|
||||||
row.insertCell(-1).textContent = status;
|
row.insertCell(-1).textContent = status;
|
||||||
row.insertCell(-1).textContent = version;
|
row.insertCell(-1).textContent = version;
|
||||||
|
row.insertCell(-1).textContent = link;
|
||||||
row.insertCell(-1).textContent = rxtx;
|
row.insertCell(-1).textContent = rxtx;
|
||||||
var latencyCell = row.insertCell(-1);
|
var latencyCell = row.insertCell(-1);
|
||||||
latencyCell.textContent = 'waiting';
|
latencyCell.textContent = 'waiting';
|
||||||
|
|
||||||
var pingURI = '<%=luci.dispatcher.build_url("admin", "services", "cjdns", "ping")%>';
|
var pingURI = '<%=luci.dispatcher.build_url("admin", "services", "cjdns", "ping")%>';
|
||||||
var timeout = 2000;
|
var timeout = 2000;
|
||||||
XHR.get(pingURI, { label: peer.switchLabel, timeout: timeout }, function(x, pong) {
|
XHR.get(pingURI, { label: peer.label, timeout: timeout }, function(x, pong) {
|
||||||
var pongrsp = ((pong.err == "ai:recv > timeout") || (pong == "undefined") || (pong.ms >= timeout))
|
var pongrsp = ((pong.err == "ai:recv > timeout") || (pong == "undefined") || (pong.ms >= timeout))
|
||||||
? '> ' + timeout + ' ms'
|
? '> ' + timeout + ' ms'
|
||||||
: pong.ms + ' ms';
|
: pong.ms + ' ms';
|
||||||
|
@ -106,6 +108,7 @@ function lbbytes (bytes){
|
||||||
<th class="cbi-section-table-cell">IPv6</th>
|
<th class="cbi-section-table-cell">IPv6</th>
|
||||||
<th class="cbi-section-table-cell">Status</th>
|
<th class="cbi-section-table-cell">Status</th>
|
||||||
<th class="cbi-section-table-cell">Version</th>
|
<th class="cbi-section-table-cell">Version</th>
|
||||||
|
<th class="cbi-section-table-cell">Address</th>
|
||||||
<th class="cbi-section-table-cell">Rx / Tx</th>
|
<th class="cbi-section-table-cell">Rx / Tx</th>
|
||||||
<th class="cbi-section-table-cell">Latency</th>
|
<th class="cbi-section-table-cell">Latency</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in a new issue