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
- Russian translation. The admin pages, the LuCI menu and the router's messages (errors, Health checks, update steps, the service log) come in Russian with the new luci-i18n-dawnline-ru package, released beside the app. LuCI shows it when its language is Russian, or "auto" with a Russian browser - The translation installs with install.sh when LuCI is in Russian (or with --lang ru), follows every Dawnline update and rollback, and can be added or removed in Components → Dawnline → Translation - The portal speaks the visitor's language: it opens in the system's language and switches between English and Russian in place, from the language pill beside its QR code. It carries its own translation and needs no package - Set-up steps quote the apps' own menus word for word, in Russian too: AmneziaVPN is "+ → Insert → Continue" (it has no "Add server"), and the Mac and Windows menus of WireGuard and AmneziaWG have their real names - Questions in the portal (Reconnect, Remove) read from the left edge and close with Cancel, without × - Numbers, sizes and dates follow the page's language. A server that can't start says why in one sentence; event details and service log lines read as whole sentences - README in Russian (README_ru.md). rules/i18n.md: how strings are written and translated; CI checks the catalogs (npm run i18n:check)
115 lines
3.5 KiB
Ucode
115 lines
3.5 KiB
Ucode
// Dawnline — one-time steps for routers set up by older versions. Each one
|
|
// checks first and writes nothing when there is nothing to do; dawnline.apply
|
|
// runs them before it takes its own lock (changes to /etc/config/dawnline go
|
|
// through dawnline.store and its config lock).
|
|
|
|
import { cursor } from 'uci';
|
|
import { stat, unlink } from 'fs';
|
|
import { q, slog } from 'dawnline.util';
|
|
import * as core from 'dawnline.core';
|
|
import * as store from 'dawnline.store';
|
|
import { L_ } from 'dawnline.i18n';
|
|
|
|
const LAN_CGI = '/www/cgi-bin/dawnline-portal';
|
|
const LAN_CGI_URL = '/cgi-bin/dawnline-portal';
|
|
|
|
/** Every personal code is a word code; older random ones are replaced (their links stop working). */
|
|
function word_codes() {
|
|
let old = (s) => s.code != null && !match(s.code, core.WORD_CODE);
|
|
let c = cursor();
|
|
c.load('dawnline');
|
|
let any = false;
|
|
c.foreach('dawnline', 'person', (s) => {
|
|
if (old(s))
|
|
any = true;
|
|
});
|
|
if (!any)
|
|
return;
|
|
store.transact((w, m) => {
|
|
w.foreach('dawnline', 'person', (s) => {
|
|
if (old(s)) {
|
|
w.set('dawnline', s['.name'], 'code', core.new_code());
|
|
w.delete('dawnline', s['.name'], 'words');
|
|
}
|
|
});
|
|
});
|
|
slog('dawnline', 'info', L_('moved to word codes'), null, L_('Personal links'));
|
|
}
|
|
|
|
/*
|
|
* Older versions answered on 443 at home through LuCI's web server (its error
|
|
* page ran the portal CGI). The portal now keeps its own port: remove that.
|
|
*/
|
|
export function uhttpd() {
|
|
let c = cursor();
|
|
c.load('uhttpd');
|
|
if (c.get('uhttpd', 'main', 'error_page') == LAN_CGI_URL) {
|
|
c.delete('uhttpd', 'main', 'error_page');
|
|
c.commit('uhttpd');
|
|
system('/etc/init.d/uhttpd reload >/dev/null 2>&1');
|
|
system(`logger -t dawnline ${q('portal removed from the LuCI web server')}`);
|
|
}
|
|
if (stat(LAN_CGI))
|
|
unlink(LAN_CGI);
|
|
// The old setting itself.
|
|
let d = cursor();
|
|
d.load('dawnline');
|
|
if (d.get('dawnline', 'settings', 'portal_443') != null)
|
|
store.transact((w, m) => w.delete('dawnline', 'settings', 'portal_443'));
|
|
};
|
|
|
|
/** The portal names itself after the server now (the breadcrumb, the tab): its own title setting is gone. */
|
|
function portal_title() {
|
|
let c = cursor();
|
|
c.load('dawnline');
|
|
if (c.get('dawnline', 'settings', 'portal_title') != null)
|
|
store.transact((w, m) => w.delete('dawnline', 'settings', 'portal_title'));
|
|
}
|
|
|
|
/*
|
|
* Steps that cannot tell from the config whether they ran are recorded in
|
|
* `settings.migrated` (a list), so they run exactly once.
|
|
*/
|
|
function migrated(c, name) {
|
|
let done = c.get('dawnline', 'settings', 'migrated') ?? [];
|
|
return index(type(done) == 'array' ? done : [ done ], name) >= 0;
|
|
}
|
|
|
|
function mark_migrated(w, name) {
|
|
let done = w.get('dawnline', 'settings', 'migrated') ?? [];
|
|
w.set('dawnline', 'settings', 'migrated', [ ...(type(done) == 'array' ? done : [ done ]), name ]);
|
|
}
|
|
|
|
/*
|
|
* 1380 was every server's stored MTU before it became automatic (by device
|
|
* type and disguise). Once only: an admin may choose 1380 again on purpose.
|
|
*/
|
|
function auto_mtu() {
|
|
let c = cursor();
|
|
c.load('dawnline');
|
|
if (migrated(c, 'auto_mtu'))
|
|
return;
|
|
let any = false;
|
|
c.foreach('dawnline', 'server', (s) => {
|
|
if (s.mtu == '1380')
|
|
any = true;
|
|
});
|
|
store.transact((w, m) => {
|
|
w.foreach('dawnline', 'server', (s) => {
|
|
if (s.mtu == '1380')
|
|
w.delete('dawnline', s['.name'], 'mtu');
|
|
});
|
|
mark_migrated(w, 'auto_mtu');
|
|
});
|
|
if (any)
|
|
slog('dawnline', 'info', L_('MTU is now automatic'), null, L_('Servers'));
|
|
}
|
|
|
|
/** All of them, in order. */
|
|
export function run() {
|
|
word_codes();
|
|
uhttpd();
|
|
auto_mtu();
|
|
portal_title();
|
|
};
|