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
- "Internet like a home device" starts off on new servers: sending the tunnel through the home network costs speed. Both server wizards (the first one and "Add server") have the switch, and on it says what it costs. Servers that have it on keep it - With it off, Server → Access says what that means: DNS still goes through the router, its proxies and filters see the tunnel only once its interface is added to their source interfaces, and sites the router's DNS answers with proxy addresses won't open - With it on, established connections skip the second pass through netfilter in Dawnline's network namespace (a software flowtable): about 12% less router CPU per packet, and about a quarter more speed through a proxy on the router. Without kmod-nft-offload the old rules load and the service log says so - Its address at home stays the same when it is turned off and on again; it moved down by one each time (.254, .253, .252) - Less CPU for the same work: the background agent's once-a-second look at the tunnels, Status, Health and the portal no longer compile the same patterns again for each line, address and device. At idle the agent uses about a quarter of the CPU it did; a portal request 5-10 ms less - On LuCI's Bootstrap themes the admin looks as it does on Outline: cards and menus a step above the page, icon tiles that keep their colour, Outline's status colours in dark mode. The choices in Settings → Logs & history and Updates are LuCI's own controls in every theme - "Add from devices at home" keeps a device's name readable in a narrow window: its ports go under the name - DESIGN.md describes the portal's look, components and motion, and the rules send portal work there first. lint-ucode no longer ends a function at a brace inside a template literal
59 lines
3.7 KiB
Ucode
59 lines
3.7 KiB
Ucode
// dawnline.loop: the "like a home device" link's errors, stored as codes and
|
|
// put into words when read; the netns's MAC and which LAN address it may use.
|
|
import * as loop from 'dawnline.loop';
|
|
import { ip2int, parse_cidr } from 'dawnline.util';
|
|
|
|
test('error_text', () => {
|
|
eq(loop.error_text(null), null, 'no error');
|
|
eq(loop.error_text({ code: 'no_lan' }), 'No LAN detected.', 'no LAN');
|
|
eq(loop.error_text({ code: 'not_bridge', dev: 'eth1' }), 'eth1 is not a bridge, so Dawnline cannot join the LAN as a device.', 'not a bridge');
|
|
eq(loop.error_text({ code: 'no_address', net: 'lan' }), 'No free address on lan.', 'no address');
|
|
eq(loop.error_text({ code: 'setup', detail: 'ip: RTNETLINK answers: File exists' }), 'Setup failed: ip: RTNETLINK answers: File exists', 'setup');
|
|
eq(loop.error_text('an old message'), 'an old message', 'older files: as written');
|
|
});
|
|
|
|
test('lan_mac', () => {
|
|
let mac = loop.lan_mac('d4:0d:ab:06:94:aa\n');
|
|
// Pinned: another MAC after an update would make the netns look like someone else once.
|
|
eq(mac, '7a:4e:71:7a:e0:83', 'hashed from the bridge MAC, as sysfs gives it');
|
|
eq(loop.lan_mac('D4:0D:AB:06:94:AA'), mac, 'the same however it is written');
|
|
ok(loop.lan_mac('d4:0d:ab:06:94:ab') != mac, 'another bridge, another MAC');
|
|
for (let b in [ 'd4:0d:ab:06:94:aa', 'd4:0d:ab:06:94:ab', '00:00:00:00:00:00', 'ff:ff:ff:ff:ff:ff' ]) {
|
|
let m = loop.lan_mac(b);
|
|
ok(match(m, /^[0-9a-f]{2}(:[0-9a-f]{2}){5}$/), `${b}: a MAC`);
|
|
let first = hex(substr(m, 0, 2));
|
|
eq([ first & 1, first & 2 ], [ 0, 2 ], `${b}: unicast, locally administered`);
|
|
}
|
|
});
|
|
|
|
test('address_free', () => {
|
|
let lan = parse_cidr('10.0.1.1/24');
|
|
let facts = { pool: [ ip2int('10.0.1.100'), ip2int('10.0.1.249') ], statics: [ ip2int('10.0.1.50') ] };
|
|
let ours = '7a:4e:71:7a:e0:83', old = '7e:8b:31:7d:04:ba', other = '3c:22:fb:01:02:03';
|
|
let free = (ip, used, mine) => loop.address_free(ip2int(ip), lan, facts, used ?? {}, mine ?? [ ours, null ]);
|
|
ok(free('10.0.1.254'), 'nobody on it');
|
|
ok(free('10.0.1.254', { '10.0.1.254': ours }), 'the neighbour entry of the netns before it was created again');
|
|
ok(free('10.0.1.254', { '10.0.1.254': old }, [ ours, old ]), 'the netns as it is now (an older version gave it a random MAC)');
|
|
ok(!free('10.0.1.254', { '10.0.1.254': old }), 'a MAC that is not the netns\'s: someone else');
|
|
ok(!free('10.0.1.254', { '10.0.1.254': other }, [ ours, null ]), 'another device');
|
|
ok(!free('10.0.1.254', { '10.0.1.254': true }), 'an entry without a MAC');
|
|
ok(!free('10.0.1.1'), 'the router');
|
|
ok(!free('10.0.1.50'), 'a static lease');
|
|
ok(!free('10.0.1.100') && !free('10.0.1.249'), 'the DHCP pool');
|
|
ok(free('10.0.1.99') && free('10.0.1.250'), 'next to the pool');
|
|
ok(!free('10.0.1.0') && !free('10.0.1.255'), 'the network and broadcast addresses');
|
|
ok(loop.address_free(ip2int('10.0.1.120'), lan, { pool: null, statics: [] }, {}, [ ours ]), 'no DHCP on the LAN: the pool is free');
|
|
});
|
|
|
|
// The netns's rules: the flowtable only on the netns's own links, never on
|
|
// the root namespace's (the guard on dawn0 must see every packet).
|
|
test('ns_rules', () => {
|
|
let p = { address: '10.0.1.250', dns: '10.0.1.1' };
|
|
let fast = loop.ns_rules(p, true), plain = loop.ns_rules(p, false);
|
|
eq(map(match(fast, /devices = \{ ([^}]*) \}/g), (m) => m[1]), [ '"dlx1", "dll1"' ], 'one flowtable, on dlx1 and dll1 only');
|
|
ok(!match(fast, /dlx0|dll0/), 'no root namespace link');
|
|
ok(index(fast, 'ct state established meta l4proto { tcp, udp } flow add @ft') >= 0, 'established flows added');
|
|
ok(index(plain, 'flowtable') < 0 && index(plain, 'flow add') < 0, 'plain: no flowtable');
|
|
eq(replace(fast, /\n\tflowtable ft \{(\n\t\t[^\n]*)*\n\t\}|\n\t\tct state established meta l4proto \{ tcp, udp \} flow add @ft/g, ''), plain, 'otherwise the same rules');
|
|
});
|