- Fixed: a new server with the Maximum disguise could not be created ("jmin=10
(64-1024)"): the 3.1 preset's small junk packets failed Dawnline's own check
- Fixed: guesses from a shared address (every visitor behind Cloudflare) could
lock people with valid links out of the portal for 15 minutes; a valid link
always opens now, only wrong guesses are counted
- Fixed: a disabled Dawnline still loaded every device into the tunnels when
netifd brought them up, with nothing enforcing end dates or limits afterwards
- Fixed: an MTU of 1380 chosen by hand was deleted on every apply (the one-time
switch to automatic MTU now runs once)
- Locations (city lookups) are off by default on new installs: they send
people's addresses to a third party. Routers that had them on keep them on
- "Don't warn" before an end date is honoured, and the warning window is the
one chosen for the person on the Overview, People, the person page and the
portal alike (People and Overview used to warn 3 days before whatever was set)
- "Ends today" and "ends tomorrow" instead of "ends in 1 day"
- Renaming a person keeps the dialog open when the router refuses the name
- Settings → Portal no longer saves a listening port its own help line marks
as taken
- "Remove Dawnline" is live only once "remove" is typed
- Downloaded .conf files are named after the device first, and two devices
whose names only differ past the 15th character no longer get the same file
(and tunnel name in the app)
105 lines
3.1 KiB
Ucode
105 lines
3.1 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';
|
|
|
|
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', 'moved to word codes', null, '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'));
|
|
};
|
|
|
|
/*
|
|
* 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', 'MTU is now automatic', null, 'Servers');
|
|
}
|
|
|
|
/** All of them, in order. */
|
|
export function run() {
|
|
word_codes();
|
|
uhttpd();
|
|
auto_mtu();
|
|
};
|