Dawnline 0.2.0
- Diagnostics page: Health and Log tabs in place of Health and Activity - Watchdog: repairs the AmneziaWG module, tunnels, nft table, firewall rules, uhttpd portal setting, portal, resolver and rpcd after two bad checks in a row, with backoff; after 3 failed repairs logs once in red, keeps repairing quietly and logs "restored" when it works again - Heartbeat cron job restarts a hung agent - Service log: tunnel and service starts with reasons (restarted, router start, update, crash), stops Dawnline made itself vs unexpected ones, certificate renewal and expiry, WAN address changes - Admin actions logged as "You ..." with their own icon and tint; every event has an icon tile; names kept for removed people and devices; server pill on events when there are several servers - Log filters: All, Connections, People, System, Problems; search and the command palette removed - Home network reaches people's devices: fw4 forwarding from the home zones, limited to people with home access - "Devices reach each other" per server, in the Access card - Portal: "This device" card first with a dotted border, key rotation and copy address in the menu, devices sorted Online/Offline/Not set up/Paused, over-limit slots in orange - People cards: slot bar, Online / Never connected, add chip always shown - Person and device pages: Add device tile, Connect at the bottom with File/Key/QR tabs, status text without dots; pulsing server tab dot - Server pill: Running / Not running / Turned off
This commit is contained in:
1 parent
d0955e44b8
commit
82ab86848e
50 files changed
+2166
-982
No files matched your search
+151
-30
@@ -11,13 +11,13 @@ import { ago, bits, bytes, daysLeft, initials } from '../../shared/format';
|
||||
import { ConnectionMap, rangeControl, type Range } from '../map';
|
||||
import { attachTip } from '../charts';
|
||||
import { methodInfo } from '../disguise';
|
||||
import { personUrl } from '../palette';
|
||||
import { personUrl } from '../urls';
|
||||
|
||||
const EVENT_TONE: Record<string, string> = {
|
||||
connect: 'ok',
|
||||
disconnect: '',
|
||||
roam: '',
|
||||
device_added: 'accent',
|
||||
device_added: 'ok',
|
||||
device_removed: '',
|
||||
person_added: '',
|
||||
person_removed: '',
|
||||
@@ -25,63 +25,177 @@ const EVENT_TONE: Record<string, string> = {
|
||||
resumed: 'ok',
|
||||
paused_all: 'warn',
|
||||
resumed_all: 'ok',
|
||||
server_down: 'bad',
|
||||
server_up: 'ok',
|
||||
portal_blocked: 'bad',
|
||||
person_changed: '',
|
||||
devices_removed: 'warn',
|
||||
};
|
||||
|
||||
/** The icon in an event's tile: the device's kind for device events, else what happened. */
|
||||
const EVENT_ICON: Record<string, string> = {
|
||||
devices_removed: 'trash',
|
||||
link_changed: 'link',
|
||||
person_added: 'plus',
|
||||
person_removed: 'trash',
|
||||
person_changed: 'edit',
|
||||
paused: 'pause',
|
||||
resumed: 'play',
|
||||
paused_all: 'pause',
|
||||
resumed_all: 'play',
|
||||
};
|
||||
|
||||
function eventIcon(st: Status, e: LogEvent): string {
|
||||
if (e.device) {
|
||||
const d = st.people.flatMap((p) => p.devices).find((x) => x.id === e.device);
|
||||
return d?.kind ?? e.dkind ?? 'other';
|
||||
}
|
||||
return EVENT_ICON[e.type] ?? 'activity';
|
||||
}
|
||||
|
||||
const ADMIN_TYPES = ['person_added', 'person_removed', 'person_changed', 'paused_all', 'resumed_all'];
|
||||
|
||||
/** Who did it. Older events have no `by`: LuCI and the portal marked it in the detail. */
|
||||
export function eventBy(e: LogEvent): 'admin' | 'portal' | null {
|
||||
if (e.by) return e.by;
|
||||
if (ADMIN_TYPES.includes(e.type) || e.detail === 'by admin' || e.detail?.endsWith(' (admin)')) return 'admin';
|
||||
if (e.detail?.endsWith(' (portal)')) return 'portal';
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The detail without the old "(admin)" / "(portal)" / "by admin" marks. */
|
||||
function plainDetail(e: LogEvent): string {
|
||||
return (e.detail ?? '').replace(/ \((admin|portal)\)$/, '').replace(/^by admin$/, '');
|
||||
}
|
||||
|
||||
export function eventText(st: Status, e: LogEvent): Node[] {
|
||||
const person = st.people.find((p) => p.id === e.person);
|
||||
const who = person?.name ?? e.person ?? '';
|
||||
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? '';
|
||||
const who = person?.name ?? e.pname ?? e.person ?? '';
|
||||
const dev = person?.devices.find((d) => d.id === e.device)?.name ?? e.dname ?? '';
|
||||
const b = (t: string) => E('b', {}, t);
|
||||
const m = (t: string) => E('span', { class: 'dl-muted' }, t);
|
||||
const mono = (t: string) => E('span', { class: 'dl-mono' }, t);
|
||||
// What the bold name is (a person, a device), said before it in grey.
|
||||
const kind = (t: string) => E('span', { class: 'dl-ev-kind' }, `${t} `);
|
||||
const wd = dev ? `${who} · ${dev}` : who;
|
||||
const detail = plainDetail(e);
|
||||
const devName = detail || dev || 'a device';
|
||||
// The admin's own actions start with an accent "You".
|
||||
const you = (verb: string) => [E('span', { class: 'dl-you' }, 'You'), m(` ${verb} `)];
|
||||
if (eventBy(e) === 'admin')
|
||||
switch (e.type) {
|
||||
case 'device_added':
|
||||
return [...you('added'), kind('device'), b(devName), m(' for '), b(who)];
|
||||
case 'device_removed':
|
||||
return [...you('removed'), kind('device'), b(devName), m(' from '), b(who)];
|
||||
case 'paused':
|
||||
return [...you('paused'), kind('person'), b(who)];
|
||||
case 'resumed':
|
||||
return [...you('resumed'), kind('person'), b(who)];
|
||||
case 'device_changed': {
|
||||
const renamed = detail.startsWith('renamed from ');
|
||||
return [
|
||||
...you(renamed ? 'renamed' : detail),
|
||||
kind('device'),
|
||||
b(dev || 'a device'),
|
||||
m(' of '),
|
||||
b(who),
|
||||
...(renamed ? [m(` · was ${detail.slice(13)}`)] : []),
|
||||
];
|
||||
}
|
||||
case 'device_keys':
|
||||
return [...you('issued new keys for'), kind('device'), b(devName), m(' of '), b(who), m(' · it needs its new configuration')];
|
||||
case 'link_changed':
|
||||
return [...you('issued a new link for'), kind('person'), b(who), m(' · the old link stopped working')];
|
||||
case 'paused_all':
|
||||
return [E('span', { class: 'dl-you' }, 'You'), m(' paused everyone')];
|
||||
case 'resumed_all':
|
||||
return [E('span', { class: 'dl-you' }, 'You'), m(' resumed everyone')];
|
||||
}
|
||||
switch (e.type) {
|
||||
case 'connect':
|
||||
return [b(wd), m(' connected'), ...(e.detail ? [m(' from '), mono(e.detail)] : []), ...(e.where ? [m(` · ${e.where}`)] : [])];
|
||||
return [
|
||||
kind('Device'),
|
||||
b(wd),
|
||||
m(' connected'),
|
||||
...(e.detail ? [m(' from '), mono(e.detail)] : []),
|
||||
...(e.where ? [m(` · ${e.where}`)] : []),
|
||||
];
|
||||
case 'disconnect':
|
||||
return [b(wd), m(' went offline')];
|
||||
return [kind('Device'), b(wd), m(' went offline')];
|
||||
case 'roam':
|
||||
return [b(wd), m(' changed network '), mono(e.detail ?? '')];
|
||||
return [kind('Device'), b(wd), m(' changed network '), mono(e.detail ?? '')];
|
||||
case 'device_added':
|
||||
return [b(who), m(' added '), E('span', {}, e.detail ?? 'a device')];
|
||||
return [
|
||||
kind('Person'),
|
||||
b(who),
|
||||
m(' added '),
|
||||
kind('device'),
|
||||
b(devName),
|
||||
...(eventBy(e) === 'portal' ? [m(' on their portal')] : []),
|
||||
];
|
||||
case 'device_removed':
|
||||
return [b(who), m(' removed '), E('span', {}, e.detail ?? 'a device')];
|
||||
return [
|
||||
kind('Person'),
|
||||
b(who),
|
||||
m(' removed '),
|
||||
kind('device'),
|
||||
b(devName),
|
||||
...(eventBy(e) === 'portal' ? [m(' on their portal')] : []),
|
||||
];
|
||||
case 'device_keys':
|
||||
return [kind('Person'), b(who), m(' issued new keys for '), kind('device'), b(devName), m(' on their portal')];
|
||||
case 'person_added':
|
||||
return [m('You added '), b(e.detail ?? who)];
|
||||
return [...you('added'), kind('person'), b(e.detail ?? who)];
|
||||
case 'person_removed':
|
||||
return [m('You removed '), b(e.detail ?? who)];
|
||||
return [...you('removed'), kind('person'), b(e.detail ?? who)];
|
||||
case 'person_changed':
|
||||
return [m('You changed '), b(who), m(` · ${e.detail ?? ''}`)];
|
||||
// The detail lists changed fields by their option names (device_limit, expire_action).
|
||||
return [...you('changed'), kind('person'), b(who), ...(detail ? [m(` · ${detail.replace(/_/g, ' ')}`)] : [])];
|
||||
case 'paused':
|
||||
return [b(who), m(` paused — ${e.detail ?? ''}`)];
|
||||
return [kind('Person'), b(who), m(` paused — ${e.detail ?? ''}`)];
|
||||
case 'resumed':
|
||||
return [b(who), m(' resumed'), ...(e.detail && e.detail !== 'active' ? [m(` — ${e.detail}`)] : [])];
|
||||
return [kind('Person'), b(who), m(' resumed'), ...(e.detail && e.detail !== 'active' ? [m(` — ${e.detail}`)] : [])];
|
||||
case 'paused_all':
|
||||
return [m('Everyone paused')];
|
||||
case 'resumed_all':
|
||||
return [m('Everyone resumed')];
|
||||
case 'server_down':
|
||||
return [m('Tunnel '), mono(e.detail ?? ''), m(' went down')];
|
||||
case 'server_up':
|
||||
return [m('Tunnel '), mono(e.detail ?? ''), m(' is back up')];
|
||||
case 'portal_blocked':
|
||||
return [m('Portal blocked '), mono(e.detail ?? ''), m(' for 15 min after too many wrong codes')];
|
||||
return [
|
||||
E('b', { class: 'dl-sys-src' }, 'Personal portal'),
|
||||
m(' blocked '),
|
||||
mono(e.detail ?? ''),
|
||||
m(' for 15 min after too many wrong codes'),
|
||||
];
|
||||
case 'devices_removed':
|
||||
return [b(who), m('’s devices were removed — end date reached')];
|
||||
return [kind('Person'), b(who), m(' — all devices removed, end date reached')];
|
||||
default:
|
||||
return [m(`${e.type}${e.detail ? `: ${e.detail}` : ''}`)];
|
||||
}
|
||||
}
|
||||
|
||||
export function eventRow(st: Status, e: LogEvent): HTMLElement {
|
||||
return E('div', { class: 'dl-row' }, [
|
||||
E('span', { class: `dl-ev-dot ${EVENT_TONE[e.type] ?? ''}` }),
|
||||
/** Events about the router rather than people look like service log lines: icon tile, colour by outcome. */
|
||||
const SYSTEM_EVENT: Record<string, [string, string]> = {
|
||||
portal_blocked: ['globe', 'bad'],
|
||||
};
|
||||
|
||||
/** With several servers, which one a person's event happened on (left out where that is clear). */
|
||||
function serverPill(st: Status, e: LogEvent): HTMLElement | '' {
|
||||
if (st.servers.length < 2 || !e.person) return '';
|
||||
const p = st.people.find((x) => x.id === e.person);
|
||||
const srv = p && st.servers.find((s) => s.id === p.server);
|
||||
return srv ? E('span', { class: 'dl-ev-srv', title: 'Server' }, srv.name) : '';
|
||||
}
|
||||
|
||||
export function eventRow(st: Status, e: LogEvent, opts: { server?: boolean } = {}): HTMLElement {
|
||||
const sys = SYSTEM_EVENT[e.type];
|
||||
const by = eventBy(e);
|
||||
return E('div', { class: `dl-row${by === 'admin' ? ' dl-ev-by-admin' : sys ? ` dl-ev-by-system ${sys[1]}` : ''}` }, [
|
||||
by === 'admin'
|
||||
? E('span', { class: 'dl-ev-tile', title: 'Done by you in LuCI' }, icon('admin'))
|
||||
: sys
|
||||
? E('span', { class: 'dl-ev-tile sys' }, icon(sys[0]))
|
||||
: E('span', { class: `dl-ev-tile ev ${EVENT_TONE[e.type] ?? ''}` }, icon(eventIcon(st, e))),
|
||||
E('span', { class: 'dl-row-main' }, eventText(st, e)),
|
||||
opts.server === false ? '' : serverPill(st, e),
|
||||
E('span', { class: 'dl-faint dl-nowrap', title: new Date(e.ts * 1000).toLocaleString() }, ago(e.ts, st.now)),
|
||||
]);
|
||||
}
|
||||
@@ -92,7 +206,10 @@ function attention(st: Status): { tone: string; text: (Node | string)[] }[] {
|
||||
const link = (href: string, t: string) => E('a', { href }, t);
|
||||
for (const s of st.servers)
|
||||
if (s.enabled && !s.up)
|
||||
out.push({ tone: 'bad', text: [`Tunnel ${s.ifname} is down. `, link(L.url('admin/network/dawnline/health'), 'Open Health')] });
|
||||
out.push({
|
||||
tone: 'bad',
|
||||
text: [`Tunnel ${s.ifname} is down. `, link(L.url('admin/network/dawnline/diagnostics'), 'Open Diagnostics')],
|
||||
});
|
||||
if (st.settings.paused_all) out.push({ tone: 'warn', text: ['Everyone is paused.'] });
|
||||
for (const p of st.people) {
|
||||
if (p.state === 'quota') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), ' reached the data limit.'] });
|
||||
@@ -120,7 +237,7 @@ function attention(st: Status): { tone: string; text: (Node | string)[] }[] {
|
||||
if (st.servers.some((s) => s.lan_like) && st.like_home.error)
|
||||
out.push({
|
||||
tone: 'warn',
|
||||
text: [`Internet through the LAN is off: ${st.like_home.error} `, link(L.url('admin/network/dawnline/health'), 'Details')],
|
||||
text: [`Internet through the LAN is off: ${st.like_home.error} `, link(L.url('admin/network/dawnline/diagnostics'), 'Details')],
|
||||
});
|
||||
if (!st.settings.portal_enabled)
|
||||
out.push({ tone: '', text: ['The personal portal is off. ', link(L.url('admin/network/dawnline/settings'), 'Turn on')] });
|
||||
@@ -222,7 +339,11 @@ export class ServerOverview {
|
||||
return it;
|
||||
}),
|
||||
bad.length > 3 ? E('span', { class: 'dl-sub' }, `+${bad.length - 3} more`) : '',
|
||||
E('a', { href: L.url('admin/network/dawnline/health') }, bad.some((c) => c.fix) ? 'Fix in Health →' : 'Open Health →'),
|
||||
E(
|
||||
'a',
|
||||
{ href: L.url('admin/network/dawnline/diagnostics') },
|
||||
bad.some((c) => c.fix) ? 'Fix in Diagnostics →' : 'Open Diagnostics →',
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
@@ -288,7 +409,7 @@ export class ServerOverview {
|
||||
E('div', { class: 'dl-panel-head pad' }, [
|
||||
E('h3', {}, 'Needs attention'),
|
||||
E('span', { class: 'dl-spacer' }),
|
||||
E('a', { href: L.url('admin/network/dawnline/health') }, 'Health'),
|
||||
E('a', { href: L.url('admin/network/dawnline/diagnostics') }, 'Health'),
|
||||
]),
|
||||
att.length
|
||||
? att
|
||||
@@ -305,7 +426,7 @@ export class ServerOverview {
|
||||
E('div', { class: 'dl-panel-head pad' }, [
|
||||
E('h3', {}, 'Activity'),
|
||||
E('span', { class: 'dl-spacer' }),
|
||||
E('a', { href: L.url('admin/network/dawnline/activity') }, 'View all'),
|
||||
E('a', { href: `${L.url('admin/network/dawnline/diagnostics')}?tab=log` }, 'View all'),
|
||||
]),
|
||||
events.length
|
||||
? events.map((e) => eventRow(st, e))
|
||||
|
||||
Reference in new issue
Block a user