mirror of https://github.com/aredn/aredn.git
Snapshot hostnames after updates so we have a consistent copy to display (#488)
This commit is contained in:
parent
3f89bb4290
commit
6ba17b8e5a
|
@ -12,7 +12,7 @@ no-negcache
|
|||
resolv-file=/tmp/resolv.conf.auto
|
||||
|
||||
# include olsr nameservice
|
||||
addn-hosts=/var/run/hosts_olsr
|
||||
addn-hosts=/var/run/hosts_olsr.stable
|
||||
|
||||
dhcp-authoritative
|
||||
dhcp-leasefile=/tmp/dhcp.leases
|
||||
|
|
|
@ -355,7 +355,7 @@ function model.all_hosts()
|
|||
local hosts={}
|
||||
local lines={}
|
||||
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
|
||||
for line in hfile:lines() do
|
||||
table.insert(lines,line)
|
||||
|
@ -571,7 +571,7 @@ end
|
|||
-------------------------------------
|
||||
function model.getLocalHosts()
|
||||
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()
|
||||
data = {}
|
||||
for k,v in pairs(lines) do
|
||||
|
|
|
@ -63,7 +63,7 @@ function do_namechange()
|
|||
local history = {}
|
||||
|
||||
-- Load the hosts file
|
||||
for line in io.lines("/var/run/hosts_olsr")
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
do
|
||||
local v = line:splitWhiteSpace()
|
||||
local ip = v[1]
|
||||
|
|
|
@ -262,7 +262,7 @@ print([[{]])
|
|||
print([[ PlParam "sighup-pid-file" "/var/run/dnsmasq/dnsmasq.pid"]])
|
||||
print([[ PlParam "interval" "30"]])
|
||||
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)
|
||||
do
|
||||
print([[ PlParam "name" "]] .. name .. [["]])
|
||||
|
|
|
@ -145,7 +145,7 @@ function getRemoteNodes()
|
|||
do
|
||||
routeetx[v.destination] = string.format("%.2f", v.etx)
|
||||
end
|
||||
for line in io.lines("/var/run/hosts_olsr")
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
do
|
||||
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
|
||||
|
|
|
@ -317,7 +317,7 @@ do
|
|||
end
|
||||
|
||||
-- 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
|
||||
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
|
||||
|
|
|
@ -453,8 +453,8 @@ do
|
|||
if val == "_add" then
|
||||
if host ~= "" then
|
||||
local pattern = "%s" .. host .. "%s"
|
||||
if nixio.fs.stat("/var/run/hosts_olsr") then
|
||||
for line in io.lines("/var/run/hosts_olsr")
|
||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
do
|
||||
if line:lower():match(pattern) then
|
||||
foundhost = true
|
||||
|
@ -649,8 +649,8 @@ do
|
|||
if val == "_add" then
|
||||
if host ~= "" then
|
||||
local pattern = "%s" .. host .. "%s"
|
||||
if nixio.fs.stat("/var/run/hosts_olsr") then
|
||||
for line in io.lines("/var/run/hosts_olsr")
|
||||
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
do
|
||||
if line:lower():match(pattern) then
|
||||
foundhost = true
|
||||
|
|
|
@ -59,7 +59,7 @@ function mesh_ip_to_hostnames(ip)
|
|||
end
|
||||
end
|
||||
local hosts = ""
|
||||
for line in io.lines("/var/run/hosts_olsr")
|
||||
for line in io.lines("/var/run/hosts_olsr.stable")
|
||||
do
|
||||
local host = line:match(pattern)
|
||||
if host then
|
||||
|
|
|
@ -53,6 +53,7 @@ local files = {
|
|||
"/etc/mesh-release",
|
||||
"/tmp/etc/",
|
||||
"/var/run/hosts_olsr",
|
||||
"/var/run/hosts_olsr.stable",
|
||||
"/var/run/services_olsr",
|
||||
"/tmp/rssi.dat",
|
||||
"/tmp/rssi.log",
|
||||
|
|
Loading…
Reference in New Issue