Dawnline 0.4.0
Build packages / Version (push) Waiting to run

- Components tab replaces Updates: Dawnline, the AmneziaWG build for this
  firmware (Slava-Shchipunov 2.0 or 2Grey 3.1, Russian translation) and
  the system packages Dawnline adds, each checked, installed, reinstalled
  or rolled back in place, with What's new, versions and an activity log
- Automatic updates: daily check, install at a set time or right away,
  per component; AmneziaWG is left out by default and an automatic run
  never switches its build or generation
- Downloads verified against GitHub's sha256; mirrors are used only when
  GitHub is unreachable and the hash is known
- New installer: checks firmware, clock, space and DNS, lets you pick a
  release, shows the plan and asks first; --dry-run
- New uninstaller removes everything Dawnline added (cron, nft, firewall,
  routing, interfaces, packages it installed); --dry-run
- Works without AmneziaWG on the router: Overview, the setup wizard,
  Health and Components say what is missing and offer to install it
- Overview shows failed health checks as notices with their fix
- People list no longer reads the config from the browser: private keys
  stay on the router; personal links are fetched on demand
- Config changes are serialized under one lock, the nft table loads
  atomically and fails closed, and Dawnline never touches network
  sections it did not create
- The portal never opens system ports, keeps disabled devices disabled,
  rate-limits per address and counts days by the router's clock
- Settings and Diagnostics load their heavy parts in the background
- Release notes are written from the commits since the previous release
- Backend and admin UI split into small single-purpose modules
This commit is contained in:
Aemeath committed 2026-10-16 02:14:15 +03:00
1 parent 70a932b8ea
commit 34293fb8e5
158 files changed
+17418 -10022

No files matched your search

