This commit is contained in:
William Fleurant 2018-07-02 03:24:19 +00:00 committed by GitHub
commit b58b0c79da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 8 deletions

View file

@ -18,11 +18,11 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=cjdns
PKG_VERSION:=20.2
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE_URL:=https://github.com/cjdelisle/cjdns.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=77259a49e5bc7ca7bc6dca5bd423e02be563bdc5
PKG_SOURCE_VERSION:=a88859364aa2e38acd96a34f4ec9085b59fd6f1e
PKG_LICENSE:=GPL-3.0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)

View file

@ -51,7 +51,9 @@ function act_peers()
end
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
peer.user = ''
uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer)
@ -97,9 +99,23 @@ function act_ping()
luci.http.write_json(response)
end
function publictoip6(publicKey)
local process = io.popen("/usr/bin/publictoip6 " .. publicKey, "r")
function publictoip6(addrLine)
local t = string.sub(addrLine, string.len(addrLine) - 53)
local process = io.popen("/usr/bin/publictoip6 " .. t, "r")
local ipv6 = process:read()
process:close()
return ipv6
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

View file

@ -36,12 +36,13 @@
var status = interface + ', ' + peer.state.toLowerCase();
if (peer.version === 0) {
if ((typeof peer.version === 'undefined') || (peer.version == false)) {
var version = '-';
} else {
var version = 'v' + peer.version;
var version = peer.version;
}
var link = peer.lladdr;
var rxtx = lbbytes(peer.bytesIn) + ' / ' + lbbytes(peer.bytesOut);
var row = table.insertRow(-1);
@ -50,13 +51,14 @@
row.insertCell(-1).textContent = peer.ipv6;
row.insertCell(-1).textContent = status;
row.insertCell(-1).textContent = version;
row.insertCell(-1).textContent = link;
row.insertCell(-1).textContent = rxtx;
var latencyCell = row.insertCell(-1);
latencyCell.textContent = 'waiting';
var pingURI = '<%=luci.dispatcher.build_url("admin", "services", "cjdns", "ping")%>';
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))
? '> ' + timeout + ' 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">Status</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">Latency</th>
</tr>