From 79a57a002155652052d80d8ac2aeb5ef30106300 Mon Sep 17 00:00:00 2001 From: Steve AB7PA <69524416+ab7pa@users.noreply.github.com> Date: Fri, 21 May 2021 09:12:43 -0700 Subject: [PATCH] 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. --- files/usr/lib/lua/aredn/info.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/files/usr/lib/lua/aredn/info.lua b/files/usr/lib/lua/aredn/info.lua index 2e4886ce..7f620c2f 100755 --- a/files/usr/lib/lua/aredn/info.lua +++ b/files/usr/lib/lua/aredn/info.lua @@ -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