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
156 lines
7.3 KiB
TypeScript
156 lines
7.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import { parseCidr, portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../src/admin/netcheck';
|
||
|
||
const nets = [
|
||
{ name: 'lan', cidr: '10.0.1.0/24' },
|
||
{ name: 'loopback', cidr: '127.0.0.0/8' },
|
||
{ name: 'wan', cidr: '109.173.124.0/23' },
|
||
{ name: 'guest', cidr: '192.168.0.0/16' },
|
||
];
|
||
|
||
describe('netcheck', () => {
|
||
it('parses subnets like the router', () => {
|
||
expect(parseCidr('10.10.10.5/24')).toEqual({ net: 0x0a0a0a00, size: 256 });
|
||
expect(parseCidr('10.10.10.0/31')).toBeNull();
|
||
expect(parseCidr('10.10.300.0/24')).toBeNull();
|
||
expect(parseCidr('10.10.10.0')).toBeNull();
|
||
});
|
||
|
||
it('converts between a range and its subnet', () => {
|
||
expect(rangeOf('10.77.0.0/24')).toBe('10.77.0');
|
||
expect(subnetOf(' 10.77.0 ')).toBe('10.77.0.0/24');
|
||
});
|
||
|
||
it('explains the device addresses', () => {
|
||
expect(rangeHelp('10.10.10', nets, '10.77.0')).toEqual({
|
||
text: 'Devices get 10.10.10.2 – 10.10.10.254, the router 10.10.10.1.',
|
||
bad: false,
|
||
});
|
||
expect(rangeHelp('10.0.1', nets, '10.77.0')).toEqual({ text: 'lan already uses 10.0.1.x. Try 10.77.0.', bad: true });
|
||
expect(rangeHelp('192.168.5', nets, '10.77.0').text).toBe('guest already uses 192.168.0.0/16. Try 10.77.0.');
|
||
expect(rangeHelp('10.77.0', [{ name: 'Home', cidr: '10.77.0.0/24' }], '10.77.0').text).toBe('Home already uses 10.77.0.x.');
|
||
});
|
||
|
||
it('wants a private range of three numbers', () => {
|
||
expect(rangeHelp('8.8.8', nets, '').text).toBe('Use a private range: 10.x.x, 172.16–31.x or 192.168.x.');
|
||
expect(rangeHelp('172.32.0', nets, '').bad).toBe(true);
|
||
expect(rangeHelp('172.31.0', nets, '').bad).toBe(false);
|
||
expect(rangeHelp('10.10', nets, '').text).toBe('Three numbers, like 10.77.0.');
|
||
expect(rangeHelp('10.10.10.0', nets, '').bad).toBe(true);
|
||
expect(rangeHelp('10.10.256', nets, '').bad).toBe(true);
|
||
});
|
||
|
||
it('says who holds a port', () => {
|
||
const taken = [
|
||
{ from: 53, to: 53, who: 'dnsmasq on this router' },
|
||
{ from: 4000, to: 4100, who: 'port forward “Game”' },
|
||
];
|
||
expect(portHelp(4500, taken, 'Free.')).toEqual({ text: 'Free.', bad: false });
|
||
expect(portHelp(53, taken, '').text).toBe('Used by dnsmasq on this router. Choose another port.');
|
||
expect(portHelp(4050, taken, '').text).toBe('Used by port forward “Game”. Choose another port.');
|
||
expect(portHelp(0, taken, '').text).toBe('Use a port from 1 to 65535.');
|
||
expect(portHelp(Number.NaN, taken, '').bad).toBe(true);
|
||
});
|
||
|
||
it('checks the portal port and the next one for IP links', () => {
|
||
const taken = [{ from: 8444, to: 8444, who: 'nginx on this router' }];
|
||
expect(portalPortHelp(8443, taken, false)).toEqual({ text: 'HTTPS on this port, opened on WAN.', bad: false });
|
||
expect(portalPortHelp(8443, taken, true).text).toBe(
|
||
'Links on IP addresses also need 8444, used by nginx on this router. Choose another port.',
|
||
);
|
||
expect(portalPortHelp(9443, taken, true)).toEqual({ text: 'HTTPS here, plain HTTP for links on IP addresses on 9444.', bad: false });
|
||
expect(portalPortHelp(8444, taken, false).bad).toBe(true);
|
||
});
|
||
});
|
||
|
||
import {
|
||
chars,
|
||
circleNameHelp,
|
||
deviceKeepaliveHelp,
|
||
deviceMtuHelp,
|
||
dnsHelp,
|
||
domainHelp,
|
||
expiresHelp,
|
||
fallbackDnsHelp,
|
||
hostHelp,
|
||
ipv4Help,
|
||
keepaliveHelp,
|
||
limitHelp,
|
||
mtuHelp,
|
||
nameHelp,
|
||
portsHelp,
|
||
quotaHelp,
|
||
timeHelp,
|
||
urlHelp,
|
||
} from '../src/admin/netcheck';
|
||
import { date, daysLeft } from '../src/shared/format';
|
||
|
||
describe('field helps', () => {
|
||
it('counts characters like the router', () => {
|
||
expect(chars('Мама')).toBe(4);
|
||
expect(nameHelp('ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧ').bad).toBe(false);
|
||
expect(nameHelp('a'.repeat(49)).bad).toBe(true);
|
||
expect(nameHelp('Bob "B"').bad).toBe(true);
|
||
expect(nameHelp(' ').bad).toBe(true);
|
||
expect(nameHelp('Phone', ['phone']).text).toContain('already exists');
|
||
expect(circleNameHelp('x'.repeat(33)).bad).toBe(true);
|
||
});
|
||
it('explains the public address', () => {
|
||
expect(hostHelp('https://vpn.example.com').text).toContain('Leave out https://');
|
||
expect(hostHelp('vpn.example.com:4500').text).toContain('without a port');
|
||
expect(hostHelp('vpn.example.com', 4500)).toEqual({ text: 'Devices connect to vpn.example.com:4500.', bad: false });
|
||
expect(hostHelp('2001:db8::1', 4500).text).toBe('Devices connect to [2001:db8::1]:4500.');
|
||
expect(hostHelp('', 4500).bad).toBe(true);
|
||
expect(hostHelp('', 4500, 'Empty = the portal address.').bad).toBe(false);
|
||
expect(hostHelp('bad_host!').bad).toBe(true);
|
||
});
|
||
it('checks DNS, MTU, keep-alive', () => {
|
||
expect(dnsHelp('', '10.77.0.1').bad).toBe(false);
|
||
expect(dnsHelp('1.1.1.1, foo', '10.77.0.1').text).toContain('“foo” is not an IP address');
|
||
expect(dnsHelp('1.1.1.1 8.8.8.8', '10.77.0.1').text).toContain('1.1.1.1 and 8.8.8.8');
|
||
expect(mtuHelp('', { computer: 1368, phone: 1280 }).text).toContain('1368');
|
||
expect(mtuHelp('1200', { computer: 1368, phone: 1280 }).bad).toBe(true);
|
||
expect(mtuHelp('1400', { computer: 1368, phone: 1280 }).text).toContain('phones and tablets 1280');
|
||
expect(keepaliveHelp('601').bad).toBe(true);
|
||
expect(keepaliveHelp('0').bad).toBe(false);
|
||
});
|
||
it('checks a device’s own MTU and keep-alive like the router', () => {
|
||
expect(deviceMtuHelp('')).toEqual({ text: 'Empty: automatic. Lower it when big pages hang on this device.', bad: false });
|
||
expect(deviceMtuHelp(' 1400 ').bad).toBe(false);
|
||
expect(deviceMtuHelp('1279')).toEqual({ text: 'From 1280 to 1500.', bad: true });
|
||
expect(deviceMtuHelp('1501').bad).toBe(true);
|
||
expect(deviceMtuHelp('14OO').bad).toBe(true);
|
||
expect(deviceKeepaliveHelp('').bad).toBe(false);
|
||
expect(deviceKeepaliveHelp('0').bad).toBe(false);
|
||
expect(deviceKeepaliveHelp('600').bad).toBe(false);
|
||
expect(deviceKeepaliveHelp('601')).toEqual({ text: 'From 0 to 600 seconds.', bad: true });
|
||
expect(deviceKeepaliveHelp('-1').bad).toBe(true);
|
||
});
|
||
it('checks limits, quota and dates', () => {
|
||
expect(limitHelp('0').bad).toBe(true);
|
||
expect(limitHelp('33').bad).toBe(true);
|
||
expect(limitHelp('2', 4).text).toContain('Already has 4');
|
||
expect(quotaHelp('').bad).toBe(false);
|
||
expect(quotaHelp('100001').bad).toBe(true);
|
||
expect(quotaHelp('50').text).toContain('Paused after 50 GB');
|
||
expect(expiresHelp('2026-10-13', '2026-10-14', daysLeft, date).bad).toBe(true);
|
||
expect(expiresHelp('2026-10-14', '2026-10-14', daysLeft, date).text).toContain('ends today');
|
||
expect(expiresHelp('2026-10-20', '2026-10-14', daysLeft, date).text).toContain('ends in 7 days');
|
||
});
|
||
it('checks services, portal and settings fields', () => {
|
||
expect(ipv4Help('10.0.1.300').bad).toBe(true);
|
||
expect(ipv4Help('10.0.1.5', () => false).text).toContain('not in any home network');
|
||
expect(portsHelp('445, 5000').text).toBe('Ports 445, 5000.');
|
||
expect(portsHelp('70000').bad).toBe(true);
|
||
expect(urlHelp('vpn.example.com').bad).toBe(true);
|
||
expect(urlHelp('https://example.com/x').bad).toBe(false);
|
||
expect(domainHelp('').bad).toBe(false);
|
||
expect(domainHelp('').text).toContain('phone.myata.lan');
|
||
expect(domainHelp('Home.LAN').text).toBe('Lowercase only.');
|
||
expect(domainHelp('home.lan').text).toContain('phone.myata.home.lan');
|
||
expect(fallbackDnsHelp('abc').bad).toBe(true);
|
||
expect(timeHelp('4:00').bad).toBe(false);
|
||
expect(timeHelp('24:00').bad).toBe(true);
|
||
});
|
||
});
|