- Where people connect from is a globe map now: live arcs from each
person to the server, grey ones for the last 24 h, 7 or 30 days, avatars
instead of dots, the server's own marker, and a light map in light mode;
it zooms to fit the people shown and follows them as they come and go
- Markers that overlap move apart with a pointer to their spot; people
next to the server fold into a count on it; a click zooms in and opens a
floating card (never clipped by the map), closing flies back
- The person page maps where they connected from, older places fading;
the device panel lists its places in order, and connections from the LAN
or through the router's own address stay off the maps ("LAN" in grey)
- Setup and new servers check the UDP port (taken by another program, a
forward or another server) and the subnet (three numbers + .x, a private
range not in use) as you type; the default port is 4500
- The personal portal can share the server's port number (TCP beside UDP);
its port is checked against forwards and other services
- A new server comes up at once: the kernel module is loaded and the
network restarted when OpenWrt doesn't know AmneziaWG yet
- A turned-off server is a state of its own: no "tunnel down" or DNS
warnings, "Turned off" in yellow, a white Turn on, and people on it are
not shown as paused
- Pause everyone is removed: turning a server off does the same (a router
left paused keeps its servers off after the update)
- People: a stopped person's card fades and says why across its bottom,
with the one action that lifts it (Resume, +10 GB, Extend 1 month);
people held by a limit or end date sort below the others, paused last
- The person page shows the state as text ("Paused") with a Resume
button, also while their server is off
- The portal tells a paused or ended person just that, even with the
server off, and lets them change nothing until the admin lifts it (the
router refuses too); its notices look like Overview's
- Automatic MTU: with the field empty the tunnel, computers and routers
get 1380 minus AmneziaWG S4 (1368 on Maximum), phones and tablets 1280;
a typed MTU still caps phones and tablets at 1280, and servers on the
old default 1380 move to automatic (phones and tablets get "Update
config", their old files keep working)
- Only procd's agent runs: a second copy (started by hand or left over)
refuses to start or is ended within 5 minutes, so no more stray paused
and resumed events; a device that leaves the tunnel is offline at once
- The installer picks the newest release (it took the lowest), DNS
lookups can't hang, and tooltips and floating cards close on scroll and
on leaving the page
This commit is contained in:
1 parent
29b1d7dfd7
commit
972e522518
60 files changed
+1966
-636
No files matched your search
@@ -0,0 +1,93 @@
|
||||
// A new server's UDP port and device addresses, checked as the router checks
|
||||
// them (rpc/servers.uc) and said in plain words for the setup wizard. The
|
||||
// addresses are three numbers ("10.77.0"): the tunnel is that /24.
|
||||
|
||||
/** A network on the router, by name: an interface ("lan") or a server ("Home"). */
|
||||
export interface Network {
|
||||
name: string;
|
||||
cidr: string;
|
||||
}
|
||||
|
||||
/** UDP ports someone holds: a single port has from == to. */
|
||||
export interface PortHold {
|
||||
from: number;
|
||||
to: number;
|
||||
who: string;
|
||||
}
|
||||
|
||||
/** A help line under a field: what it means, or what is wrong (`bad`). */
|
||||
export interface Help {
|
||||
text: string;
|
||||
bad: boolean;
|
||||
}
|
||||
|
||||
interface Cidr {
|
||||
net: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
/** "10.77.0.0/24" as its network and size, prefix 8-30 like util.uc's parse_cidr; null if not one. */
|
||||
export function parseCidr(s: string): Cidr | null {
|
||||
const m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(s.trim());
|
||||
if (!m) return null;
|
||||
const [a, b, c, d] = m.slice(1, 5).map(Number);
|
||||
const prefix = Number(m[5]);
|
||||
if ([a, b, c, d].some((x) => x > 255) || prefix < 8 || prefix > 30) return null;
|
||||
const ip = a * 2 ** 24 + b * 2 ** 16 + c * 2 ** 8 + d;
|
||||
const size = 2 ** (32 - prefix);
|
||||
return { net: ip - (ip % size), size };
|
||||
}
|
||||
|
||||
const overlaps = (x: Cidr, y: Cidr): boolean => x.net < y.net + y.size && y.net < x.net + x.size;
|
||||
|
||||
const PRIVATE = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'].map((c) => parseCidr(c) as Cidr);
|
||||
|
||||
/** The first three numbers of a subnet ("10.77.0.0/24" → "10.77.0"). */
|
||||
export function rangeOf(subnet: string): string {
|
||||
return subnet.split('/')[0].split('.').slice(0, 3).join('.');
|
||||
}
|
||||
|
||||
/** The tunnel subnet of a range ("10.77.0" → "10.77.0.0/24"). */
|
||||
export function subnetOf(range: string): string {
|
||||
return `${range.trim()}.0/24`;
|
||||
}
|
||||
|
||||
/** The device addresses: what they give, or why not (`suggest` is a free range to offer). */
|
||||
export function rangeHelp(range: string, nets: Network[], suggest: string): Help {
|
||||
const r = range.trim();
|
||||
const c = /^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r) ? parseCidr(subnetOf(r)) : null;
|
||||
if (!c) return { text: 'Three numbers, like 10.77.0.', bad: true };
|
||||
if (!PRIVATE.some((p) => c.net >= p.net && c.net + c.size <= p.net + p.size))
|
||||
return { text: 'Use a private range: 10.x.x, 172.16–31.x or 192.168.x.', bad: true };
|
||||
const hit = nets.find((n) => {
|
||||
const o = parseCidr(n.cidr);
|
||||
return o != null && overlaps(c, o);
|
||||
});
|
||||
if (hit) {
|
||||
const used = hit.cidr.endsWith('/24') ? `${rangeOf(hit.cidr)}.x` : hit.cidr;
|
||||
const other = suggest && suggest !== r ? ` Try ${suggest}.` : '';
|
||||
return { text: `${hit.name} already uses ${used}.${other}`, bad: true };
|
||||
}
|
||||
return { text: `Devices get ${r}.2 – ${r}.254, the router ${r}.1.`, bad: false };
|
||||
}
|
||||
|
||||
const holder = (port: number, taken: PortHold[]): string | null => taken.find((t) => t.from <= port && port <= t.to)?.who ?? null;
|
||||
|
||||
const validPort = (port: number): boolean => Number.isInteger(port) && port >= 1 && port <= 65535;
|
||||
|
||||
/** A port: `free` when nobody holds it, or who does. */
|
||||
export function portHelp(port: number, taken: PortHold[], free: string): Help {
|
||||
if (!validPort(port)) return { text: 'Use a port from 1 to 65535.', bad: true };
|
||||
const who = holder(port, taken);
|
||||
return who ? { text: `Used by ${who}. Choose another port.`, bad: true } : { text: free, bad: false };
|
||||
}
|
||||
|
||||
/** The portal's TCP port; links on IP addresses (`ipLinks`) use plain HTTP on the next one too. */
|
||||
export function portalPortHelp(port: number, taken: PortHold[], ipLinks: boolean): Help {
|
||||
const free = ipLinks ? `HTTPS here, plain HTTP for links on IP addresses on ${port + 1}.` : 'HTTPS on this port, opened on WAN.';
|
||||
const h = portHelp(port, taken, free);
|
||||
if (h.bad || !ipLinks) return h;
|
||||
if (port === 65535) return { text: 'Links on IP addresses also need the next port: choose a lower one.', bad: true };
|
||||
const who = holder(port + 1, taken);
|
||||
return who ? { text: `Links on IP addresses also need ${port + 1}, used by ${who}. Choose another port.`, bad: true } : h;
|
||||
}
|
||||
Reference in new issue
Block a user