Dawnline 0.20.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions

- **Backend rewritten in Go.** One daemon, `dawnlined`, replaces the whole ucode backend: the rpcd plugin, the agent, the CLI and the updater. The package no longer depends on ucode.
- **Per-architecture builds.** The release carries the backend for arm64, ARMv7, mips, mipsle and amd64; the router fetches its own after the package is installed and checks its sha256. Dawnline does not run on other architectures (older ARM, 32-bit x86, RISC-V).
- **Faster on the router.** A firewall sync takes 0.06 s instead of 0.9 s; a full apply takes about 300 ms. The portal is served by the daemon itself, without a CGI process per request.
- **Live pages.** The admin and the portal follow a live stream from the router instead of re-fetching the whole state every 30 seconds.
- **Admin redesigned in the portal's style.** Three sections (Overview · Log · Settings); a server is a page of its own with People, Places and Settings; a device opens as a dialog over its person.
- **Changes wait for «Apply».** Every setting, and a person's access, is staged in one dock before it reaches the router.
- **Configuration rollout.** After a change that makes devices fetch their configuration again, the admin shows how many have fetched it and who has not. Every setting shows beforehand (⟳N) how many devices it will touch.
- **Waiting for a decision.** Overview and People put first the people who need one (access ended, limit reached, a device that does not connect), each with its one action a tap away.
- **Bulk actions on people.** «Select» (or a long press on a card) picks several people to extend by a month, pause or resume at once.
- **Undo.** An action done from a card or a request is undone from its toast.
- **Update dialogs redesigned.** An update is one view from its question to its result; Dawnline's own update runs in it like every other, and the page reloads itself once the new version answers. Other versions are a list, each with its notes and Install on a page of its own.
- **Site to site: networks behind a router.** A router connected as a device can have networks behind it (up to eight, /16 to /30): the server routes them and applies the router's access to them. A network that shares addresses with a tunnel, the router's own networks or another site is refused by name.
- **Routers from the portal.** People can add a router and name its networks on their own page; the admin accepts or declines with a reason, or lets them through without asking.
- **Check access and Health know the networks behind routers.**
- **Usage limits reworked.** A monthly limit no longer follows the calendar. A person's month starts with their first traffic and ends a month later; the next one starts only when they connect again, so time away uses up none of it. Before, everyone's limit reset on the 1st.
- Extra data lasts until that person's month ends; «Reset usage» starts the month anew.
- A limit is for a month or for the whole term; the admin and the portal show when it resets.
- Charts that said «this month» show the last 30 days.
- After the update nobody loses what was counted: the month that was running becomes the person's first and ends on the 1st.
- **Access by time of day removed.** The Hours limit is gone from the admin, the portal and the backend; saved hours are dropped.
- **Expiry simplified.** An end date always stops access, with a heads-up three days before; the per-person choice is gone.
- **No false disconnects from sleeping phones.** A phone or a tablet stays online through ten minutes of silence.
- **Mobile Safari fixes.** Pressing a control no longer sends the page to its top; tab tracks that do not fit scroll; switches animate after a press.
This commit is contained in:
Aemeath committed 2026-11-13 09:43:50 +03:00
1 parent f8130e39a8
commit ac90575b0b
788 files changed
+139244 -41720

No files matched your search

