- 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:
1 parent
70a932b8ea
commit
34293fb8e5
158 files changed
+17418
-10022
No files matched your search
@@ -0,0 +1,63 @@
|
||||
// The clipboard and files: copy, download, pick.
|
||||
|
||||
import { E } from '../e';
|
||||
import { errorText, notify } from './toast';
|
||||
|
||||
export async function copyText(text: string, what = 'Copied to clipboard') {
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
const ta = E('textarea', { style: 'position:fixed;opacity:0' }, text) as HTMLTextAreaElement;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
const ok = document.execCommand('copy');
|
||||
ta.remove();
|
||||
if (!ok) throw new Error('Copying is blocked here. Select the text and copy it by hand.');
|
||||
}
|
||||
notify(what, 'success', 2500);
|
||||
} catch (e) {
|
||||
notify(errorText(e), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
/** Saves a file; pass application/octet-stream for .conf, or Safari appends .txt. */
|
||||
export function downloadFile(name: string, content: string | Blob, type = 'text/plain') {
|
||||
const g = globalThis as unknown as { Blob: typeof Blob };
|
||||
const blob = typeof content === 'string' ? new g.Blob([content], { type }) : content;
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = E('a', { href: url, download: name, style: 'display:none' });
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
setTimeout(() => {
|
||||
URL.revokeObjectURL(url);
|
||||
a.remove();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
/** Read a picked file as text or base64. */
|
||||
export function pickFile(accept: string, as: 'text' | 'base64'): Promise<{ name: string; data: string } | null> {
|
||||
return new Promise((resolve) => {
|
||||
const input = E('input', { type: 'file', accept, style: 'display:none' }) as HTMLInputElement;
|
||||
// Closing the file picker fires "cancel" (no "change"); without it the caller waits forever.
|
||||
input.addEventListener('cancel', () => {
|
||||
input.remove();
|
||||
resolve(null);
|
||||
});
|
||||
input.addEventListener('change', () => {
|
||||
const f = input.files?.[0];
|
||||
input.remove();
|
||||
if (!f) return resolve(null);
|
||||
const r = new FileReader();
|
||||
r.onload = () => {
|
||||
const res = String(r.result ?? '');
|
||||
resolve({ name: f.name, data: as === 'base64' ? res.replace(/^data:[^,]*,/, '') : res });
|
||||
};
|
||||
r.onerror = () => resolve(null);
|
||||
if (as === 'base64') r.readAsDataURL(f);
|
||||
else r.readAsText(f);
|
||||
});
|
||||
document.body.appendChild(input);
|
||||
input.click();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user