diff --git a/files/app/partial/local-services.ut b/files/app/partial/local-services.ut index 24374e1e..d4dfff06 100755 --- a/files/app/partial/local-services.ut +++ b/files/app/partial/local-services.ut @@ -36,21 +36,22 @@ const reService = /^([^|]+)\|1\|([^|]+)\|([^|]+)\|(\d+)\|(.*)$/; const reLink = /^([^|]+)\|0\|\|([^|]+)\|\|$/; const reType = /^(.+) \[([a-z]+)\]$/; - const reOlsr = /PlParam "service" ".*\|([^|]+)"/; const services = []; const devices = []; const leases = {}; - const activesvc = {}; + const valid = {}; const dhcp = configuration.getDHCP(); - let f = fs.open("/var/etc/olsrd.conf"); + let f = fs.open("/tmp/service-validation-state"); if (f) { + const now = time(); for (let l = f.read("line"); length(l); l = f.read("line")) { - const m = match(l, reOlsr); - if (m) { - activesvc[m[1]] = true; + const m = match(trim(l), /^(\d+) (.+)$/); + const n = split(m[2], "|"); + if (length(n) > 1) { + valid[n[0]] = (int(m[1]) > now); } } f.close(); @@ -61,7 +62,7 @@ const v = match(l, reService); if (v) { let type = ""; - if (!activesvc[v[1]]) { + if (valid[`${v[2]}://${v[3]}:${v[4]}/${v[5]}`] === false) { type += `
`; } const v2 = match(v[1], reType); @@ -101,7 +102,15 @@ for (let l = f.read("line"); length(l); l = f.read("line")) { const v = match(trim(l), /^([^ ]+) ([^ ]+) ([^ ]+) ?(.*)/); if (v && v[4] !== "#NOPROP") { - push(devices, `
${v[3]}
`); + if (valid[`pseudo://${v[3]}:80/`] === true) { + push(devices, `
${v[3]}
`); + } + else if (valid[`pseudos://${v[3]}:443/`] === true) { + push(devices, `
${v[3]}
`); + } + else { + push(devices, `
${v[3]}
`); + } } } f.close(); diff --git a/files/app/resource/css/user.css b/files/app/resource/css/user.css index e6e98c9e..0d606382 100755 --- a/files/app/resource/css/user.css +++ b/files/app/resource/css/user.css @@ -474,7 +474,8 @@ body.authenticated #local-and-neighbor-devices .status.ctrl:hover color: var(--service-fg-color-status); background-color: var(--service-bg-color-status-inactive); } -#services .service .icon +#services .service .icon, +#services .device .icon { position: relative; display: inline-block; @@ -962,6 +963,10 @@ body.authenticated #local-and-neighbor-devices .status.ctrl:hover /* start icons */ +.icon.link +{ + background-image: url('data:image/svg+xml;utf8,') !important; +} .icon.status { background-image: url('data:image/svg+xml;utf8,') !important; diff --git a/files/usr/lib/lua/aredn/services.lua b/files/usr/lib/lua/aredn/services.lua index 48e2b002..62524cdd 100755 --- a/files/usr/lib/lua/aredn/services.lua +++ b/files/usr/lib/lua/aredn/services.lua @@ -109,7 +109,10 @@ local function get(validate) local dtdip = line:match("^(%d+%.%d+%.%d+%.%d+)%s+dtdlink%.") if dtdip then hosts[#hosts + 1] = { ip = dtdip, host = "dtdlink." .. name .. ".local.mesh" } - break + end + local lanip = line:match("^(%d+%.%d+%.%d+%.%d+)%s+localnode$") + if lanip then + hosts[#hosts + 1] = { ip = lanip, host = "lan." .. name .. ".local.mesh" } end end end @@ -169,8 +172,12 @@ local function get(validate) do if os.execute("/bin/ping -q -c 1 -W 1 " .. host.ip .. " > /dev/null 2>&1") == 0 then vstate[host.host:lower()] = last + services[#services + 1] = string.format("pseudo://%s:80/|tcp|pseudo", host.host) + services[#services + 1] = string.format("pseudos://%s:443/|tcp|pseudos", host.host) elseif os.execute("/usr/sbin/arping -q -f -c 1 -w 1 -I " .. laniface .. " " .. host.ip .. " > /dev/null 2>&1") == 0 then vstate[host.host:lower()] = last + services[#services + 1] = string.format("pseudo://%s:80/|tcp|pseudo", host.host) + services[#services + 1] = string.format("pseudos://%s:443/|tcp|pseudos", host.host) end end -- Load NAT @@ -215,7 +222,7 @@ local function get(validate) if port == "0" then -- no port so not a link - we can only check the hostname so have to assume the service is good vstate[service] = last - elseif proto == "http" then + elseif proto == "http" or proto == "pseudo" then -- http so looks like a link. http check it if not hostname:match("%.local%.mesh$") then hostname = hostname .. ".local.mesh" @@ -298,13 +305,15 @@ local function get(validate) services = {} for _, service in ipairs(old_services) do - local vs = vstate[service] - if not vs then - -- New services will be valid for a while, even if they're not there yet - services[#services + 1] = service - vstate[service] = last - elseif vs > now then - services[#services + 1] = service + if not service:match("^pseudo:") and not service:match("^pseudos:") then + local vs = vstate[service] + if not vs then + -- New services will be valid for a while, even if they're not there yet + services[#services + 1] = service + vstate[service] = last + elseif vs > now then + services[#services + 1] = service + end end end