diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index 6b1e0b3c..27814634 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -125,6 +125,7 @@ local ipalias = {} local localhosts = {} local dtd = {} local midcount = {} +local xlinkcount = {} local hosts = {} local services = {} local history = {} @@ -164,7 +165,7 @@ local iwrates local prefix = "/sys/kernel/debug/ieee80211/" .. phy .. "/netdev:" .. wifiif .. "/stations/" for i, node in ipairs(aredn.olsr.getOLSRLinks()) do - links[node.remoteIP] = { lq = node.linkQuality, nlq = node.neighborLinkQuality, mbps = "" } + links[node.remoteIP] = { lq = node.linkQuality, nlq = node.neighborLinkQuality, mbps = "", weight = 65536 / node.lossMultiplier } neighbor[node.remoteIP] = true local mac = arpcache[node.remoteIP] if mac then @@ -285,7 +286,11 @@ if nixio.fs.stat("/var/run/hosts_olsr.stable") then links[ip].dtd = true end elseif name:match("^xlink%d+%.") then - dtd[originator] = true + if not xlinkcount[originator] then + xlinkcount[originator] = 1 + else + xlinkcount[originator] = xlinkcount[originator] + 1 + end if links[ip] then links[ip].xlink = true end @@ -672,8 +677,8 @@ do c1 = c1 .. "   (" .. nodeiface .. ")" end local c2 = "" - local c3 = string.format("%.0f%%", 100 * link.lq) - local c4 = string.format("%.0f%%", 100 * link.nlq) + local c3 = string.format("%.0f%%", math.min(100, math.ceil(100 * link.lq * link.weight))) + local c4 = string.format("%.0f%%", math.min(100, math.ceil(100 * link.nlq * link.weight))) local c5 = string.format("%s", link.mbps) local c6 = "" @@ -807,6 +812,10 @@ do local mycount = 0 if midcount[ip] then mycount = midcount[ip] + if xlinkcount[ip] then + mycount = mycount - xlinkcount[ip] + nodeiface = "xlink*" .. xlinkcount[ip] + end end if dtd[ip] then mycount = mycount - 1 @@ -815,7 +824,11 @@ do mycount = mycount - 1 end if mycount > 0 then - nodeiface = "tun*" .. mycount + if nodeiface then + nodeiface = nodeiface .. ",tun*" .. mycount + else + nodeiface = "tun*" .. mycount + end end if wangateway[ip] then if nodeiface then @@ -900,6 +913,7 @@ end neighbor = nil dtd = nil midcount = nil +xlinkcount = nil wangateway = nil services = nil