Dawnline 0.5.0
Build packages / Version (push) Waiting to run

- 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:
Aemeath committed 2026-10-17 01:03:23 +03:00
1 parent 29b1d7dfd7
commit 972e522518
60 files changed
+1966 -636

No files matched your search

@@ -11,7 +11,7 @@
'use strict';
import * as uloop from 'uloop';
import { readfile, writefile, stat, unlink } from 'fs';
import { open, readfile, writefile, stat, unlink } from 'fs';
import {
read_json, write_json, ensure_dir, sh_out, q, uniq, slog, slog_trim, slog_restore, DATA_DIR, RUN_DIR, VERSION
} from 'dawnline.util';
@@ -34,6 +34,21 @@ const LOG_FLUSH = { '10min': 600, hourly: 3600 };
const RESYNC_EVERY = 600;
const CONFIG_FILE = '/etc/config/dawnline';
// One agent, procd's. A second copy would run forever beside it with the code
// it started with: its own events (pauses and resumes from stale states), its
// own counters and syncs. It takes no arguments: the commands are `dawnline`'s.
if (length(ARGV)) {
warn(`The agent takes no arguments (procd runs it). For commands use: dawnline ${join(' ', ARGV)}\n`);
exit(2);
}
ensure_dir(RUN_DIR);
// Held as long as the process lives; close-on-exec, so children don't keep it.
let instance = open(`${RUN_DIR}/agent.lock`, 'we');
if (!instance?.lock('xn')) {
warn(`The agent is already running (${RUN_DIR}/agent.lock is held). Use /etc/init.d/dawnline restart.\n`);
exit(1);
}
let usage = live.load_usage();
let last_states = null;
// Who was online, kept in tmpfs so an agent restart (update, reload) does not
@@ -111,17 +126,19 @@ let conf_mtime = null;
let cert_mtime = null;
const REASON = {
paused: 'paused by admin', paused_all: 'everyone paused', expired: 'end date reached',
quota: 'data limit reached', hours: 'outside allowed hours', no_server: 'no server', active: 'active',
paused: 'paused by admin', expired: 'end date reached',
quota: 'data limit reached', hours: 'outside allowed hours', no_server: 'no server', server_off: 'server turned off',
active: 'active',
};
function check_people(m, states, events) {
let ts = time();
for (let id, p in m.people) {
let st = states[id], prev = last_states?.[id];
// The admin's own pauses are logged by rpcd when they happen; here only
// what changes on its own (end date, data limit, allowed hours).
let by_admin = (x) => x == 'paused' || x == 'paused_all';
// The admin's own pauses (and turning a server off or on) are logged by
// rpcd when they happen; here only what changes on its own (end date,
// data limit, allowed hours).
let by_admin = (x) => x == 'paused' || x == 'server_off';
if (prev != null && prev != st && !by_admin(prev) && !by_admin(st))
push(events, { type: st == 'active' ? 'resumed' : 'paused', person: id, detail: REASON[st] ?? st });
// "Remove their devices" when the end date passes.
@@ -220,6 +237,10 @@ function watch() {
last_hs[id] = max(last_hs[id] ?? 0, peer.handshake);
ep = live.endpoint_ip(peer.endpoint);
}
// Not in the tunnel (turned off, paused, out of time or data): offline now, and online
// again only with a new handshake, not the one remembered from before.
else
last_hs[id] = 0;
let on = last_hs[id] > 0 && now - last_hs[id] < live.ONLINE_WINDOW;
let was = last_online[id];
if (on && !was) {
@@ -1,9 +1,17 @@
#!/bin/sh
# Cron, every 5 minutes: the watchdog lives in the agent, so this looks after
# the agent itself and kills it when it runs but has stopped ticking (procd
# starts it again). Off with the watchdog (Health → Watchdog).
[ "$(uci -q get dawnline.settings.watchdog)" = 0 ] && exit 0
# the agent itself: ends any copy that isn't procd's, and kills procd's when it
# runs but has stopped ticking (procd starts it again; that part is off with
# the watchdog, Health → Watchdog).
pid="$(ubus call service list '{"name":"dawnline"}' 2>/dev/null | jsonfilter -q -e '@.dawnline.instances.agent.pid')"
# Only procd's agent: any other copy (started by hand, or left by an older version that let
# it start) runs stale code beside it, with its own events and syncs. Always ended.
for p in $(pgrep -f '^/usr/bin/ucode /usr/libexec/dawnline/agent'); do
[ "$p" = "$pid" ] || kill -9 "$p" 2>/dev/null
done
[ "$(uci -q get dawnline.settings.watchdog)" = 0 ] && exit 0
[ -n "$pid" ] && [ -r "/proc/$pid/stat" ] || exit 0
now="$(date +%s)"