Snapshot hostnames after updates so we have a consistent copy to display (#488)

This commit is contained in:
Tim Wilkinson 2022-09-06 07:58:18 -07:00 committed by GitHub
parent 3f89bb4290
commit 6ba17b8e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 13 additions and 12 deletions

View File

@ -12,7 +12,7 @@ no-negcache
resolv-file=/tmp/resolv.conf.auto resolv-file=/tmp/resolv.conf.auto
# include olsr nameservice # include olsr nameservice
addn-hosts=/var/run/hosts_olsr addn-hosts=/var/run/hosts_olsr.stable
dhcp-authoritative dhcp-authoritative
dhcp-leasefile=/tmp/dhcp.leases dhcp-leasefile=/tmp/dhcp.leases

View File

@ -355,7 +355,7 @@ function model.all_hosts()
local hosts={} local hosts={}
local lines={} local lines={}
local pos, val local pos, val
local hfile=io.open("/var/run/hosts_olsr","r") local hfile=io.open("/var/run/hosts_olsr.stable","r")
if hfile~=nil then if hfile~=nil then
for line in hfile:lines() do for line in hfile:lines() do
table.insert(lines,line) table.insert(lines,line)
@ -571,7 +571,7 @@ end
------------------------------------- -------------------------------------
function model.getLocalHosts() function model.getLocalHosts()
local localhosts = {} local localhosts = {}
myhosts=os.capture('/bin/grep "# myself" /var/run/hosts_olsr|grep -v dtdlink') myhosts=os.capture('/bin/grep "# myself" /var/run/hosts_olsr.stable|grep -v dtdlink')
local lines = myhosts:splitNewLine() local lines = myhosts:splitNewLine()
data = {} data = {}
for k,v in pairs(lines) do for k,v in pairs(lines) do

View File

@ -63,7 +63,7 @@ function do_namechange()
local history = {} local history = {}
-- Load the hosts file -- Load the hosts file
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
local v = line:splitWhiteSpace() local v = line:splitWhiteSpace()
local ip = v[1] local ip = v[1]

View File

@ -262,7 +262,7 @@ print([[{]])
print([[ PlParam "sighup-pid-file" "/var/run/dnsmasq/dnsmasq.pid"]]) print([[ PlParam "sighup-pid-file" "/var/run/dnsmasq/dnsmasq.pid"]])
print([[ PlParam "interval" "30"]]) print([[ PlParam "interval" "30"]])
print([[ PlParam "timeout" "300"]]) print([[ PlParam "timeout" "300"]])
print([[ PlParam "name-change-script" "touch /tmp/namechange"]]) print([[ PlParam "name-change-script" "touch /tmp/namechange; cp /var/run/hosts_olsr /var/run/hosts_olsr.snapshot; mv -f /var/run/hosts_olsr.snapshot /var/run/hosts_olsr.stable"]])
for _, name in ipairs(names) for _, name in ipairs(names)
do do
print([[ PlParam "name" "]] .. name .. [["]]) print([[ PlParam "name" "]] .. name .. [["]])

View File

@ -145,7 +145,7 @@ function getRemoteNodes()
do do
routeetx[v.destination] = string.format("%.2f", v.etx) routeetx[v.destination] = string.format("%.2f", v.etx)
end end
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
local ip, hostname = line:match("^(%d+%.%d+%.%d+%.%d+)%s+(%S+)%s+#.*$") local ip, hostname = line:match("^(%d+%.%d+%.%d+%.%d+)%s+(%S+)%s+#.*$")
if ip and not neighbors[ip] and not (hostname:match("^dtdlink%.") or hostname:match("^mid%d+%.")) then if ip and not neighbors[ip] and not (hostname:match("^dtdlink%.") or hostname:match("^mid%d+%.")) then

View File

@ -317,7 +317,7 @@ do
end end
-- load the olsr hosts file -- load the olsr hosts file
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
local ip, name, originator = line:match("^([%d%.]+)%s+(%S+)%s+%S+%s+(%S+)") 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 if ip and originator and originator ~= "myself" and (routes[ip] or routes[originator]) then

View File

@ -453,8 +453,8 @@ do
if val == "_add" then if val == "_add" then
if host ~= "" then if host ~= "" then
local pattern = "%s" .. host .. "%s" local pattern = "%s" .. host .. "%s"
if nixio.fs.stat("/var/run/hosts_olsr") then if nixio.fs.stat("/var/run/hosts_olsr.stable") then
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
if line:lower():match(pattern) then if line:lower():match(pattern) then
foundhost = true foundhost = true
@ -649,8 +649,8 @@ do
if val == "_add" then if val == "_add" then
if host ~= "" then if host ~= "" then
local pattern = "%s" .. host .. "%s" local pattern = "%s" .. host .. "%s"
if nixio.fs.stat("/var/run/hosts_olsr") then if nixio.fs.stat("/var/run/hosts_olsr.stable") then
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
if line:lower():match(pattern) then if line:lower():match(pattern) then
foundhost = true foundhost = true

View File

@ -59,7 +59,7 @@ function mesh_ip_to_hostnames(ip)
end end
end end
local hosts = "" local hosts = ""
for line in io.lines("/var/run/hosts_olsr") for line in io.lines("/var/run/hosts_olsr.stable")
do do
local host = line:match(pattern) local host = line:match(pattern)
if host then if host then

View File

@ -53,6 +53,7 @@ local files = {
"/etc/mesh-release", "/etc/mesh-release",
"/tmp/etc/", "/tmp/etc/",
"/var/run/hosts_olsr", "/var/run/hosts_olsr",
"/var/run/hosts_olsr.stable",
"/var/run/services_olsr", "/var/run/services_olsr",
"/tmp/rssi.dat", "/tmp/rssi.dat",
"/tmp/rssi.log", "/tmp/rssi.log",