Protect against missing hosts_olsr.stable (#523)

This commit is contained in:
Tim Wilkinson 2022-10-14 13:31:09 -07:00 committed by GitHub
parent 277610bf27
commit caaafc3831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 52 deletions

View File

@ -316,6 +316,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")
do
local ip, name, originator = line:match("^([%d%.]+)%s+(%S+)%s+%S+%s+(%S+)")
@ -362,6 +363,7 @@ do
end
end
end
end
-- discard
routes = nil

View File

@ -58,6 +58,7 @@ function mesh_ip_to_hostnames(ip)
end
end
local hosts = ""
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
for line in io.lines("/var/run/hosts_olsr.stable")
do
local host = line:match(pattern)
@ -65,6 +66,7 @@ function mesh_ip_to_hostnames(ip)
hosts = hosts .. " / " .. host
end
end
end
return hosts:sub(4, #hosts)
end
@ -180,6 +182,7 @@ end
local host_total = 0
local host_nodes = 0
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
for line in io.lines("/var/run/hosts_olsr.stable")
do
if line:match("^10%.") and not line:match("%smid%d+%.") then
@ -190,6 +193,7 @@ do
end
end
end
end
-- post data