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 / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- A device is renamed where its name stands on its card: a click on the
name, Return or Space on it, or Rename in the ⋯ menu turns it into a
field with the name selected. Return saves, and the words shimmer until
the router answers. Esc or a click elsewhere puts the old name back. The
rename window is gone, and the page no longer redraws under a name being
edited
- Device names take up to 20 characters: letters of any language, digits,
spaces and - _ . The router refuses anything else when a device is added
or renamed, so a name can't carry symbols into configurations, file
names or the AmneziaVPN key. The portal and the admin turn a character
like that away as it is typed: the field shakes, its outline goes red
and a short line says why. Suggested names (a phone's model, "Phone 2")
are stripped of such characters and cut to fit. Names set before this
stay as they are
- LAN Bypass: Add a device, in the portal and in the admin, has a switch
that keeps the device's own local network (printer, TV, NAS) reachable
while it is connected. It is off by default and stays as chosen; the
admin's device drawer shows it. With home and internet access the switch
says which addresses still lead to the home network
- Health warns when a server's home network is on one of the subnets home
routers come with (192.168.0.x, 192.168.1.x and others). People with
home access who connect from a network on the same addresses reach your
home instead of their own, LAN Bypass or not
- The router tells when a device can't connect properly. After the problem
lasts three minutes, the portal card and the admin drawer name it:
can't finish connecting (the network may block it), connected but no
data (an outdated configuration, and the card offers Reconnect), on two
devices at once, or a connection that keeps dropping. Activity lists
these under Problems, one line per device per hour, and says when the
device connects normally again
- The set-up sheet's connection line follows what the device does:
waiting, can't finish, connected, or connected but no data. The sheet
closes by itself only once data comes through. On the device itself and
for a router, the steps regroup to what fixes the problem: "Set it up
again" when the handshake never finishes, "Add the connection again"
("Import the configuration again" for a router) when no data comes
- Set-up in the portal: a QR code too long for a camera to read gives its
place to a code that opens the set-up link (a LAN Bypass configuration
or a long AmneziaVPN key can be that long). A TV, box or NAS added from
a phone gets the steps for setting up from another device. Back from
"Open on the device" keeps the kind, LAN Bypass and the name typed. The
packet-size note under the kinds is gone
- The portal on phones keeps its place: nothing jumps when an access row
opens or folds, a notice comes or goes, or Safari redraws the cards. A
reload, or coming back from the VPN app, opens where the page was. Cards
glide to their new height, and an animation interrupted half-way goes on
from where it is instead of snapping. A double click no longer closes
the sheet it just opened
- In the admin, a device's drawer has its own MTU and keep-alive (empty
means the server's), each with a Change dialog. A change touches only
that device's configuration and restarts nothing on the router. Opening
the drawer no longer counts as handing out the configuration: "Update
config" stays until the new configuration is shown as a QR code,
downloaded or copied ("Show the new configuration"). New keys set the
device up again, as the portal's Reconnect does
- "Speed now" on a server's Overview is live: one point a second over the
last two minutes, all there as soon as the Overview opens. The agent
keeps those two minutes in memory and writes them out only while someone
is looking
- Disguise values that AmneziaWG refuses or crashes on are stopped before
they reach the kernel. That covers overlapping H1-H4, Jmin above Jmax,
broken I1-I5 tags, padding under 12 with header protection, and more.
Import and restore refuse them. After a hand edit in uci, the server's
tunnel stays down and Health and the service log say why and what to do.
Errors are full sentences in the reader's language
- The header protection key no longer shows in the status that read-only
users can see: the Server page says only that the key is set, and each
device's configuration still has it. The server no longer turns off
WireGuard's protection against handshake floods (devices keep
DisableCookies). A device can't be added with a server's own key
- An AmneziaWG update whose kernel module can't be swapped (another
AmneziaWG interface holds the old one) no longer fails. It is installed,
the tunnels come back on the old module, and Health and Components say
the update starts after a reboot. On apk firmware, an install that apk
left at the old version counts as failed. A module installed by hand is
recorded, so after a firmware upgrade Health can tell that it is gone
- Dawnline reads only its own tunnels, each one separately. Another
AmneziaWG interface on the router no longer slows the agent's
once-a-second check, has its keys read or breaks Dawnline's reads. A
portal request reads only that person's server: one process however many
servers there are
- Fewer false disconnects: a tunnel that netifd sets up again no longer
logs everyone as leaving and coming back, and a device with a long
keep-alive stays online between handshakes. One configuration on two
devices isn't logged as roaming every few seconds, and new keys end the
old session at once. A tunnel that is missing devices is synced within a
minute, and traffic across a tunnel restart is no longer undercounted
- Renaming a server no longer restarts its tunnel. If a tunnel's interface
is edited outside Dawnline (LuCI, uci), the watchdog sets it up again
with Dawnline's settings and names only the changed options. The routing
rules for "Internet like a home device" change one at a time, new ones
first, so traffic never falls between them. Health and the Server page
warn when the address's AAAA record isn't this router's, or the router
has no public IPv6: devices that prefer IPv6 fail to connect
- The README screenshots come in English and Russian; the portal's are
taken from its demo. The demo has a switch beside × in the set-up sheet
to show each state of the connection line. In Russian, long labels in
the admin's wide option buttons wrap under their icon. DESIGN.md
describes the switch, renaming on the card, the shimmer, the shake and
how the portal scrolls. New tests cover link states, the meter, access,
Health, firewall rules, network settings and packages
295 lines
13 KiB
JavaScript
Executable File
295 lines
13 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// Capture the raw README screenshots of the admin pages from a live router into
|
|
// docs/screenshots/raw/<name>.png (2x PNG); scripts/frame-screenshots.py then
|
|
// frames them for the README. The portal's come from its demo instead
|
|
// (scripts/capture-portal.mjs): no one's real page, and adding a device there adds none.
|
|
//
|
|
// Drives a headless Chromium (BROWSER=/path/to/chrome, default: Brave or Chrome
|
|
// on macOS) over the DevTools protocol (scripts/cdp.mjs). Signs in to LuCI with
|
|
// the password from LUCI_PASSWORD or asked on the terminal; the session lives
|
|
// only in a throwaway profile (LUCI_USER picks another user than root). Nothing on the router is changed.
|
|
//
|
|
// scripts/capture-screenshots.mjs [--router https://router.lan] [--person id]
|
|
// [--mask real=shown ...] [--name real=shown ...]
|
|
// [--only overview,people] [--demo] [--lang ru]
|
|
//
|
|
// --lang asks LuCI for the pages in that language (its catalog, po/<lang>/dawnline.po;
|
|
// the router's LuCI language left on auto) and names the captures <name>-<lang>.png
|
|
// for that README (README_ru.md); English (the default) keeps <name>.png.
|
|
// --mask replaces text on every page before the capture (a domain, a name);
|
|
// --name does the same for a person's name in any case, and for their initials.
|
|
// Public IPv4 addresses are always swapped for documentation ones (203.0.113.x).
|
|
// --demo shows a made-up cast instead of the router's people (scripts/screenshot-demo.mjs):
|
|
// the router's answers are rewritten in the headless browser on their way to the page.
|
|
|
|
import { execFileSync } from 'node:child_process';
|
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
import { dirname, join, resolve } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { createInterface } from 'node:readline';
|
|
import { die, launch, sleep } from './cdp.mjs';
|
|
import { demoRpc } from './screenshot-demo.mjs';
|
|
|
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const RAW = join(ROOT, 'docs', 'screenshots', 'raw');
|
|
const SCALE = 2;
|
|
|
|
const args = {
|
|
router: 'https://outline.lan',
|
|
person: '',
|
|
mask: [],
|
|
names: [],
|
|
only: [],
|
|
demo: false,
|
|
lang: 'en',
|
|
};
|
|
for (let i = 2; i < process.argv.length; i++) {
|
|
const a = process.argv[i];
|
|
const v = () => process.argv[++i] ?? die(`${a} needs a value`);
|
|
if (a === '--router') args.router = v().replace(/\/+$/, '');
|
|
else if (a === '--person') args.person = v();
|
|
else if (a === '--mask') args.mask.push(v().split('=', 2));
|
|
else if (a === '--name') args.names.push(v().split('=', 2));
|
|
else if (a === '--only') args.only = v().split(',');
|
|
else if (a === '--demo') args.demo = true;
|
|
else if (a === '--lang') args.lang = v();
|
|
else die(`unknown argument ${a}`);
|
|
}
|
|
const SUFFIX = args.lang === 'en' ? '' : `-${args.lang}`;
|
|
|
|
/** The admin's catalog for --lang: msgid -> msgstr, the entries without a context (English: none). */
|
|
const CATALOG = (() => {
|
|
const out = new Map();
|
|
if (args.lang === 'en') return out;
|
|
let po;
|
|
try {
|
|
po = readFileSync(join(ROOT, 'package', 'luci-app-dawnline', 'po', args.lang, 'dawnline.po'), 'utf8');
|
|
} catch {
|
|
die(`no admin catalog for --lang ${args.lang}`);
|
|
}
|
|
for (const m of po.matchAll(/^(msgctxt .*\n)?msgid "(.*)"\nmsgstr "(.*)"$/gm)) if (!m[1] && m[3]) out.set(m[2], m[3]);
|
|
return out;
|
|
})();
|
|
/** A button's words as the page shows them in --lang (the pages are clicked by what they say). */
|
|
const tr = (id) => CATALOG.get(id) ?? id;
|
|
if ([...args.mask, ...args.names].some((m) => m.length !== 2 || !m[0])) die('--mask and --name take real=shown');
|
|
|
|
/** As shared/format initials(): first letters of the first and last word, or the first two of one word. */
|
|
const initials = (name) => {
|
|
const p = name.trim().split(/\s+/);
|
|
return (p[0][0] + (p.length > 1 ? p[p.length - 1][0] : (p[0][1] ?? ''))).toUpperCase();
|
|
};
|
|
for (const [real, shown] of args.names)
|
|
args.mask.push([real, shown], [real.toLowerCase(), shown.toLowerCase()], [real.toUpperCase(), shown.toUpperCase()]);
|
|
const INITIALS = args.names.map(([real, shown]) => [initials(real), initials(shown)]);
|
|
|
|
const LUCI = `${args.router}/cgi-bin/luci/admin/network/dawnline`;
|
|
const USER = process.env.LUCI_USER || 'root';
|
|
|
|
/*
|
|
* Each shot: the page, what must be on it before the capture, what to do
|
|
* first (in the page), and the area to keep (in the page, CSS pixels).
|
|
* Admin pages keep the theme's header and the content column, 48px either side.
|
|
*/
|
|
const column = `(() => {
|
|
const r = document.querySelector('.dl-root').getBoundingClientRect();
|
|
return { x: r.left - 48, w: r.width + 96 };
|
|
})()`;
|
|
// From the top down to an element; whatever follows it is hidden, not cut through.
|
|
const below = (sel) => `(() => {
|
|
const c = ${column}, el = document.querySelector(${JSON.stringify(sel)});
|
|
for (let e = el; e && !e.classList.contains('dl-root'); e = e.parentElement)
|
|
for (let n = e.nextElementSibling; n; n = n.nextElementSibling) n.style.visibility = 'hidden';
|
|
return { x: c.x, y: 0, width: c.w, height: el.getBoundingClientRect().bottom + 40 };
|
|
})()`;
|
|
|
|
const SHOTS = [
|
|
{
|
|
name: 'overview',
|
|
url: () => `${LUCI}/server`,
|
|
width: 1400,
|
|
ready: '.dl-srvov .dl-panel.flush .maplibregl-canvas',
|
|
// The map shows the last 30 days, not only who is online now.
|
|
prep: `(() => {
|
|
const b = [...document.querySelectorAll('.dl-srvov .dl-panel.flush button')].find((x) => x.textContent.trim() === ${JSON.stringify(tr('30 days'))});
|
|
b?.click();
|
|
})()`,
|
|
settle: 6000,
|
|
clip: below('.dl-srvov .dl-panel.flush'),
|
|
},
|
|
{
|
|
name: 'people',
|
|
url: () => `${LUCI}/server?section=people`,
|
|
width: 1400,
|
|
ready: '.dl-srvbody a[href*="dawnline/person"]',
|
|
clip: below('.dl-srvbody'),
|
|
},
|
|
{
|
|
name: 'person',
|
|
url: (s) => `${LUCI}/person?id=${encodeURIComponent(s.person)}`,
|
|
width: 1400,
|
|
ready: '.dl-grid-person .dl-row',
|
|
// Where they connected from, on the map.
|
|
prep: `(() => {
|
|
const b = [...document.querySelectorAll('.dl-grid-person button')].find((x) => x.textContent.trim() === ${JSON.stringify(tr('Show map'))});
|
|
b?.click();
|
|
})()`,
|
|
settle: 6000,
|
|
// Down to the end of Access & limits or of the map, whichever is lower; activity rows that would be cut are hidden.
|
|
clip: `(() => {
|
|
const c = ${column}, cols = document.querySelectorAll('.dl-grid-person > .dl-col');
|
|
const places = cols[0].children[2];
|
|
const cut = Math.max(cols[1].getBoundingClientRect().bottom, places ? places.getBoundingClientRect().bottom : 0) + 40;
|
|
document.querySelectorAll('.dl-grid-person .dl-row').forEach((r) => {
|
|
if (r.getBoundingClientRect().bottom > cut - 8) r.style.visibility = 'hidden';
|
|
});
|
|
// Activity that would start right at the cut goes too, its heading with it.
|
|
const act = cols[0].children[3];
|
|
if (act && act.getBoundingClientRect().top > cut - 120) act.style.visibility = 'hidden';
|
|
return { x: c.x, y: 0, width: c.w, height: cut };
|
|
})()`,
|
|
},
|
|
];
|
|
|
|
const MASK = `((pairs, inits) => {
|
|
const doc = new Map();
|
|
const isPrivate = (a) => a[0] === 10 || a[0] === 127 || (a[0] === 172 && a[1] >= 16 && a[1] < 32) ||
|
|
(a[0] === 192 && a[1] === 168) || (a[0] === 100 && a[1] >= 64 && a[1] < 128) || a[0] === 0 || a[0] >= 224;
|
|
const ip = (m) => {
|
|
const a = m.split('.').map(Number);
|
|
if (a.some((x) => x > 255) || isPrivate(a)) return m;
|
|
if (!doc.has(m)) doc.set(m, '203.0.113.' + (24 + doc.size));
|
|
return doc.get(m);
|
|
};
|
|
// IPv6 too, unless link-local or private (fe80::, fc00::/7).
|
|
const ip6 = (m) => {
|
|
if (/^(fe8|fe9|fea|feb|fc|fd)/i.test(m)) return m;
|
|
if (!doc.has(m)) doc.set(m, '2001:db8::' + (24 + doc.size));
|
|
return doc.get(m);
|
|
};
|
|
const swap = (s) =>
|
|
pairs
|
|
.reduce((t, [a, b]) => t.split(a).join(b), s)
|
|
.replace(/\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/g, ip)
|
|
.replace(/\\b(?:[0-9a-f]{1,4}:){3,7}[0-9a-f]{1,4}\\b/gi, ip6);
|
|
const w = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
|
for (let n; (n = w.nextNode()); ) {
|
|
const ini = inits.find(([a]) => n.nodeValue.trim() === a);
|
|
const v = ini ? n.nodeValue.replace(ini[0], ini[1]) : swap(n.nodeValue);
|
|
if (v !== n.nodeValue) n.nodeValue = v;
|
|
}
|
|
document.querySelectorAll('input').forEach((i) => { const v = swap(i.value); if (v !== i.value) i.value = v; });
|
|
})(${JSON.stringify(args.mask)}, ${JSON.stringify(INITIALS)})`;
|
|
|
|
async function password() {
|
|
if (process.env.LUCI_PASSWORD) return process.env.LUCI_PASSWORD;
|
|
if (!process.stdin.isTTY) die('Set LUCI_PASSWORD or run on a terminal');
|
|
process.stdout.write(`LuCI password for ${USER}: `);
|
|
execFileSync('stty', ['-echo'], { stdio: 'inherit' });
|
|
try {
|
|
const rl = createInterface({ input: process.stdin });
|
|
const line = await new Promise((ok) => rl.once('line', ok));
|
|
rl.close();
|
|
return line.replace(/\r$/, '');
|
|
} finally {
|
|
execFileSync('stty', ['echo'], { stdio: 'inherit' });
|
|
process.stdout.write('\n');
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
const pass = await password();
|
|
// The router's certificate is usually for its public name, not router.lan.
|
|
const b = await launch(['--ignore-certificate-errors', `--lang=${args.lang}`]);
|
|
const { page, evaluate, go, waitSel } = b;
|
|
try {
|
|
// LuCI on auto speaks the browser's language: this one, whatever this computer's is.
|
|
await page.send('Network.enable');
|
|
await page.send('Network.setExtraHTTPHeaders', { headers: { 'Accept-Language': args.lang } });
|
|
await page.send('Emulation.setEmulatedMedia', {
|
|
features: [{ name: 'prefers-color-scheme', value: 'dark' }],
|
|
});
|
|
// The person shown on the Person page; known once People has loaded (or from --person).
|
|
const s = { person: args.person };
|
|
if (args.demo) {
|
|
page.on('Fetch.requestPaused', async (e) => {
|
|
try {
|
|
const r = await page.send('Fetch.getResponseBody', {
|
|
requestId: e.requestId,
|
|
});
|
|
const body = r.base64Encoded ? Buffer.from(r.body, 'base64').toString('utf8') : r.body;
|
|
const out = demoRpc(e.request.postData ?? '', body, s.person);
|
|
await page.send('Fetch.fulfillRequest', {
|
|
requestId: e.requestId,
|
|
responseCode: e.responseStatusCode ?? 200,
|
|
responseHeaders: e.responseHeaders ?? [],
|
|
body: Buffer.from(out, 'utf8').toString('base64'),
|
|
});
|
|
} catch {
|
|
await page.send('Fetch.continueRequest', { requestId: e.requestId }).catch(() => {});
|
|
}
|
|
});
|
|
await page.send('Fetch.enable', {
|
|
patterns: [{ urlPattern: '*ubus*', requestStage: 'Response' }],
|
|
});
|
|
}
|
|
|
|
// A tall window: Outline scrolls #maincontent, not the page, so it must hold everything.
|
|
const viewport = (width, height = 2600) =>
|
|
page.send('Emulation.setDeviceMetricsOverride', {
|
|
width,
|
|
height,
|
|
deviceScaleFactor: SCALE,
|
|
mobile: false,
|
|
});
|
|
|
|
await viewport(1400);
|
|
await go(`${args.router}/cgi-bin/luci/`);
|
|
if (await evaluate(`!!document.querySelector('input[name=luci_password]')`)) {
|
|
await evaluate(`(() => {
|
|
document.querySelector('input[name=luci_username]').value = ${JSON.stringify(USER)};
|
|
document.querySelector('input[name=luci_password]').value = ${JSON.stringify(pass)};
|
|
})()`);
|
|
const loaded = page.waitFor('Page.loadEventFired');
|
|
await evaluate(`document.querySelector('form.login-form, form').submit()`);
|
|
await loaded;
|
|
if (await evaluate(`!!document.querySelector('input[name=luci_password]')`))
|
|
die(
|
|
(await evaluate(`!!document.querySelector('.login-error')`))
|
|
? `LuCI login failed: wrong password for ${USER} (LUCI_USER sets the user)`
|
|
: `LuCI login failed: still on the login page (${await evaluate('location.href')})`,
|
|
);
|
|
}
|
|
|
|
// The person to show: the first one on People unless --person.
|
|
await go(`${LUCI}/server?section=people`);
|
|
await waitSel('.dl-srvbody a[href*="dawnline/person"]');
|
|
if (!s.person)
|
|
s.person = await evaluate(`new URL(document.querySelector('.dl-srvbody a[href*="dawnline/person"]').href).searchParams.get('id')`);
|
|
|
|
for (const shot of SHOTS) {
|
|
if (args.only.length && !args.only.includes(shot.name)) continue;
|
|
await viewport(shot.width);
|
|
await go(shot.url(s));
|
|
await waitSel(shot.ready);
|
|
await sleep(2000);
|
|
if (shot.prep) await evaluate(shot.prep);
|
|
await sleep(shot.settle ?? 1500);
|
|
await evaluate(MASK);
|
|
const clip = await evaluate(shot.clip);
|
|
const { data } = await page.send('Page.captureScreenshot', {
|
|
format: 'png',
|
|
clip: { ...clip, scale: 1 },
|
|
captureBeyondViewport: true,
|
|
});
|
|
writeFileSync(join(RAW, `${shot.name}${SUFFIX}.png`), Buffer.from(data, 'base64'));
|
|
console.log(`${shot.name}${SUFFIX}: ${Math.round(clip.width)}x${Math.round(clip.height)} (x${SCALE})`);
|
|
}
|
|
page.close();
|
|
} finally {
|
|
await b.close();
|
|
}
|
|
}
|
|
|
|
main().catch((e) => die(e.message));
|