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

+81 -9
View File
@@ -51,18 +51,90 @@ export function clock(ts: number): string {
return sameDay ? t : `${d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' })} ${t}`;
}
export function date(s: string): string {
if (!s) return '';
const [y, m, d] = s.split('-').map(Number);
return new Date(y, m - 1, d).toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
/* ---------- days (YYYY-MM-DD, the router's calendar) ---------- */
/** A Date as YYYY-MM-DD in local time. */
export function isoDay(d: Date): string {
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
}
/** Whole days until the end of the given YYYY-MM-DD (negative when past). */
export function daysLeft(s: string, now = Date.now()): number | null {
if (!s) return null;
/** YYYY-MM-DD as a local Date at noon: never shifted to another day by the time zone. */
export function parseDay(s: string): Date {
const [y, m, d] = s.split('-').map(Number);
const end = new Date(y, m - 1, d, 23, 59, 59).getTime();
return Math.ceil((end - now) / 86400000);
return new Date(y, (m || 1) - 1, d || 1, 12);
}
/** "1 Oct 2026". A YYYY-MM-DD is a calendar day; other strings and Dates are moments. */
export function fmtDay(d: Date | string): string {
const v = typeof d === 'string' ? (/^\d{4}-\d{2}-\d{2}$/.test(d) ? parseDay(d) : new Date(d)) : d;
return v.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
}
export function date(s: string): string {
return s ? fmtDay(s) : '';
}
/** Whole days from `b` to `a` (both YYYY-MM-DD); negative when `a` is earlier. */
export function dayDiff(a: string, b: string): number {
const utc = (s: string) => {
const [y, m, d] = s.split('-').map(Number);
return Date.UTC(y, m - 1, d);
};
return Math.round((utc(a) - utc(b)) / 86400000);
}
export function addDays(day: string, n: number): string {
const d = parseDay(day);
d.setDate(d.getDate() + n);
return isoDay(d);
}
/** Months later (or earlier), the day clamped to the month's end: 31 Jan + 1 month = 28 or 29 Feb, not 3 Mar. */
export function addMonthsClamped(day: string, n: number): string {
const [y, m, d] = day.split('-').map(Number);
const t = new Date(y, m - 1 + n, 1, 12);
const last = new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate();
t.setDate(Math.min(d, last));
return isoDay(t);
}
/** Today on the router: the last day of a router series, else the browser's. */
export function todayOf(series: { day: string }[] | undefined): string {
return series?.length ? series[series.length - 1].day : isoDay(new Date());
}
export type DateStep = 'day' | 'week' | 'month' | 'year' | 'custom';
/** Move an end date by n steps (negative shortens). An empty date counts from `today`. */
export function shiftDay(cur: string, step: DateStep, n: number, today: string, customDays = 30): string {
const from = cur || today;
if (step === 'day') return addDays(from, n);
if (step === 'week') return addDays(from, 7 * n);
if (step === 'month') return addMonthsClamped(from, n);
if (step === 'year') return addMonthsClamped(from, 12 * n);
return addDays(from, customDays * n);
}
/**
* Days of access left for an end date (YYYY-MM-DD), counting today: 1 on the
* last day, negative once it has passed, null without one. `today` is the
* router's day; a number (ms) is a moment in the browser's zone.
*/
export function daysLeft(s: string, today: string | number = Date.now()): number | null {
if (!s) return null;
const t = typeof today === 'number' ? isoDay(new Date(today)) : today;
const diff = dayDiff(s, t);
return diff >= 0 ? diff + 1 : diff;
}
/** "1 event", "2,000 events". */
export function plural(n: number, one: string, many = `${one}s`): string {
return `${n.toLocaleString('en-GB')} ${n === 1 ? one : many}`;
}
/** Small sizes on flash and in memory: B, KB, MB. */
export function kb(n: number): string {
return n < 1024 ? `${n} B` : n < 1048576 ? `${(n / 1024).toFixed(n < 10240 ? 1 : 0)} KB` : `${(n / 1048576).toFixed(1)} MB`;
}
export const ACCESS_LABEL: Record<Access, string> = {