Add LocalHost Connection Type (#109)

Add a connection type field to info.lua so the api can provide it to the 
newui Local Hosts display.
This commit is contained in:
Steve AB7PA 2021-05-21 09:12:43 -07:00 committed by GitHub
parent 1c76248765
commit 79a57a0021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 1 deletions

View File

@ -504,6 +504,21 @@ function model.getCurrentDHCPLeases()
return leases
end
-------------------------------------
-- Returns Local Host Connection Type
-------------------------------------
function model.getLocalCnxType(hostname)
if string.match(hostname,"localhost") then
return "Loopback"
elseif string.match(hostname,"dtdlink") then
return "DTD"
elseif hostname == string.lower( model.getNodeName() ) then
return "RF"
else
return "LAN"
end
end
-------------------------------------
-- Returns Local Hosts
-------------------------------------
@ -521,11 +536,13 @@ function model.getLocalHosts()
if ip then
local entry = {
["ip"] = ip,
["hostnames"] = { }
["hostnames"] = { },
["cnxtype"] = ""
}
local index = 0
for hostname in entries:gmatch("%S+") do
hostname = string.gsub(hostname,".local.mesh$","")
entry["cnxtype"] = model.getLocalCnxType(hostname)
entry["hostnames"][index] = hostname
index = index + 1
end