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
- Russian translation. The admin pages, the LuCI menu and the router's messages (errors, Health checks, update steps, the service log) come in Russian with the new luci-i18n-dawnline-ru package, released beside the app. LuCI shows it when its language is Russian, or "auto" with a Russian browser - The translation installs with install.sh when LuCI is in Russian (or with --lang ru), follows every Dawnline update and rollback, and can be added or removed in Components → Dawnline → Translation - The portal speaks the visitor's language: it opens in the system's language and switches between English and Russian in place, from the language pill beside its QR code. It carries its own translation and needs no package - Set-up steps quote the apps' own menus word for word, in Russian too: AmneziaVPN is "+ → Insert → Continue" (it has no "Add server"), and the Mac and Windows menus of WireGuard and AmneziaWG have their real names - Questions in the portal (Reconnect, Remove) read from the left edge and close with Cancel, without × - Numbers, sizes and dates follow the page's language. A server that can't start says why in one sentence; event details and service log lines read as whole sentences - README in Russian (README_ru.md). rules/i18n.md: how strings are written and translated; CI checks the catalogs (npm run i18n:check)
118 lines
6.1 KiB
Ucode
118 lines
6.1 KiB
Ucode
// dawnline.awg: disguise presets against their own validation, the parser
|
|
// of `awg show all dump` on the output formats of AmneziaWG 1.0, 2.0 and 3.1
|
|
// (the stand-in awg in fixtures/bin prints the fixture put at AWG_DUMP), and Reconnect.
|
|
import { readfile, writefile, unlink } from 'fs';
|
|
import * as awg from 'dawnline.awg';
|
|
|
|
const AWG_DUMP = '/tmp/dawnline-tests/awg-dump';
|
|
let fixtures = sourcepath(0, true) + '/fixtures';
|
|
|
|
test('obf_preset off', () => {
|
|
let o = awg.obf_preset('off');
|
|
eq(o, { jc: '0', jmin: '0', jmax: '0', s1: '0', s2: '0', h1: '1', h2: '2', h3: '3', h4: '4' }, 'plain WireGuard headers');
|
|
eq(awg.obf_errors(o), [], 'valid');
|
|
});
|
|
|
|
test('obf_preset balanced', () => {
|
|
for (let i = 0; i < 25; i++) {
|
|
let o = awg.obf_preset('balanced');
|
|
eq(awg.obf_errors(o), [], 'balanced is valid');
|
|
ok(+o.jc >= 4 && +o.jc <= 8, `jc=${o.jc}`);
|
|
let jmin = +o.jmin, jmax = +o.jmax;
|
|
ok(jmin >= 64 && jmax > jmin && jmax <= 1024, `junk sizes ${o.jmin}-${o.jmax}`);
|
|
ok(+o.s1 + 56 != +o.s2, 's1 + 56 != s2');
|
|
eq(length(uniq([ o.h1, o.h2, o.h3, o.h4 ])), 4, 'distinct headers');
|
|
for (let k in [ 'h1', 'h2', 'h3', 'h4' ])
|
|
ok(+o[k] >= 5, `${k} above the reserved values`);
|
|
ok(+o.s3 >= 8 && +o.s3 <= 48 && +o.s4 >= 4 && +o.s4 <= 16, `padding ${o.s3}/${o.s4}`);
|
|
ok(substr(o.i1, 0, 3) == '<r ' && substr(o.i2, 0, 3) == '<r ', 'DNS-shaped signature packets');
|
|
eq(o.header_protection_key, null, 'no 3.1 values');
|
|
}
|
|
});
|
|
|
|
test('obf_preset max', () => {
|
|
let o = awg.obf_preset('max');
|
|
eq(o.header_protection_key, 'yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=', 'key from awg genkey');
|
|
ok(+o.jc >= 4 && +o.jc <= 6, 'jc');
|
|
ok(substr(o.i1, 0, 3) == '<r ', 'DNS-like first packet');
|
|
eq([ o.random_trailers, o.disable_cookies, o.content_padding_addition ], [ 'on', 'on', '10-100' ], '3.1 options');
|
|
ok(substr(o.i2, 0, 3) == '<r ', 'DNS-answer second packet');
|
|
// The template varies by name length and top-level domain (the letters
|
|
// themselves are random at run time): over many servers, more than one shape.
|
|
let shapes = {};
|
|
for (let i = 0; i < 20; i++)
|
|
shapes[awg.obf_preset('max').i1] = true;
|
|
ok(length(keys(shapes)) > 1, 'signature packets differ between servers');
|
|
// The preset passes the server's own validation (jmin/jmax may be small: 0.5.2).
|
|
eq(awg.obf_errors(o), [], 'max is valid');
|
|
});
|
|
|
|
test('obf_errors', () => {
|
|
eq(awg.obf_errors({}), [], 'nothing set');
|
|
eq(awg.obf_errors({ jc: '11' }), [ 'jc=11 (0-10)' ], 'jc range');
|
|
eq(awg.obf_errors({ jmin: '0', jmax: '0' }), [], 'zero junk sizes are allowed');
|
|
eq(awg.obf_errors({ jmin: '2000' }), [ 'jmin=2000 (0-1024)' ], 'jmin range');
|
|
eq(awg.obf_errors({ jmin: '200', jmax: '100' }), [ 'jmin > jmax' ], 'order');
|
|
eq(awg.obf_errors({ s1: '5', s2: '61' }), [ 's1 + 56 = s2' ], 'the handshake size clash');
|
|
eq(awg.obf_errors({ s4: '33' }), [ 's4=33 (0-32)' ], 's4 range');
|
|
eq(awg.obf_errors({ jc: 'x' }), [ 'jc=x (0-10)' ], 'not a number');
|
|
eq(awg.obf_errors({ h1: '7', h2: '7' }), [ 'h1-h4 must be distinct' ], 'duplicate headers');
|
|
eq(awg.obf_errors({ h1: '7-9', h2: 'abc' }), [ 'h2 must be a number or range' ], 'header ranges');
|
|
eq(awg.obf_neutral({ jc: '0', jmin: '0', jmax: '0', s1: '0', s2: '0', h1: '1', h2: '2', h3: '3', h4: '4' }), true, 'off is neutral');
|
|
eq(awg.obf_neutral({ jc: '4', jmin: '64', jmax: '128' }), false, 'junk is not neutral');
|
|
});
|
|
|
|
function dump_of(name) {
|
|
writefile(AWG_DUMP, readfile(`${fixtures}/awg-dump-${name}.txt`));
|
|
return awg.dump();
|
|
}
|
|
|
|
test('dump: AmneziaWG 1.0 (14 interface fields)', () => {
|
|
let d = dump_of('1.0');
|
|
eq(d.ok, true, 'ok');
|
|
eq(d.ifaces, { awgmain: { public_key: 'xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=', port: 51820 } }, 'interface');
|
|
eq(d.peers['HIgo9xNzJMWLKASShiTqIybxZ0U3wGLiUeJ1PKf8ykw='],
|
|
{ ifname: 'awgmain', endpoint: '203.0.113.7:41821', handshake: 1760000000, rx: 123456, tx: 654321 }, 'peer with a session');
|
|
eq(d.peers['TrMvSoP4jYQlY6RIzBgbssQqY3vxI2Pi+y71lOWWXX0='],
|
|
{ ifname: 'awgmain', endpoint: '', handshake: 0, rx: 0, tx: 0 }, 'peer that never connected');
|
|
});
|
|
|
|
test('dump: AmneziaWG 2.0 (33 interface fields)', () => {
|
|
let d = dump_of('2.0');
|
|
eq(d.ifaces, { awgmain: { public_key: 'xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=', port: 51820 } }, 'interface');
|
|
eq(keys(d.peers), [ 'HIgo9xNzJMWLKASShiTqIybxZ0U3wGLiUeJ1PKf8ykw=' ], 'one peer');
|
|
});
|
|
|
|
test('dump: AmneziaWG 3.1 (33 interface fields, protection on)', () => {
|
|
let d = dump_of('3.1');
|
|
eq(d.ifaces, { awgmain: { public_key: 'xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=', port: 51820 } }, 'interface');
|
|
eq(length(d.peers), 2, 'two peers');
|
|
});
|
|
|
|
test('dump: the tool fails', () => {
|
|
unlink(AWG_DUMP);
|
|
let d = awg.dump();
|
|
eq(d, { ok: false, ifaces: {}, peers: {} }, 'nothing known');
|
|
});
|
|
|
|
test('handshake_since: Reconnect hides older handshakes', () => {
|
|
eq(awg.handshake_since(1000, null), 1000, 'never set up again');
|
|
eq(awg.handshake_since(1000, 0), 1000, 'no time');
|
|
eq(awg.handshake_since(1000, 1500), 0, 'connected before: not set up yet');
|
|
eq(awg.handshake_since(1500, 1500), 0, 'the same second does not count');
|
|
eq(awg.handshake_since(1600, 1500), 1600, 'connected after');
|
|
eq(awg.handshake_since(0, 1500), 0, 'never connected');
|
|
});
|
|
|
|
test('blocked reasons', () => {
|
|
let srv = (b) => ({ name: 'Home', blocked: b });
|
|
eq(awg.blocked_text(srv(null)), null, 'not kept down');
|
|
eq(awg.blocked_text(srv({ code: 'ifname', ifname: 'bad name' })), 'Home has an invalid interface name "bad name".', 'interface name');
|
|
eq(awg.blocked_text(srv({ code: 'taken', ifname: 'wg0' })), "Home can't use the network interface wg0: it exists and isn't Dawnline's.", 'foreign interface');
|
|
eq(awg.blocked_text(srv({ code: 'disguise', need: '3.1', installed: '2.0' })), 'Home is kept down: its disguise needs AmneziaWG 3.1 (installed: 2.0).', 'disguise');
|
|
eq(awg.blocked_text(srv({ code: 'disguise', need: '3.1' })), 'Home is kept down: its disguise needs AmneziaWG 3.1 (installed: none).', 'disguise, none installed');
|
|
// Files of older versions hold the English fragment after the name.
|
|
eq(awg.blocked_text(srv('has an invalid interface name "x"')), 'Home has an invalid interface name "x".', 'old fragment');
|
|
eq(awg.blocked_note({ code: 'ifname', ifname: 'x' }), 'has an invalid interface name "x"', 'the log keeps the fragment');
|
|
});
|