Files
Aemeath ac90575b0b
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
Dawnline 0.20.0
- **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.
2026-11-13 09:43:50 +03:00

160 lines
7.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest';
import {
asksNow,
asksOf,
askCount,
behindRefetch,
netsOf,
reachers,
routerAsks,
routerDeclined,
routersOf,
takenFor,
wishOf,
} from '../src/admin/servers/behind';
import { netRefusal, normNet, tooMany } from '../src/shared/nets';
import { deviceChangedText } from '../src/admin/events/model';
import type { Device, Person } from '../src/shared/types';
const dev = (o: Partial<Device> = {}): Device =>
({
id: 'd1',
name: 'Phone',
kind: 'phone',
disabled: false,
handshake: 100,
config_stale: false,
config_issued: 100,
lan_bypass: false,
...o,
}) as Device;
const person = (o: Partial<Person> = {}): Person =>
({ id: 'p1', name: 'Lena', server: 's1', access: 'both', state: 'active', services: [], home_nets: [], devices: [], ...o }) as Person;
describe('what a router has and asks for', () => {
const has = dev({ id: 'r1', kind: 'router', behind: ['192.168.2.0/24'], ask: ['192.168.3.0/24', '192.168.2.0/24'] });
const waits = dev({ id: 'r2', kind: 'router', waiting: true, ask: ['192.168.4.0/24'] });
const turned = dev({ id: 'r3', kind: 'router', waiting: true, declined: 'talk', ask: ['192.168.5.0/24'] });
const phone = dev({ behind: ['192.168.9.0/24'], ask: ['192.168.8.0/24'], waiting: true });
it('only a router has networks or asks', () => {
expect(netsOf(has)).toEqual(['192.168.2.0/24']);
expect(netsOf(phone)).toEqual([]);
expect(asksNow(phone)).toBe(false);
});
it('a network asked for is one it does not have', () => {
expect(asksOf(has)).toEqual(['192.168.3.0/24']);
expect(asksNow(has)).toBe(true);
expect(asksNow(dev({ kind: 'router', behind: ['192.168.2.0/24'] }))).toBe(false);
});
it('a router asked for is the whole question, its networks with it', () => {
expect(routerAsks(waits)).toBe(true);
expect(asksOf(waits)).toEqual([]);
expect(wishOf(waits)).toEqual(['192.168.4.0/24']);
expect(asksNow(waits)).toBe(true);
});
it('one turned down asks for nothing and is no router of the server', () => {
expect(routerAsks(turned)).toBe(false);
expect(routerDeclined(turned)).toBe(true);
expect(asksNow(turned)).toBe(false);
const people = [
person({ devices: [has, waits, turned, phone] }),
person({ id: 'p2', server: 's2', devices: [dev({ id: 'r9', kind: 'router', waiting: true })] }),
];
expect(routersOf(people, 's1').map((x) => x.d.id)).toEqual(['r1', 'r2']);
expect(askCount(people, 's1')).toBe(2);
expect(askCount(people, 's2')).toBe(1);
});
});
describe('a network typed', () => {
const taken = [{ cidr: '10.77.0.0/24', who: 'the tunnel network of Home' }];
it('is kept from its first address', () => {
expect(normNet(' 192.168.2.7/24 ')).toBe('192.168.2.0/24');
expect(normNet('10.5.200.1/16')).toBe('10.5.0.0/16');
});
it('is a private network of a site’s size', () => {
expect(netRefusal('192.168.2.0/24', taken)).toBeNull();
expect(netRefusal('10.5.0.0/16', taken)).toBeNull();
expect(netRefusal('192.168.2.0', taken)).toContain('is not a network like');
expect(netRefusal('8.8.8.0/24', taken)).toContain('not a private network');
expect(netRefusal('172.32.0.0/24', taken)).toContain('not a private network');
expect(netRefusal('10.0.0.0/8', taken)).toContain('too wide');
expect(netRefusal('10.4.0.0/15', taken)).toContain('too wide');
});
it('shares no address with what something has', () => {
expect(netRefusal('10.77.0.128/25', taken)).toBe(
'10.77.0.0/24 is taken: it is the tunnel network of Home. The two ends need different ranges.',
);
expect(netRefusal('10.77.0.0/16', taken)).toContain('10.77.0.0/24 is taken');
});
it('is one of eight at the most', () => {
expect(tooMany(8)).toBeNull();
expect(tooMany(9)).toContain('8 networks behind one router');
});
it('is held against tunnels, the router’s own and other devices’ networks, a staged list included', () => {
const r1 = dev({ id: 'r1', kind: 'router', behind: ['192.168.2.0/24'] });
const r2 = dev({ id: 'r2', name: 'Dacha', kind: 'router', behind: ['192.168.3.0/24'] });
const people = [person({ devices: [r1, r2] })];
const t = takenFor([{ name: 'Home', subnet: '10.77.0.0/24' }], [{ name: 'br-lan', nets: ['192.168.1.0/24'] }], people, r1, (o) =>
o.id === 'r2' ? ['192.168.30.0/24'] : (o.behind ?? []),
);
expect(t.map((x) => x.cidr)).toEqual(['10.77.0.0/24', '192.168.1.0/24', '192.168.30.0/24']);
expect(t[2].who).toBe('the network behind Dacha');
});
});
describe('who fetches again when a router’s networks change', () => {
const router = dev({ id: 'r1', kind: 'router' });
const owner = person({ id: 'boris', circle: 'fam', devices: [router, dev({ id: 'b2', lan_bypass: true })] });
const people = [
owner,
// sends everything into the tunnel: no word of any network in its configuration
person({
id: 'anna',
circle: 'fam',
devices: [dev({ id: 'a1' }), dev({ id: 'a2', lan_bypass: true }), dev({ id: 'a3', lan_bypass: true, disabled: true })],
}),
person({ id: 'dima', access: 'lan', circle: 'work', devices: [dev({ id: 'd1' }), dev({ id: 'd2', config_issued: 0, handshake: 0 })] }),
person({ id: 'eva', access: 'lan', services: ['nas'], devices: [dev({ id: 'e1' })] }),
person({ id: 'clara', access: 'internet', devices: [dev({ id: 'c1', lan_bypass: true })] }),
person({ id: 'far', server: 's2', devices: [dev({ id: 'f1', lan_bypass: true })] }),
];
const ids = (mesh: 'off' | 'all' | 'circles') => reachers(people, { id: 's1', mesh }, owner, router).map((x) => x.d.id);
it('everyone who is part of home, where everyone reaches everyone; never the router itself', () => {
expect(ids('all')).toEqual(['b2', 'a2', 'd1', 'd2']);
});
it('the circle, where devices are kept within circles', () => {
expect(ids('circles')).toEqual(['b2', 'a2']);
});
it('nobody while devices are kept apart, or when its owner is no part of home', () => {
expect(ids('off')).toEqual([]);
expect(reachers(people, { id: 's1', mesh: 'all' }, people[4], dev({ id: 'c1' }))).toEqual([]);
});
it('counts those that hold a configuration, each once', () => {
expect(behindRefetch(people, { id: 's1', mesh: 'all' }, [{ p: owner, d: router }])).toBe(3);
expect(
behindRefetch(people, { id: 's1', mesh: 'all' }, [
{ p: owner, d: router },
{ p: people[1], d: dev({ id: 'a1' }) },
]),
).toBe(3);
expect(behindRefetch(people, { id: 's1', mesh: 'off' }, [{ p: owner, d: router }])).toBe(0);
});
});
describe('what the log says of a router’s networks and requests', () => {
it('words each change the router writes', () => {
expect(deviceChangedText('networks=192.168.2.0/24 172.20.0.0/16')).toBe('networks behind it: 192.168.2.0/24, 172.20.0.0/16');
expect(deviceChangedText('networks=none')).toBe('no networks behind it');
expect(deviceChangedText('asked=router, asked=192.168.88.0/24')).toBe('the router is asked for, asked for: 192.168.88.0/24');
expect(deviceChangedText('withdrew=192.168.3.128/25')).toBe('no longer asked for: 192.168.3.128/25');
expect(deviceChangedText('accepted=router, accepted=192.168.88.0/24')).toBe('the router accepted, accepted: 192.168.88.0/24');
expect(deviceChangedText('declined=192.168.89.0/24, reason=overlap')).toBe(
'declined: 192.168.89.0/24, reason: It shares addresses with a network here',
);
expect(deviceChangedText('declined=router, reason=plain')).toBe('the router declined, no reason given');
expect(deviceChangedText('reopened=router')).toBe('the router is asked for again');
expect(deviceChangedText('kind=phone, networks=none')).toBe('type: Phone, no networks behind it');
});
});