mirror of https://github.com/aredn/aredn.git
Improve which local devices and service we show when logged out or logged in. (#1682)
* Show more devices when logged in as admin * Updates
This commit is contained in:
parent
747871b35d
commit
c29bcc2bdd
|
@ -61,25 +61,28 @@
|
||||||
const l = trim(svcs[i]);
|
const l = trim(svcs[i]);
|
||||||
const v = match(l, reService);
|
const v = match(l, reService);
|
||||||
if (v) {
|
if (v) {
|
||||||
let type = "";
|
const reachable = valid[`${v[2]}://${v[3]}:${v[4]}/${v[5]}`] !== false;
|
||||||
if (valid[`${v[2]}://${v[3]}:${v[4]}/${v[5]}`] === false) {
|
if (reachable || auth.isAdmin) {
|
||||||
type += ` <div class="icon warning" title="Service cannot be reached"></div>`;
|
let type = "";
|
||||||
}
|
if (!reachable) {
|
||||||
const v2 = match(v[1], reType);
|
type += ` <div class="icon warning" title="Service cannot be reached"></div>`;
|
||||||
if (v2) {
|
}
|
||||||
v[1] = v2[1];
|
const v2 = match(v[1], reType);
|
||||||
type += ` <div class="icon ${v2[2]}" title="${v2[2]}"></div>`;
|
if (v2) {
|
||||||
}
|
v[1] = v2[1];
|
||||||
switch (v[4]) {
|
type += ` <div class="icon ${v2[2]}" title="${v2[2]}"></div>`;
|
||||||
case "80":
|
}
|
||||||
push(services, `<div class="service"><a target="_blank" href="http://${v[3]}.local.mesh/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
switch (v[4]) {
|
||||||
break;
|
case "80":
|
||||||
case "443":
|
push(services, `<div class="service"><a target="_blank" href="http://${v[3]}.local.mesh/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
||||||
push(services, `<div class="service"><a target="_blank" href="https://${v[3]}.local.mesh/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
break;
|
||||||
break;
|
case "443":
|
||||||
default:
|
push(services, `<div class="service"><a target="_blank" href="https://${v[3]}.local.mesh/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
||||||
push(services, `<div class="service"><a target="_blank" href="${v[2]}://${v[3]}.local.mesh:${v[4]}/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
break;
|
||||||
break;
|
default:
|
||||||
|
push(services, `<div class="service"><a target="_blank" href="${v[2]}://${v[3]}.local.mesh:${v[4]}/${v[5]}" onclick="event.stopPropagation()">${v[1]}${type}</a></div>`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -97,24 +100,62 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dhcp.enabled) {
|
if (dhcp.enabled) {
|
||||||
f = fs.open(dhcp.reservations);
|
const leased = {};
|
||||||
|
f = fs.open(dhcp.leases);
|
||||||
if (f) {
|
if (f) {
|
||||||
for (let l = f.read("line"); length(l); l = f.read("line")) {
|
for (let l = f.read("line"); length(l); l = f.read("line")) {
|
||||||
const v = match(trim(l), /^([^ ]+) ([^ ]+) ([^ ]+) ?(.*)/);
|
const m = split(trim(l), " ");
|
||||||
if (v && v[4] !== "#NOPROP") {
|
if (length(m) === 5) {
|
||||||
if (valid[`pseudo://${v[3]}:80/`] === true) {
|
if (m[3] === "*") {
|
||||||
push(devices, `<div class="device"><a target="_blank" href="http://${v[3]}.local.mesh" onclick="event.stopPropagation()">${v[3]} <div class="icon link" title="link"></div></a></div>`);
|
leased[lc(m[1])] = { n: m[2], p: 0, s: auth.isAdmin, v: true };
|
||||||
}
|
|
||||||
else if (valid[`pseudos://${v[3]}:443/`] === true) {
|
|
||||||
push(devices, `<div class="device"><a target="_blank" href="https://${v[3]}.local.mesh" onclick="event.stopPropagation()">${v[3]} <div class="icon link" title="link"></div></a></div>`);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
push(devices, `<div class="device">${v[3]}</div>`);
|
leased[lc(m[1])] = { n: m[3], p: 0, s: auth.isAdmin, v: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.close();
|
f.close();
|
||||||
}
|
}
|
||||||
|
f = fs.open(dhcp.reservations);
|
||||||
|
if (f) {
|
||||||
|
for (let l = f.read("line"); length(l); l = f.read("line")) {
|
||||||
|
const v = match(trim(l), /^([^ ]+) ([^ ]+) ([^ ]+) ?(.*)/);
|
||||||
|
if (v && (v[4] !== "#NOPROP" || auth.isAdmin)) {
|
||||||
|
const k = lc(v[1]);
|
||||||
|
const l = leased[k] || (leased[k] = { n: null, p: 0, s: true, v: false });
|
||||||
|
l.n = v[3];
|
||||||
|
l.s = true;
|
||||||
|
if (valid[`pseudo://${v[3]}:80/`] === true) {
|
||||||
|
l.p = 80;
|
||||||
|
}
|
||||||
|
else if (valid[`pseudos://${v[3]}:443/`] === true) {
|
||||||
|
l.p = 443;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
for (let k in leased) {
|
||||||
|
const l = leased[k];
|
||||||
|
if (l.s) {
|
||||||
|
if (!l.v) {
|
||||||
|
if (auth.isAdmin) {
|
||||||
|
push(devices, `<div class="device">${l.n} <div class="icon warning" title="No active lease"></div></div>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (l.p === 80) {
|
||||||
|
push(devices, `<div class="device"><a target="_blank" href="http://${l.n}.local.mesh" onclick="event.stopPropagation()">${l.n} <div class="icon link" title="Connect"></div></a></div>`);
|
||||||
|
}
|
||||||
|
else if (l.p === 443) {
|
||||||
|
push(devices, `<div class="device"><a target="_blank" href="https://${l.n}.local.mesh" onclick="event.stopPropagation()">${l.n} <div class="icon link" title="Connect"></div></a></div>`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
push(devices, `<div class="device">${l.n}</div>`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
<div class="ctrl" hx-get="status/e/local-services" hx-target="#ctrl-modal">
|
<div class="ctrl" hx-get="status/e/local-services" hx-target="#ctrl-modal">
|
||||||
|
|
Loading…
Reference in New Issue