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

- Components tab replaces Updates: Dawnline, the AmneziaWG build for this
  firmware (Slava-Shchipunov 2.0 or 2Grey 3.1, Russian translation) and
  the system packages Dawnline adds, each checked, installed, reinstalled
  or rolled back in place, with What's new, versions and an activity log
- Automatic updates: daily check, install at a set time or right away,
  per component; AmneziaWG is left out by default and an automatic run
  never switches its build or generation
- Downloads verified against GitHub's sha256; mirrors are used only when
  GitHub is unreachable and the hash is known
- New installer: checks firmware, clock, space and DNS, lets you pick a
  release, shows the plan and asks first; --dry-run
- New uninstaller removes everything Dawnline added (cron, nft, firewall,
  routing, interfaces, packages it installed); --dry-run
- Works without AmneziaWG on the router: Overview, the setup wizard,
  Health and Components say what is missing and offer to install it
- Overview shows failed health checks as notices with their fix
- People list no longer reads the config from the browser: private keys
  stay on the router; personal links are fetched on demand
- Config changes are serialized under one lock, the nft table loads
  atomically and fails closed, and Dawnline never touches network
  sections it did not create
- The portal never opens system ports, keeps disabled devices disabled,
  rate-limits per address and counts days by the router's clock
- Settings and Diagnostics load their heavy parts in the background
- Release notes are written from the commits since the previous release
- Backend and admin UI split into small single-purpose modules
This commit is contained in:
Aemeath committed 2026-10-16 02:14:15 +03:00
1 parent 70a932b8ea
commit 34293fb8e5
158 files changed
+17418 -10022

No files matched your search

@@ -0,0 +1,99 @@
// Dawnline — the plain resolver for people with Home-only access: real
// addresses from the WAN's DNS, home names from the LAN DNS. Their internet
// does not use the tunnel, so fake-IP answers would break it. dawnline.loop
// says where it runs (inside the netns while it exists, otherwise on the
// tunnel interfaces); procd runs dnsmasq through /usr/libexec/dawnline/resolver.
import { readfile, writefile, stat } from 'fs';
import { cursor } from 'uci';
import { ensure_dir, iface_status, uniq } from 'dawnline.util';
import * as net from 'dawnline.net';
import * as core from 'dawnline.core';
/** Port on the tunnel addresses while it runs on the router itself. */
export const PORT = 5354;
export const CONF = '/var/etc/dawnline-dns.conf';
const RESOLV = '/var/etc/dawnline-dns.resolv';
const PID = '/var/run/dawnline-dns.pid';
const FALLBACK_DNS = [ '1.1.1.1', '8.8.8.8' ];
function wan_dns() {
let out = [];
let snap = net.snapshot();
let wan = snap.devices[snap.wan]?.logical;
for (let name in uniq([ wan, 'wan', 'wan6' ])) {
if (!name)
continue;
for (let a in iface_status(name)?.['dns-server'] ?? [])
if (match(a, /^[0-9.]+$/))
push(out, a);
}
return length(out) ? uniq(out) : FALLBACK_DNS;
}
/** Local domain of the LAN DNS (dnsmasq `domain`, else the Dawnline hostname domain). */
function lan_domain(m) {
let c = cursor();
c.load('dhcp');
let d = null;
c.foreach('dhcp', 'dnsmasq', (s) => { d ??= s.domain; });
return uniq(filter([ d, m.settings.domain ], (x) => x));
}
/** True when the resolver process is alive. */
export function running() {
let pid = trim(readfile(PID) ?? '');
return match(pid, /^[0-9]+$/) != null && stat(`/proc/${pid}`) != null;
};
/**
* Write the config for `target` (dawnline.loop resolver_target) with home
* names from `lan` (the LAN's DNS); returns true when it changed (the running
* instance is then restarted by procd's respawn after a kill). The first line
* tells /usr/libexec/dawnline/resolver where to run it.
*/
export function sync(m, target, lan) {
ensure_dir('/var/etc');
let ifs = [];
for (let id, s in m.servers)
for (let t in core.tunnels(s))
push(ifs, t.ifname);
let lines = [
`# mode=${target.mode}`,
'# Generated by Dawnline: plain DNS for Home-only tunnel clients.',
`port=${target.port}`,
'no-hosts',
'bogus-priv',
'cache-size=1000',
`pid-file=${PID}`,
'user=dnsmasq',
'group=dnsmasq',
];
if (target.mode == 'ns') {
push(lines, `listen-address=${target.address}`, 'bind-interfaces', 'no-resolv');
// Upstream from the transit address: forwarded through the router to the WAN.
for (let a in wan_dns())
push(lines, `server=${a}@${target.address}`);
}
else {
// No tunnel yet: loopback only (without any interface= line dnsmasq would answer everywhere).
push(lines, 'bind-dynamic', ...(length(ifs) ? map(ifs, (i) => `interface=${i}`) : [ 'listen-address=127.0.0.1' ]), `resolv-file=${RESOLV}`);
let resolv = join('', map(wan_dns(), (a) => `nameserver ${a}\n`));
if ((readfile(RESOLV) ?? '') != resolv) {
writefile(RESOLV, resolv);
system(`chmod 644 ${RESOLV}`);
}
}
if (lan)
for (let d in lan_domain(m))
push(lines, `server=/${d}/${lan}`);
let conf = join('\n', lines) + '\n';
if ((readfile(CONF) ?? '') == conf)
return false;
writefile(CONF, conf);
system(`chmod 644 ${CONF}`);
let pid = trim(readfile(PID) ?? '');
if (match(pid, /^[0-9]+$/))
system(`kill ${pid} 2>/dev/null`);
return true;
};