+220
View File
@@ -0,0 +1,220 @@
import { describe, expect, it } from 'vitest';
import type { LogEvent } from '../src/shared/types';
import type { ServiceLogEntry } from '../src/admin/api';
import { sessions, type FeedItem } from '../src/admin/events/sessions';
import {
WHOLE,
choices,
inScope,
logQueryParams,
narrowed,
parseLogQuery,
withFilters,
type LogQuery,
type Who,
} from '../src/admin/events/scope';
// 2026-11-09 09:00 at the router (+3 h): 06:00 UTC.
const NOW = Date.UTC(2026, 10, 9, 6, 0) / 1000;
const TZ = 180;
const clock = { now: NOW, tz: TZ };
const HOUR = 3600;
const who = {
people: [
{
id: 'p_lena',
name: 'Lena',
server: 's_home',
devices: [
{ id: 'd_mac', name: 'MacBook' },
{ id: 'd_ipad', name: 'iPad' },
],
},
{ id: 'p_dima', name: 'Dima', server: 's_dacha', devices: [{ id: 'd_xi', name: 'Xiaomi 14' }] },
{ id: 'p_new', name: 'Katya', server: 's_home', devices: [{ id: 'd_none', name: 'Phone' }] },
],
servers: [
{ id: 's_home', name: 'Home' },
{ id: 's_dacha', name: 'Dacha' },
],
} as unknown as Who;
const ev = (ago: number, type: string, person?: string, device?: string, extra: Partial<LogEvent> = {}): LogEvent => ({
ts: NOW - ago,
type,
person,
device,
...extra,
});
const sys = (ago: number, extra: Partial<ServiceLogEntry> = {}): ServiceLogEntry => ({
ts: NOW - ago,
src: 'awg',
level: 'info',
msg: 'up',
...extra,
});
/** The feed: today 4 rows, yesterday 3, five days ago 1, ten days ago 1. */
const feed = (): FeedItem[] =>
sessions(
[
ev(1 * HOUR, 'paused', 'p_lena'),
ev(2 * HOUR, 'device_failing', 'p_dima', 'd_xi'),
ev(3 * HOUR, 'device_changed', 'p_lena', 'd_mac'),
// 23:00 the day before at the router
ev(10 * HOUR, 'device_changed', 'p_lena', 'd_ipad'),
ev(20 * HOUR, 'device_changed', 'p_dima', 'd_xi'),
ev(5 * 24 * HOUR, 'device_changed', 'p_lena', 'd_mac'),
ev(10 * 24 * HOUR, 'device_removed', 'p_gone', 'd_gone', { server: 's_dacha', pname: 'Gone' }),
],
[sys(4 * HOUR, { who: 'Home' }), sys(12 * HOUR, { sid: 's_dacha', who: 'Renamed since' }), sys(13 * HOUR, { who: 'Personal portal' })],
() => false,
);
const ask = (patch: Partial<LogQuery>): LogQuery => ({ ...WHOLE, ...patch });
const kept = (q: Partial<LogQuery>) => feed().filter(inScope(ask(q), who, clock));
describe('the log’s address', () => {
it('reads what it knows and leaves out the rest', () => {
expect(parseLogQuery('')).toEqual(WHOLE);
expect(parseLogQuery('kind=problems&day=yesterday&person=p_dima&device=d_xi&server=s_home&q=176.59')).toEqual({
kind: 'problems',
day: 'yesterday',
person: 'p_dima',
device: 'd_xi',
server: 's_home',
q: '176.59',
});
expect(parseLogQuery('kind=everything&day=tomorrow&sheet=x')).toEqual(WHOLE);
expect(parseLogQuery('q=%20two%20words%20').q).toBe('two words');
});
it('takes the 7 days by both of their names and writes one', () => {
expect(parseLogQuery('day=7d').day).toBe('7d');
expect(parseLogQuery('day=week').day).toBe('7d');
expect(logQueryParams(parseLogQuery('day=week')).day).toBe('7d');
});
it('writes only what narrows the log, and reads it back the same', () => {
expect(logQueryParams(WHOLE)).toEqual({});
const q = ask({ kind: 'system', day: 'today', person: 'p_lena', q: 'no route' });
const params = logQueryParams(q);
expect(params).toEqual({ kind: 'system', day: 'today', person: 'p_lena', q: 'no route' });
const query = new URLSearchParams(Object.entries(params).filter((e): e is [string, string] => !!e[1])).toString();
expect(parseLogQuery(query)).toEqual(q);
});
it('knows when something narrows it', () => {
expect(narrowed(WHOLE)).toBe(false);
for (const patch of [
{ kind: 'people' },
{ day: '7d' },
{ person: 'p' },
{ device: 'd' },
{ server: 's' },
{ q: 'x' },
] as Partial<LogQuery>[])
expect(narrowed(ask(patch))).toBe(true);
});
});
describe('changing the log’s filters', () => {
it('keeps a person with a device of theirs', () => {
expect(withFilters(ask({ person: 'p_lena' }), { device: 'd_mac' }, who.people)).toMatchObject({ person: 'p_lena', device: 'd_mac' });
expect(withFilters(ask({ device: 'd_mac' }), { person: 'p_lena' }, who.people)).toMatchObject({ person: 'p_lena', device: 'd_mac' });
});
it('drops the person when a device of someone else is picked, and the device when another person is', () => {
expect(withFilters(ask({ person: 'p_lena' }), { device: 'd_xi' }, who.people)).toMatchObject({ person: '', device: 'd_xi' });
expect(withFilters(ask({ device: 'd_mac' }), { person: 'p_dima' }, who.people)).toMatchObject({ person: 'p_dima', device: '' });
});
it('leaves the rest alone', () => {
const q = ask({ person: 'p_lena', device: 'd_mac', day: 'today', q: 'x' });
expect(withFilters(q, { day: '' }, who.people)).toEqual({ ...q, day: '' });
expect(withFilters(q, { person: '' }, who.people)).toEqual({ ...q, person: '' });
expect(withFilters(q, WHOLE, who.people)).toEqual(WHOLE);
});
});
describe('the log’s scope', () => {
it('keeps everything when nothing is asked, whatever the kind and the search', () => {
expect(kept({})).toHaveLength(10);
expect(kept({ kind: 'problems', q: 'nothing like it' })).toHaveLength(10);
});
it('keeps one person’s rows, or one device’s, without the service lines', () => {
expect(kept({ person: 'p_lena' }).map((x) => x.ev?.device)).toEqual([undefined, 'd_mac', 'd_ipad', 'd_mac']);
expect(kept({ device: 'd_xi' })).toHaveLength(2);
expect(kept({ person: 'p_lena', device: 'd_xi' })).toHaveLength(0);
expect(kept({ person: 'p_dima' }).some((x) => x.sys)).toBe(false);
});
it('reads a row’s server from its person, from the event itself for someone removed, from a service line’s id or name', () => {
const dacha = kept({ server: 's_dacha' });
expect(dacha.map((x) => x.ev?.person ?? x.sys?.who)).toEqual(['p_dima', 'Renamed since', 'p_dima', 'p_gone']);
const home = kept({ server: 's_home' });
expect(home.filter((x) => x.sys).map((x) => x.sys!.who)).toEqual(['Home']);
expect(home.filter((x) => x.ev).every((x) => x.ev!.person === 'p_lena')).toBe(true);
// the portal's line is no server's
expect([...dacha, ...home]).toHaveLength(9);
});
it('tells today from yesterday by the router’s day, and the 7 days by the clock', () => {
expect(kept({ day: 'today' })).toHaveLength(4);
// 10 h ago is 23:00 yesterday at the router (and still today in UTC)
expect(kept({ day: 'yesterday' }).map((x) => NOW - x.ts)).toEqual([10 * HOUR, 12 * HOUR, 13 * HOUR, 20 * HOUR]);
expect(kept({ day: '7d' })).toHaveLength(9);
expect(kept({ day: 'yesterday', person: 'p_lena' })).toHaveLength(1);
});
});
describe('what the log’s chips offer', () => {
it('lists the people with rows, the most first', () => {
expect(choices(feed(), WHOLE, who, clock).people).toEqual([
{ id: 'p_lena', n: 4 },
{ id: 'p_dima', n: 2 },
]);
});
it('counts under the other filters, not under its own', () => {
const c = choices(feed(), ask({ day: 'yesterday', person: 'p_dima', device: 'd_xi' }), who, clock);
// another person takes the device off: people are counted without it
expect(c.people).toEqual([
{ id: 'p_lena', n: 1 },
{ id: 'p_dima', n: 1 },
]);
expect(c.devices).toEqual([{ id: 'd_xi', n: 1 }]);
expect(c.servers).toEqual([
{ id: 's_home', n: 0 },
{ id: 's_dacha', n: 1 },
]);
});
it('offers the picked person’s devices only, and everyone’s with nobody picked', () => {
expect(choices(feed(), ask({ person: 'p_lena' }), who, clock).devices).toEqual([
{ id: 'd_mac', n: 2 },
{ id: 'd_ipad', n: 1 },
]);
expect(choices(feed(), WHOLE, who, clock).devices.map((d) => d.id)).toEqual(['d_mac', 'd_xi', 'd_ipad']);
});
it('keeps the picked one in its list with no rows, and when the router no longer has it', () => {
expect(choices(feed(), ask({ day: 'today', person: 'p_new' }), who, clock).people.map((p) => p.id)).toEqual([
'p_lena',
'p_dima',
'p_new',
]);
const gone = choices(feed(), ask({ person: 'p_gone', device: 'd_gone' }), who, clock);
expect(gone.people).toContainEqual({ id: 'p_gone', n: 1 });
expect(gone.devices).toEqual([{ id: 'd_gone', n: 1 }]);
});
it('lists every server in the router’s order', () => {
expect(choices(feed(), WHOLE, who, clock).servers).toEqual([
{ id: 's_home', n: 5 },
{ id: 's_dacha', n: 4 },
]);
});
});