mirror of https://github.com/aredn/aredn.git
Fix missing hosts on mesh page (#1146)
* Another attempt to stop the mesh page from being truncated sometimes * Fix originator
This commit is contained in:
parent
d8c29d60e9
commit
9b89db7a7f
|
@ -33,9 +33,12 @@
|
|||
version.
|
||||
|
||||
--]]
|
||||
|
||||
require("nixio")
|
||||
require("aredn.http")
|
||||
require("aredn.utils")
|
||||
local ai=require("aredn.info")
|
||||
require("aredn.info")
|
||||
|
||||
-------------------------------------
|
||||
-- Public API is attached to table
|
||||
-------------------------------------
|
||||
|
@ -124,8 +127,8 @@ function model.getCurrentNeighbors(RFinfo)
|
|||
|
||||
if info[mainip]['linkType'] == "RF" and RFinfo then
|
||||
require("iwinfo")
|
||||
local radio = ai.getMeshRadioDevice()
|
||||
local bandwidth = tonumber(ai.getChannelBW(radio))
|
||||
local radio = aredn.info.getMeshRadioDevice()
|
||||
local bandwidth = tonumber(aredn.info.getChannelBW(radio))
|
||||
local RFinterface=get_ifname('wifi')
|
||||
local arptable=capture("/bin/cat /proc/net/arp |grep "..RFinterface)
|
||||
local lines=arptable:splitNewLine()
|
||||
|
@ -159,4 +162,32 @@ function model.getCurrentNeighbors(RFinfo)
|
|||
return info
|
||||
end
|
||||
|
||||
function model.getHostAsLines(attempts)
|
||||
if not attempts then
|
||||
attempts = 1
|
||||
end
|
||||
for _ = 1, attempts
|
||||
do
|
||||
local f = io.open("/var/run/hosts_olsr")
|
||||
if f then
|
||||
return f:lines()
|
||||
end
|
||||
nixio.nanosleep(1, 0)
|
||||
end
|
||||
return string.gmatch("", ".")
|
||||
end
|
||||
|
||||
function model.getServicesAsLines()
|
||||
local f = io.open("/var/run/services_olsr")
|
||||
if f then
|
||||
return f:lines()
|
||||
end
|
||||
return string.gmatch("", ".")
|
||||
end
|
||||
|
||||
if not aredn then
|
||||
aredn = {}
|
||||
end
|
||||
aredn.olsr = model;
|
||||
|
||||
return model
|
||||
|
|
|
@ -41,8 +41,8 @@ require("aredn.http")
|
|||
require("aredn.utils")
|
||||
require("aredn.html")
|
||||
require("uci")
|
||||
aredn.info = require("aredn.info")
|
||||
aredn.olsr = require("aredn.olsr")
|
||||
require("aredn.info")
|
||||
require("aredn.olsr")
|
||||
require("iwinfo")
|
||||
require('luci.jsonc')
|
||||
|
||||
|
@ -237,8 +237,7 @@ do
|
|||
end
|
||||
|
||||
-- load the olsr hosts file
|
||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
for line in aredn.olsr.getHostAsLines(2)
|
||||
do
|
||||
local ip, name, originator = line:match("^([%d%.]+)%s+(%S+)%s+%S+%s+(%S+)")
|
||||
if ip and originator and originator ~= "myself" and (routes[ip] or routes[originator]) then
|
||||
|
@ -293,13 +292,11 @@ if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- discard
|
||||
routes = nil
|
||||
|
||||
if nixio.fs.stat("/var/run/services_olsr") then
|
||||
for line in io.lines("/var/run/services_olsr")
|
||||
for line in aredn.olsr.getServicesAsLines()
|
||||
do
|
||||
if line:match("^%w") then
|
||||
local url, name = line:match("^(.*)|.*|(.*)$")
|
||||
|
@ -326,11 +323,11 @@ if nixio.fs.stat("/var/run/services_olsr") then
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- load the node history
|
||||
if nixio.fs.stat("/tmp/node.history") then
|
||||
for line in io.lines("/tmp/node.history")
|
||||
local f = io.open("/tmp/node.history")
|
||||
if f then
|
||||
for line in f:lines("/tmp/node.history")
|
||||
do
|
||||
local ip, age, host = line:match("^(%S+) (%d+) (%S+)")
|
||||
if ip and age and host then
|
||||
|
|
Loading…
Reference in New Issue