+55 -401
View File
@@ -2,220 +2,41 @@
// online, traffic, disguise, the connection map, activity and what needs
// attention — all limited to the people on that server.
import type { DayUsage, Device, LogEvent, Person, Status } from '../../shared/types';
import type { Device, Person, Status } from '../../shared/types';
import { E } from '../e';
import { api } from '../api';
import { svg } from '../ui';
import { svg } from '../ui/layout';
import { attachTip } from '../ui/tooltip';
import { icon } from '../../shared/icons';
import { ago, bits, bytes, daysLeft, initials } from '../../shared/format';
import { ago, bits, bytes, daysLeft, initials, todayOf } from '../../shared/format';
import { ConnectionMap, rangeControl, type Range } from '../map';
import { attachTip } from '../charts';
import { methodInfo } from '../disguise';
import { personUrl } from '../urls';
import { eventRow } from '../events/render';
import { scoped } from '../state/scope';
import { repaint } from '../state/poller';
import { daysTile, speedTile } from '../widgets/tiles';
import { coreOf } from '../cores';
import { healthNotices, runFix } from '../widgets/health';
const EVENT_TONE: Record<string, string> = {
connect: 'ok',
disconnect: '',
roam: '',
device_added: 'ok',
device_removed: '',
person_added: '',
person_removed: '',
paused: 'warn',
resumed: 'ok',
paused_all: 'warn',
resumed_all: '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.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);
/** An address; at home, the name of the device that has it, with the address in brackets. */
const addr = (ip: string) =>
e.hosts?.[ip]
? [E('span', { class: 'dl-ev-host' }, [E('b', {}, e.hosts[ip]), E('span', { class: 'dl-faint' }, ` (${ip})`)])]
: [mono(ip)];
// 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 [
kind('Device'),
b(wd),
m(' connected'),
...(e.detail ? [m(' from '), ...addr(e.detail)] : []),
...(e.where ? [m(` · ${e.where}`)] : []),
];
case 'disconnect':
return [kind('Device'), b(wd), m(' went offline')];
case 'roam':
return [
kind('Device'),
b(wd),
m(' changed network '),
...(e.detail ?? '').split(' → ').flatMap((ip, i) => (i ? [m(' → '), ...addr(ip)] : addr(ip))),
];
case 'device_added':
return [
kind('Person'),
b(who),
m(' added '),
kind('device'),
b(devName),
...(eventBy(e) === 'portal' ? [m(' on their portal')] : []),
];
case 'device_removed':
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 [...you('added'), kind('person'), b(e.detail ?? who)];
case 'person_removed':
return [...you('removed'), kind('person'), b(e.detail ?? who)];
case 'person_changed':
// 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 [kind('Person'), b(who), m(` paused — ${e.detail ?? ''}`)];
case 'resumed':
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 'portal_blocked':
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 [kind('Person'), b(who), m(' — all devices removed, end date reached')];
default:
return [m(`${e.type}${e.detail ? `: ${e.detail}` : ''}`)];
}
}
/** 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)),
]);
interface Attention {
tone: string;
text: (Node | string)[];
/** A button or link that deals with it. */
action?: Node;
}
/** Things worth the admin's attention, most important first. */
function attention(st: Status): { tone: string; text: (Node | string)[] }[] {
const out: { tone: string; text: (Node | string)[] }[] = [];
function attention(st: Status): Attention[] {
const out: Attention[] = [];
const link = (href: string, t: string) => E('a', { href }, t);
const today = todayOf(st.series);
// AmneziaWG itself can't run: the health notice says so once, not "Tunnel down" for every server.
const awg = !!st.awg_state && !st.awg_state.ok;
for (const s of st.servers)
if (s.enabled && !s.up)
if (s.enabled && s.blocked)
// The reason, not just "down": its interface name is taken by a network section Dawnline didn't make.
out.push({ tone: 'bad', text: [`${s.name} ${s.blocked}. `, link(L.url('admin/network/dawnline/diagnostics'), 'Open Diagnostics')] });
else if (s.enabled && !s.up && !awg)
out.push({
tone: 'bad',
text: [`Tunnel ${s.ifname} is down. `, link(L.url('admin/network/dawnline/diagnostics'), 'Open Diagnostics')],
@@ -225,7 +46,7 @@ function attention(st: Status): { tone: string; text: (Node | string)[] }[] {
if (p.state === 'quota') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), ' reached the data limit.'] });
else if (p.state === 'expired') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), '’s access has ended.'] });
else {
const left = daysLeft(p.expires);
const left = daysLeft(p.expires, today);
if (left != null && left >= 0 && left <= Math.max(p.expire_warn, 3))
out.push({ tone: '', text: [link(personUrl(p.id), p.name), `’s access ends in ${left} day${left === 1 ? '' : 's'}.`] });
if (p.quota_limit && p.quota_used >= p.quota_limit * 0.9)
@@ -254,42 +75,6 @@ function attention(st: Status): { tone: string; text: (Node | string)[] }[] {
return out;
}
/**
* The status as seen from one server: its people, their devices, traffic,
* map points and events (plus router-wide events without a person).
*/
export function scoped(st: Status, srvId: string): Status {
const srv = st.servers.find((s) => s.id === srvId) ?? st.servers[0];
const people = st.people.filter((p) => p.server === srv.id);
const ids = new Set(people.map((p) => p.id));
const devices = people.flatMap((p) => p.devices);
const sum = (f: (p: Person) => [number, number]) =>
people.reduce<[number, number]>(
(a, p) => {
const v = f(p);
return [a[0] + v[0], a[1] + v[1]];
},
[0, 0],
);
const today = srv.series?.[srv.series.length - 1];
return {
...st,
servers: [srv],
people,
series: srv.series ?? st.series,
events: st.events.filter((e) => (e.person ? ids.has(e.person) : true)),
geo: { ...st.geo, points: st.geo.points.filter((g) => ids.has(g.person)) },
totals: {
people: people.length,
devices: devices.length,
online: devices.filter((d) => d.online).length,
active: people.filter((p) => p.state === 'active').length,
today: today ? [today.rx, today.tx] : [0, 0],
month: sum((p) => p.month),
},
};
}
export class ServerOverview {
st!: Status;
el = E('div', { class: 'dl-srvov' });
@@ -319,42 +104,31 @@ export class ServerOverview {
return this.el;
}
update(st: Status) {
/** New status; a `quiet` (periodic) update leaves alone a part that has the keyboard focus. */
update(st: Status, quiet = false) {
this.st = scoped(st, this.srvId);
this.paint();
this.paint(quiet);
this.map?.update(this.mapData());
// Health checks cost more than a status call: once a minute is plenty.
if (Date.now() - this.healthAt > 60_000) void this.loadHealth();
}
/** A strip above the bento, only while Health has warnings or errors. */
/** Notices above the bento for the checks that failed (with their fix), only while Health has any. */
async loadHealth() {
this.healthAt = Date.now();
const r = await api.health().catch(() => null);
if (!r) return;
const bad = r.checks.filter((c) => c.status === 'warn' || c.status === 'error');
if (!bad.length) {
dom.content(this.parts.health, '');
return;
}
const errors = bad.filter((c) => c.status === 'error').length;
const label = `${bad.length} ${errors ? (bad.length === 1 ? 'problem' : 'problems') : bad.length === 1 ? 'warning' : 'warnings'}`;
dom.content(
const again = () => void this.loadHealth();
const run = async (fix: string) => {
if (!(await runFix(fix))) return;
again();
// The network restarts a second after the answer: look again once it is back.
if (fix === 'netrestart') setTimeout(again, 5000);
};
repaint(
this.parts.health,
E('div', { class: `dl-healthstrip ${errors ? 'bad' : 'warn'}` }, [
E('span', { class: 'dl-healthstrip-title' }, [icon('alert'), label]),
...bad.slice(0, 3).map((c) => {
const it = E('span', { class: 'dl-healthstrip-item' }, c.title);
attachTip(it, () => [E('div', { class: 'dl-tip-title' }, c.title), E('div', { class: 'dl-muted' }, c.detail)]);
return it;
}),
bad.length > 3 ? E('span', { class: 'dl-sub' }, `+${bad.length - 3} more`) : '',
E(
'a',
{ href: L.url('admin/network/dawnline/diagnostics') },
bad.some((c) => c.fix) ? 'Fix in Diagnostics →' : 'Open Diagnostics →',
),
]),
healthNotices(r.checks, (fix) => void run(fix), again),
true,
);
}
@@ -401,19 +175,19 @@ export class ServerOverview {
return E('div', { class: 'dl-panel flush' }, [head, wrap]);
}
paint() {
paint(quiet = false) {
const st = this.st;
const srv = st.servers[0];
const slots = st.people.reduce((a, p) => a + Math.max(0, p.device_limit - p.devices.length), 0);
const online = st.people.flatMap((p) => p.devices.filter((d) => d.online));
dom.content(
repaint(
this.parts.bento,
E('div', { class: 'dl-bento' }, [this.onlineTile(online), this.speedTile(), this.disguiseTile(srv), this.monthTile(slots)]),
E('div', { class: 'dl-bento' }, [this.onlineTile(), this.speedTile(), coreOf(srv).overviewTile(srv), this.monthTile(slots)]),
quiet,
);
const att = attention(st);
dom.content(
repaint(
this.parts.side,
E('div', { class: 'dl-panel flush' }, [
E('div', { class: 'dl-panel-head pad' }, [
@@ -424,13 +198,20 @@ export class ServerOverview {
att.length
? att
.slice(0, 8)
.map((a) => E('div', { class: 'dl-attn-item dl-row' }, [E('span', { class: `dl-ev-dot ${a.tone}` }), E('span', {}, a.text)]))
.map((a) =>
E('div', { class: 'dl-attn-item dl-row' }, [
E('span', { class: `dl-ev-dot ${a.tone}` }),
E('span', {}, a.text),
a.action ?? '',
]),
)
: E('div', { class: 'dl-row dl-muted' }, [icon('check'), 'All good. Nothing needs you right now.']),
]),
quiet,
);
const events = [...st.events].reverse().slice(0, 8);
dom.content(
repaint(
this.parts.activity,
E('div', { class: 'dl-panel flush' }, [
E('div', { class: 'dl-panel-head pad' }, [
@@ -442,6 +223,7 @@ export class ServerOverview {
? events.map((e) => eventRow(st, e))
: E('div', { class: 'dl-row dl-muted' }, 'Nothing yet. Connections, new devices and pauses appear here.'),
]),
quiet,
);
}
@@ -451,7 +233,7 @@ export class ServerOverview {
* then +N). The device badge is the main device, or a count. Hover: a live
* card with speed, devices and today's traffic. Nobody: when someone was last seen.
*/
onlineTile(_online: Device[]): HTMLElement {
onlineTile(): HTMLElement {
const st = this.st;
const CAP = 12;
const today = (d: Device) => d.spark[d.spark.length - 1] ?? 0;
@@ -596,49 +378,6 @@ export class ServerOverview {
return speedTile(this.st.servers[0]?.rate ?? [], this.st.now, this.st.totals.today);
}
disguiseTile(srv: Status['servers'][number]): HTMLElement {
const m = methodInfo(srv.preset);
const o = srv.obf ?? {};
const segs = (n: number, cls: string) =>
E(
'span',
{ class: `dl-segs ${cls}` },
[0, 1, 2, 3].map((i) => E('i', { class: i < n ? 'on' : '' })),
);
// The values devices carry, in words.
const chips: string[] = [];
if (+o.jc) chips.push(`${o.jc} junk · ${o.jmin}–${o.jmax} B`);
const pad = ['s1', 's2', 's3', 's4'].filter((k) => +o[k]).map((k) => `${k.toUpperCase()} ${o[k]}`);
if (pad.length) chips.push(pad.slice(0, 2).join(' · ') + (pad.length > 2 ? ` +${pad.length - 2}` : ''));
if (['h1', 'h2', 'h3', 'h4'].some((k) => o[k] && o[k] !== String(['h1', 'h2', 'h3', 'h4'].indexOf(k) + 1))) chips.push('H1–H4 random');
if (o.i1) chips.push(o.i1.includes('0x8580') ? 'DNS-like first packet' : 'Signature packets');
if (o.header_protection_key) chips.push('Encrypted headers');
if (!chips.length) chips.push(m?.id === 'off' ? 'Plain WireGuard' : 'No values yet');
return E('div', { class: 'dl-bento-tile dl-disg' }, [
E('div', { class: 'dl-bento-head' }, [
E('span', { class: 'dl-metric-label' }, 'Disguise'),
E('a', { href: `${L.url('admin/network/dawnline/server')}?server=${encodeURIComponent(srv.id)}&section=disguise` }, 'Change'),
]),
E('div', { class: 'dl-disg-id' }, [
E('span', { class: 'dl-disg-ic' }, icon(m?.ic ?? 'shield')),
E('span', { class: 'dl-stack' }, [E('b', {}, m ? m.title : 'Custom'), E('span', { class: 'dl-sub' }, m ? m.short : 'Set by hand')]),
]),
m
? E('div', { class: 'dl-disg-meters' }, [
E('span', {}, 'Stealth'),
segs(m.stealth, 'acc'),
E('span', {}, 'Speed'),
segs(m.speed, 'ok'),
])
: '',
E(
'div',
{ class: 'dl-disg-chips' },
chips.map((c) => E('span', {}, c)),
),
]);
}
/** The last 30 days, today on the right, with the peak; plus the people summary. */
monthTile(slots: number): HTMLElement {
const t = this.st.totals;
@@ -649,88 +388,3 @@ export class ServerOverview {
);
}
}
/** Throughput over the last 15 minutes plus today's total. */
export function speedTile(rate: [number, number, number][], now: number, today: [number, number]): HTMLElement {
const pts = rate.slice(-15);
const last = pts[pts.length - 1];
const fresh = last && now - last[0] < 180;
const down = fresh ? last[2] : 0,
up = fresh ? last[1] : 0;
const [rx, tx] = today;
const W = 200,
H = 40;
const max = Math.max(1, ...pts.map((p) => Math.max(p[1], p[2])));
const line = (k: 1 | 2) => pts.map((p, i) => `${pts.length > 1 ? (i / (pts.length - 1)) * W : W},${H - 2 - (p[k] / max) * (H - 6)}`);
const dl = line(2),
ul = line(1);
const chart =
pts.length > 1
? svg(
`<svg viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true">` +
`<path d="M${dl.join(' L')} L${W},${H} L0,${H}Z" class="area"/><path d="M${dl.join(' L')}" class="line"/>` +
`<path d="M${ul.join(' L')}" class="line up"/></svg>`,
)
: E('div', { class: 'dl-speed-wait' }, [E('i'), E('span', {}, 'Collecting… 1 point a minute')]);
const col = (label: string, ic: string, cls: string, v: number) =>
E('div', { class: 'dl-speed-col' }, [
E('span', { class: 'dl-sub' }, [E('span', { class: cls }, ic), ` ${label}`]),
E('span', { class: 'dl-speed-val' }, bits(v)),
]);
if (pts.length > 1)
attachTip(chart as HTMLElement, () => {
const p = pts[pts.length - 1];
return [
E('div', { class: 'dl-tip-title' }, new Date(p[0] * 1000).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit' })),
E('div', {}, `↓ ${bits(p[2])} · ↑ ${bits(p[1])}`),
];
});
return E('div', { class: 'dl-bento-tile' }, [
E('div', { class: 'dl-bento-head' }, [
E('span', { class: 'dl-metric-label' }, 'Speed now'),
E('span', { class: 'dl-sub' }, 'last 15 min'),
]),
E('div', { class: 'dl-speed-cols' }, [col('Download', '↓', 'dl-dn', down), col('Upload', '↑', 'dl-up', up)]),
chart,
E('div', { class: 'dl-speed-today' }, [
E('span', {}, ['Today ', E('b', {}, bytes(rx + tx))]),
E('span', {}, [E('span', { class: 'dl-dn' }, '↓'), ` ${bytes(tx)} `, E('span', { class: 'dl-up' }, '↑'), ` ${bytes(rx)}`]),
]),
]);
}
/** Daily traffic for the last 30 days, today on the right. */
export function daysTile(series: DayUsage[], note: string): HTMLElement {
const days = series.slice(-30);
const vals = days.map((d) => d.rx + d.tx);
const max = Math.max(1, ...vals);
const total = vals.reduce((a, v) => a + v, 0);
const peakI = vals.reduce((a, v, i) => (v > vals[a] ? i : a), 0);
const label = (day: string) => new Date(`${day}T12:00:00`).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' });
const bars = E(
'div',
{ class: 'dl-bento-bars' },
days.map((d, i) => {
const v = vals[i];
const bar = E('i', { class: i === days.length - 1 ? 'hi' : '', style: `height:${Math.max(4, (v / max) * 100)}%` });
attachTip(bar, () => [
E('div', { class: 'dl-tip-title' }, i === days.length - 1 ? `Today · ${label(d.day)}` : label(d.day)),
E('div', {}, bytes(v)),
E('div', { class: 'dl-muted dl-mono' }, `↓ ${bytes(d.tx)} ↑ ${bytes(d.rx)}`),
]);
return bar;
}),
);
return E('div', { class: 'dl-bento-tile month' }, [
E('div', { class: 'dl-bento-head' }, [
E('span', {}, [E('span', { class: 'dl-metric-label' }, 'Last 30 days'), E('b', { class: 'dl-bento-total' }, bytes(total))]),
vals[peakI] > 0 ? E('span', { class: 'dl-sub' }, `peak ${bytes(vals[peakI])} · ${label(days[peakI].day)}`) : '',
]),
days.length ? bars : E('p', { class: 'dl-muted' }, 'No traffic yet.'),
E('div', { class: 'dl-bento-head' }, [
E('span', { class: 'dl-sub' }, days.length ? label(days[0].day) : ''),
E('span', { class: 'dl-sub' }, note),
E('span', { class: 'dl-sub' }, 'today'),
]),
]);
}