Handle names missing .local.mesh (#528)

This commit is contained in:
Tim Wilkinson 2022-10-20 13:43:55 -07:00 committed by GitHub
parent 27115894ab
commit f7909823ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 109 additions and 99 deletions

View File

@ -495,60 +495,64 @@ if next(localhosts) then
for ip, host in pairs(localhosts) for ip, host in pairs(localhosts)
do do
local localpart = host.name:match("([^.]*)%.") local localpart = host.name:match("([^.]*)%.")
local tactical = "" if localpart then
if host.tactical ~= "" then local tactical = ""
tactical = " / " .. host.tactical if host.tactical ~= "" then
end tactical = " / " .. host.tactical
local row = "<tr><td>" .. localpart .. tactical
if wangateway[ip] then
row = row .. " &nbsp; <small>(wan)</small>"
end
row = row .. "</td><td></td><td>"
if services[host.name] then
for n, v in pairs(services[host.name])
do
row = row .. v .. "<br>"
end end
end local row = "<tr><td>" .. localpart .. tactical
row = row .. "</td></tr>" if wangateway[ip] then
row = row .. " &nbsp; <small>(wan)</small>"
-- add locally advertised dmz hosts
for i, dmzhost in ipairs(host.hosts)
do
local nopropd = false
local aliased = false
for _, v in ipairs(host.noprops)
do
if v == dmzhost then
nopropd = true;
break
end
end end
for _, v in ipairs(host.aliases) row = row .. "</td><td></td><td>"
do if services[host.name] then
if v == dmzhost then for n, v in pairs(services[host.name])
aliased = true;
break
end
end
local localpart = dmzhost:match("(.*)%.local%.mesh")
if not nopropd and not aliased then
row = row .. "<tr><td></td><td>" .. localpart .. "</td>"
elseif aliased then
row = row .. "<tr><td></td><td class=aliased-hosts title='Aliased Host'>" .. localpart .. "</td>"
else
row = row .. "<tr><td></td><td class=hidden-hosts title='Non Propagated Host'>" .. localpart .."</td>"
end
if services[dmzhost] then
row = row .. "</td><td>"
for n, v in pairs(services[dmzhost])
do do
row = row .. v .. "<br>" row = row .. v .. "<br>"
end end
end end
row = row .. "</td></tr>" row = row .. "</td></tr>"
-- add locally advertised dmz hosts
for i, dmzhost in ipairs(host.hosts)
do
local nopropd = false
local aliased = false
for _, v in ipairs(host.noprops)
do
if v == dmzhost then
nopropd = true;
break
end
end
for _, v in ipairs(host.aliases)
do
if v == dmzhost then
aliased = true;
break
end
end
local localpart = dmzhost:match("(.*)%.local%.mesh")
if localpart then
if not nopropd and not aliased then
row = row .. "<tr><td></td><td>" .. localpart .. "</td>"
elseif aliased then
row = row .. "<tr><td></td><td class=aliased-hosts title='Aliased Host'>" .. localpart .. "</td>"
else
row = row .. "<tr><td></td><td class=hidden-hosts title='Non Propagated Host'>" .. localpart .."</td>"
end
if services[dmzhost] then
row = row .. "</td><td>"
for n, v in pairs(services[dmzhost])
do
row = row .. v .. "<br>"
end
end
row = row .. "</td></tr>"
end
end
rows[#rows + 1] = { key = host.name, row = row }
end end
rows[#rows + 1] = { key = host.name, row = row }
end end
table.sort(rows, function(a,b) return a.key < b.key end) table.sort(rows, function(a,b) return a.key < b.key end)
for _, row in ipairs(rows) for _, row in ipairs(rows)
@ -717,15 +721,17 @@ do
for _, dmzhost in ipairs(host.hosts) for _, dmzhost in ipairs(host.hosts)
do do
local localpart = dmzhost:match("(.*)%.local%.mesh") local localpart = dmzhost:match("(.*)%.local%.mesh")
row = row .. "<tr><td></td><td>" .. localpart .. "</td>" if localpart then
row = row .. "<td colspan=3></td><td>" row = row .. "<tr><td></td><td>" .. localpart .. "</td>"
if services[dmzhost] then row = row .. "<td colspan=3></td><td>"
for _, v in pairs(services[dmzhost]) if services[dmzhost] then
do for _, v in pairs(services[dmzhost])
row = row .. v .. "<br>" do
row = row .. v .. "<br>"
end
end end
row = row .. "</td></tr>"
end end
row = row .. "</td></tr>"
end end
end end
end end
@ -766,60 +772,64 @@ for ip, host in pairs(hosts)
do do
if not neighbor[ip] and host.name then if not neighbor[ip] and host.name then
local localpart = host.name:match("(.*)%.local%.mesh") local localpart = host.name:match("(.*)%.local%.mesh")
local tactical = "" if localpart then
if host.tactical then local tactical = ""
tactical = " / " .. host.tactical if host.tactical then
end tactical = " / " .. host.tactical
local etx = string.format("%.2f", host.etx) end
local row = "<tr><td><a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>" local etx = string.format("%.2f", host.etx)
local nodeiface local row = "<tr><td><a href='http://" .. host.name .. ":8080/'>" .. localpart .. tactical .. "</a>"
local mycount = 0 local nodeiface
if midcount[ip] then local mycount = 0
mycount = midcount[ip] if midcount[ip] then
end mycount = midcount[ip]
if dtd[ip] then end
mycount = mycount - 1 if dtd[ip] then
end mycount = mycount - 1
if hosts[ip].tactical then end
mycount = mycount - 1 if hosts[ip].tactical then
end mycount = mycount - 1
if mycount > 0 then end
nodeiface = "tun*" .. mycount if mycount > 0 then
end nodeiface = "tun*" .. mycount
if wangateway[ip] then end
if wangateway[ip] then
if nodeiface then
nodeiface = nodeiface .. ",wan"
else
nodeiface = "wan"
end
end
if nodeiface then if nodeiface then
nodeiface = nodeiface .. ",wan" row = row .. " &nbsp; <small>(" .. nodeiface .. ")</small>"
else
nodeiface = "wan"
end end
end row = row .. "</td><td></td><td>" .. etx .. "</td><td>"
if nodeiface then if services[host.name] then
row = row .. " &nbsp; <small>(" .. nodeiface .. ")</small>" for _, v in pairs(services[host.name])
end
row = row .. "</td><td></td><td>" .. etx .. "</td><td>"
if services[host.name] then
for _, v in pairs(services[host.name])
do
row = row .. v .. "<br>"
end
end
row = row .. "</td></tr>"
-- add locally advertised dmz hosts
for _, dmzhost in ipairs(host.hosts)
do
local localpart = dmzhost:match("(.*)%.local%.mesh")
row = row .. "<tr><td></td><td>" .. localpart .. "</td><td></td><td>"
if services[dmzhost] then
for _, v in pairs(services[dmzhost])
do do
row = row .. v .. "<br>" row = row .. v .. "<br>"
end end
end end
row = row .. "</td></tr>" row = row .. "</td></tr>"
end
rows[#rows + 1] = { key = host.etx, row = row } -- add locally advertised dmz hosts
for _, dmzhost in ipairs(host.hosts)
do
local localpart = dmzhost:match("(.*)%.local%.mesh")
if localpart then
row = row .. "<tr><td></td><td>" .. localpart .. "</td><td></td><td>"
if services[dmzhost] then
for _, v in pairs(services[dmzhost])
do
row = row .. v .. "<br>"
end
end
row = row .. "</td></tr>"
end
end
rows[#rows + 1] = { key = host.etx, row = row }
end
end end
end end