Dawnline 0.18.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- Add V2RayTun to a device's set-up on Android: its awg:// link as a code and to copy, in the portal and in the admin (phones, tablets and other devices), with the server's IP, which its Android app needs; not with the Maximum disguise. Its Windows app is ready but stays off until it gives the tunnel the server's DNS. - Portal: show V2RayTun's Telegram channel beside Google Play. - Make WireGuard part of AmneziaWG's choice when the disguise is off: the same file and code, both apps named in the steps, WireGuard's store a tap away; a router still picks its package. - Portal: Reconnect asks again what the device is and about LAN Bypass, and LAN Bypass switches from a device's ⋯ menu, in a group of its own between the copy actions and Rename, Reconnect, Remove (the keys stay; the device takes its updated configuration). - Turn LAN Bypass on by default for new devices, in the portal and the admin. - Portal: an app's name too long for the picker fades at its edge and glides to its end on hover or tap; two store buttons stack where they do not fit side by side; the month chart's "Today" stays inside its axis. - Write to the router's system log by level (Settings → Logs & history → System log: errors, warnings, normal, verbose): the service starting and stopping, every apply with its time, network, firewall, nftables and peer changes, changed settings and portal errors, in English whatever the admin's language, with keys masked. - Activity: say what a device's change on the portal was (LAN Bypass on or off, its type). - Demo: build again after a force-pushed main instead of failing on the commit that is gone.
This commit is contained in:
1 parent
18e3013047
commit
f8130e39a8
65 files changed
+2066
-338
No files matched your search
+84
-16
@@ -1,8 +1,8 @@
|
||||
// The AmneziaWG core in the admin: how a device connects (.conf, AmneziaVPN
|
||||
// key, QR), the disguise and its parameters, and the core's own settings on
|
||||
// key, QR, V2RayTun's link), the disguise and its parameters, and the core's own settings on
|
||||
// Server → AmneziaWG. Plain WireGuard is AmneziaWG with the disguise off.
|
||||
|
||||
import type { AwgConfig, Server, Status } from '../../shared/types';
|
||||
import type { AwgConfig, Kind, Server, Status } from '../../shared/types';
|
||||
import { E } from '../e';
|
||||
import { api } from '../api';
|
||||
import { button } from '../ui/button';
|
||||
@@ -14,10 +14,12 @@ import { callout, card, firstBad, group, liveRow, row } from '../ui/layout';
|
||||
import { qrCode } from '../ui/qr';
|
||||
import { keepaliveHelp, mtuHelp, portHelp, type PortHold } from '../netcheck';
|
||||
import { vpnKey } from '../../shared/vpnkey';
|
||||
import { awgLink, v2rFits } from '../../shared/awglink';
|
||||
import { V2R_WINDOWS } from '../../shared/flags';
|
||||
import { icon } from '../../shared/icons';
|
||||
import { methodInfo, methodPicker, type Method, defaultMethod, legacyTitle } from '../disguise';
|
||||
import { fmt, fill, num, plural } from '../../shared/i18n';
|
||||
import { coreHead, type Core, type CoreCtx } from './common';
|
||||
import { coreHead, type ConnectView, type Core, type CoreCtx } from './common';
|
||||
|
||||
/** `.conf` names of the disguise parameters, in file order. */
|
||||
const CONF: [string, string][] = [
|
||||
@@ -219,8 +221,71 @@ export function plainWg(cfg: AwgConfig): boolean {
|
||||
return Object.entries(o).every(([k, v]) => v == null || v === '' || v === (neutral[k] ?? '0'));
|
||||
}
|
||||
|
||||
/** File / key / QR switcher for a client configuration; opens on the file unless asked otherwise. */
|
||||
async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'file'): Promise<HTMLElement> {
|
||||
/**
|
||||
* V2RayTun's way in: the connection as its awg:// link (shared/awglink.ts;
|
||||
* the app's own words are in portal/setup.ts, with where they come from). A
|
||||
* computer runs it on Windows, whose core looks the server's name up itself:
|
||||
* the link keeps the name. That one is off for now (shared/flags.ts
|
||||
* V2R_WINDOWS: its core leaves the server's DNS unused). Anything else is
|
||||
* taken for Android, whose core takes no name: the link has the server's IP
|
||||
* (amnezia.host_ip, from device_config).
|
||||
*/
|
||||
function v2rPane(cfg: AwgConfig, kind: Kind): HTMLElement {
|
||||
const win = kind === 'computer';
|
||||
const host = cfg.amnezia.host.replace(/^\[(.*)\]$/, '$1');
|
||||
const ip = win ? null : (cfg.amnezia.host_ip ?? null);
|
||||
const link = awgLink(cfg.conf, cfg.server, ip);
|
||||
const box = E('div', { class: 'dl-linkbox' }, [
|
||||
E('span', { class: 'dl-mono', title: link }, link),
|
||||
button(_('Copy'), () => copyText(link, _('Link copied'))),
|
||||
]);
|
||||
if (win)
|
||||
return E('div', { class: 'dl-stack gap8' }, [
|
||||
box,
|
||||
E(
|
||||
'span',
|
||||
{ class: 'dl-sub' },
|
||||
fmt(
|
||||
_(
|
||||
'V2RayTun on Windows: %s, then set its mode to %s and connect. That mode needs administrator rights: the app offers to restart with them.',
|
||||
),
|
||||
['+', _('Import from clipboard', 'V2RayTun app')].join(' → '),
|
||||
_('Tunnel', 'V2RayTun app'),
|
||||
),
|
||||
),
|
||||
]);
|
||||
return E('div', { class: 'dl-qr-pane' }, [
|
||||
qrCode(link),
|
||||
E(
|
||||
'span',
|
||||
{ class: 'dl-sub' },
|
||||
fmt(
|
||||
_('V2RayTun on Android: %s, or copy the link and %s.'),
|
||||
['+', _('Import config from QRcode', 'V2RayTun app')].join(' → '),
|
||||
['+', _('Import config from Clipboard', 'V2RayTun app')].join(' → '),
|
||||
),
|
||||
),
|
||||
box,
|
||||
// Honest about what the IP costs, and about a name that gives none.
|
||||
ip && ip !== host
|
||||
? E(
|
||||
'div',
|
||||
{ class: 'dl-hint' },
|
||||
_('The link has the server’s IP address, not its name: if the address changes, set the device up again.'),
|
||||
)
|
||||
: !ip
|
||||
? callout('warn', fmt(_('%s does not resolve right now, and V2RayTun on Android connects by IP address only.'), host))
|
||||
: '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* File / key / QR / V2RayTun switcher for a client configuration of a device
|
||||
* of this kind; opens on the file unless asked otherwise. V2RayTun is left out
|
||||
* for a router, for a computer while V2R_WINDOWS is off (shared/flags.ts) and
|
||||
* for AmneziaWG 3.1 (the Maximum disguise), which it lacks.
|
||||
*/
|
||||
async function connectBlock(cfg: AwgConfig, kind: Kind, initial: ConnectView = 'file'): Promise<HTMLElement> {
|
||||
if (!cfg.has_private_key)
|
||||
return E(
|
||||
'div',
|
||||
@@ -228,7 +293,7 @@ async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'fi
|
||||
_('This device generated its own keys in the browser, so its full configuration only exists on that device.'),
|
||||
);
|
||||
const key = await vpnKey(cfg, cfg.server);
|
||||
const panes: Record<string, () => Node> = {
|
||||
const panes: Partial<Record<ConnectView, () => Node>> = {
|
||||
qr: () =>
|
||||
E('div', { class: 'dl-qr-pane' }, [
|
||||
qrCode(cfg.conf),
|
||||
@@ -252,19 +317,22 @@ async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'fi
|
||||
]),
|
||||
file: () => fileCard(cfg),
|
||||
};
|
||||
const body = E('div', { class: 'dl-connect-body' });
|
||||
const seg = E('div', { class: 'dl-seg' });
|
||||
const show = (id: string) => {
|
||||
seg.querySelectorAll('button').forEach((b) => b.classList.toggle('on', b.dataset.id === id));
|
||||
dom.content(body, panes[id]());
|
||||
};
|
||||
for (const [id, label] of [
|
||||
if (kind !== 'router' && (kind !== 'computer' || V2R_WINDOWS) && v2rFits(cfg.conf)) panes.v2r = () => v2rPane(cfg, kind);
|
||||
const labels: [ConnectView, string][] = [
|
||||
['file', _('File')],
|
||||
['key', _('Key')],
|
||||
['qr', _('QR code')],
|
||||
])
|
||||
seg.appendChild(E('button', { type: 'button', 'data-id': id, click: () => show(id) }, label));
|
||||
show(initial);
|
||||
['v2r', 'V2RayTun'],
|
||||
];
|
||||
const body = E('div', { class: 'dl-connect-body' });
|
||||
const seg = E('div', { class: 'dl-seg' });
|
||||
const show = (id: ConnectView) => {
|
||||
seg.querySelectorAll('button').forEach((b) => b.classList.toggle('on', b.dataset.id === id));
|
||||
dom.content(body, panes[id]!());
|
||||
};
|
||||
for (const [id, label] of labels)
|
||||
if (panes[id]) seg.appendChild(E('button', { type: 'button', 'data-id': id, click: () => show(id) }, label));
|
||||
show(panes[initial] ? initial : 'file');
|
||||
return E('div', { class: 'dl-stack gap12' }, [seg, body]);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
// What every tunnel core gives the admin (cores/index.ts holds the registry),
|
||||
// what a core's settings card gets from the Server page, and that card's head.
|
||||
|
||||
import type { ClientConfig, Server, Status } from '../../shared/types';
|
||||
import type { ClientConfig, Kind, Server, Status } from '../../shared/types';
|
||||
import { E } from '../e';
|
||||
|
||||
/** The ways a device takes its configuration, as the set-up switcher names them. */
|
||||
export type ConnectView = 'file' | 'key' | 'qr' | 'v2r';
|
||||
|
||||
/** What the Server page hands a core's settings card. */
|
||||
export interface CoreCtx {
|
||||
st: Status;
|
||||
@@ -21,8 +24,8 @@ export interface Core {
|
||||
settingsCard(ctx: CoreCtx, srv: Server): HTMLElement;
|
||||
/** Overview: how the tunnel looks on the wire (the disguise tile). */
|
||||
overviewTile(srv: Server): HTMLElement;
|
||||
/** How a device connects: file / key / QR. */
|
||||
connectBlock(cfg: ClientConfig, initial?: 'file' | 'key' | 'qr'): Promise<HTMLElement>;
|
||||
/** How a device of this kind connects: file / key / QR / V2RayTun's link, opening on `initial`. */
|
||||
connectBlock(cfg: ClientConfig, kind: Kind, initial?: ConnectView): Promise<HTMLElement>;
|
||||
/** What a QR code for the device carries. */
|
||||
qrText(cfg: ClientConfig): string;
|
||||
/** The key the device's app imports (⋯ → Copy key), with the menu label. */
|
||||
|
||||
@@ -189,7 +189,7 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) {
|
||||
let today = o.today ?? isoDay(new Date());
|
||||
let srv = o.server;
|
||||
// Phones and tablets are set up by scanning; computers and routers by a file.
|
||||
const block = (c: ClientConfig) => core.connectBlock(c, dev.kind === 'phone' || dev.kind === 'tablet' ? 'qr' : 'file');
|
||||
const block = (c: ClientConfig) => core.connectBlock(c, dev.kind, dev.kind === 'phone' || dev.kind === 'tablet' ? 'qr' : 'file');
|
||||
// An older configuration on the device: the new one waits for a click (the inline QR code is itself a delivery).
|
||||
// `relinked`: its MTU or keep-alive was just changed here, which outdates the configuration on screen even where
|
||||
// the router keeps no record of what the device got (never "stale" then, e.g. after a JSON import).
|
||||
@@ -665,8 +665,8 @@ export function addDevice(person: Person, o: DeviceOpts) {
|
||||
),
|
||||
),
|
||||
);
|
||||
// LAN Bypass: off unless chosen (the person chooses it on the portal, the admin here).
|
||||
const bypass = sw(false, _('LAN Bypass'));
|
||||
// LAN Bypass: on unless turned off (the person chooses it on the portal, the admin here).
|
||||
const bypass = sw(true, _('LAN Bypass'));
|
||||
const over = person.devices.length >= person.device_limit;
|
||||
modal(
|
||||
fmt(_('Add a device for %s'), person.name),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// The activity log's vocabulary: categories, who did what, problems, retention.
|
||||
// No DOM and no RPC here (see ./render for rows).
|
||||
|
||||
import type { LogEvent } from '../../shared/types';
|
||||
import type { Kind, LogEvent } from '../../shared/types';
|
||||
import { kindLabel } from '../../shared/format';
|
||||
import type { LogCategory, LogsInfo, ServiceLogEntry } from '../api';
|
||||
import { fmt, known, plural } from '../../shared/i18n';
|
||||
import { LOG_TEMPLATES } from './log-templates';
|
||||
@@ -136,13 +137,25 @@ export function changedText(detail: string): string {
|
||||
.join(', ');
|
||||
}
|
||||
|
||||
/** A device's settings a device_changed event lists (its link options, "mtu, keepalive"); anything else as written. */
|
||||
/**
|
||||
* A device's settings a device_changed event lists: each with what it became
|
||||
* ("lan_bypass=on", "kind=phone", "mtu=1400", "keepalive=auto": the server's),
|
||||
* or by name alone as events before 0.18 have them ("mtu, keepalive");
|
||||
* anything else as written.
|
||||
*/
|
||||
export function deviceChangedText(detail: string): string {
|
||||
const f: Record<string, string> = { mtu: 'MTU', keepalive: _('keep-alive'), lan_bypass: _('LAN Bypass') };
|
||||
return detail
|
||||
.split(', ')
|
||||
.map((k) => f[k] ?? k)
|
||||
.join(', ');
|
||||
const f: Record<string, string> = { mtu: 'MTU', keepalive: _('keep-alive'), lan_bypass: _('LAN Bypass'), kind: _('type') };
|
||||
const one = (part: string): string => {
|
||||
const at = part.indexOf('=');
|
||||
if (at < 0) return f[part] ?? part;
|
||||
const k = part.slice(0, at);
|
||||
const v = part.slice(at + 1);
|
||||
if (k === 'lan_bypass') return v === 'on' ? _('LAN Bypass on') : _('LAN Bypass off');
|
||||
if (k === 'kind') return fmt(_('type: %s'), ['computer', 'phone', 'tablet', 'router', 'other'].includes(v) ? kindLabel(v as Kind) : v);
|
||||
if (v === 'auto') return fmt(_('%s: automatic'), f[k] ?? k);
|
||||
return k === 'keepalive' ? fmt(_('keep-alive %s s'), v) : `${f[k] ?? k} ${v}`;
|
||||
};
|
||||
return detail.split(', ').map(one).join(', ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,6 +179,14 @@ export function eventText(st: Pick<Status, 'people'>, e: LogEvent, personId?: st
|
||||
];
|
||||
if (detail === 'turned off') return say(_('Device %s turned off'), wd);
|
||||
if (detail === 'turned on') return say(_('Device %s turned on'), wd);
|
||||
// On the portal: LAN Bypass from its ⋯ menu, what it is and LAN Bypass with Reconnect.
|
||||
if (by === 'portal')
|
||||
return [
|
||||
...(scoped
|
||||
? say(_('Device %s changed on the portal'), b(dev || _('a device')))
|
||||
: say(_('Person %s changed device %s on their portal'), b(who), b(dev || _('a device')))),
|
||||
...(detail ? [m(` · ${deviceChangedText(detail)}`)] : []),
|
||||
];
|
||||
return [...say(_('Device %s changed'), wd), ...(detail ? [m(` · ${deviceChangedText(detail)}`)] : [])];
|
||||
case 'device_keys':
|
||||
return scoped
|
||||
|
||||
@@ -19,7 +19,7 @@ import type { PersonPage } from './index';
|
||||
async function showDeviceQr(page: PersonPage, d: Device) {
|
||||
const cfg = await attempt(() => api.deviceConfig(d.id, true));
|
||||
if (!cfg) return;
|
||||
modal(fmt(_('Set up %s'), d.name), [await page.core.connectBlock(cfg, 'qr')], [cancelButton(_('Close'))]);
|
||||
modal(fmt(_('Set up %s'), d.name), [await page.core.connectBlock(cfg, d.kind, 'qr')], [cancelButton(_('Close'))]);
|
||||
}
|
||||
|
||||
async function downloadConfig(page: PersonPage, d: Device) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Settings → Logs & history: retention, what is recorded, and the stored data.
|
||||
// Settings → Logs & history: retention, what is recorded, what goes to the
|
||||
// router's system log, and the stored data.
|
||||
|
||||
import { E } from '../../e';
|
||||
import { api } from '../../api';
|
||||
@@ -67,6 +68,17 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
||||
String(p.usage_months),
|
||||
_('Monthly traffic'),
|
||||
);
|
||||
// The router's system log (logread): dawnline.util syslog() writes at these levels.
|
||||
const level = select(
|
||||
[
|
||||
['error', _('Errors only')],
|
||||
['warn', _('Warnings and errors')],
|
||||
['info', _('Normal')],
|
||||
['debug', _('Verbose (debug)')],
|
||||
],
|
||||
String(host.d.effective.log_level ?? 'info'),
|
||||
_('System log'),
|
||||
);
|
||||
const cats = multiSelect(
|
||||
CATEGORIES.map((c): [string, Node] => [
|
||||
c,
|
||||
@@ -111,6 +123,13 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
||||
persist,
|
||||
_('The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot.'),
|
||||
),
|
||||
row(
|
||||
_('System log'),
|
||||
level,
|
||||
_(
|
||||
'What Dawnline writes to the router’s system log (logread -e dawnline). Verbose adds each step of a start and of applying settings.',
|
||||
),
|
||||
),
|
||||
row(_('Daily traffic'), days, _('Per-day history behind the charts.')),
|
||||
row(_('Monthly traffic'), months, _('Per-month totals; data limits use the current month.')),
|
||||
E('h4', { class: 'dl-setsub' }, _('Stored data')),
|
||||
@@ -173,6 +192,7 @@ export function logsCard(host: SettingsHost): HTMLElement {
|
||||
usage_keep_days: days.value,
|
||||
usage_keep_months: months.value,
|
||||
log_category: cats.value(),
|
||||
log_level: level.value,
|
||||
},
|
||||
_('Saved'),
|
||||
'logs',
|
||||
|
||||
Reference in new issue
Block a user