Dawnline 0.5.2
- 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)
This commit is contained in:
1 parent
1a2f0b327e
commit
2b98abdba4
23 files changed
+197
-88
No files matched your search
@@ -8,7 +8,7 @@ import { api } from '../api';
|
||||
import { svg } from '../ui/layout';
|
||||
import { attachTip } from '../ui/tooltip';
|
||||
import { icon } from '../../shared/icons';
|
||||
import { ago, bits, bytes, daysLeft, initials, todayOf } from '../../shared/format';
|
||||
import { ago, bits, bytes, daysLeft, endsIn, endsSoon, initials, todayOf } from '../../shared/format';
|
||||
import { ConnectionMap, rangeControl, type Range } from '../map';
|
||||
import { personUrl } from '../urls';
|
||||
import { eventRow } from '../events/render';
|
||||
@@ -46,8 +46,7 @@ function attention(st: Status): Attention[] {
|
||||
else if (p.state === 'expired') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), '’s access has ended.'] });
|
||||
else {
|
||||
const left = daysLeft(p.expires, today);
|
||||
if (left != null && left >= 0 && left <= Math.max(p.expire_warn, 3))
|
||||
out.push({ tone: '', text: [link(personUrl(p.id), p.name), `’s access ends in ${left} day${left === 1 ? '' : 's'}.`] });
|
||||
if (endsSoon(p, left)) out.push({ tone: '', text: [link(personUrl(p.id), p.name), `’s access ${endsIn(left as number)}.`] });
|
||||
if (p.quota_limit && p.quota_used >= p.quota_limit * 0.9)
|
||||
out.push({ tone: '', text: [link(personUrl(p.id), p.name), ' has used 90% of the data limit.'] });
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import {
|
||||
date,
|
||||
dayDiff,
|
||||
daysLeft,
|
||||
endsIn,
|
||||
endsSoon,
|
||||
initials,
|
||||
todayOf,
|
||||
} from '../../shared/format';
|
||||
@@ -66,12 +68,7 @@ const stopReason = (p: Person): Exclude<Person['state'], 'active' | 'server_off'
|
||||
|
||||
function needsAttention(p: Person, today: string): boolean {
|
||||
const left = daysLeft(p.expires, today);
|
||||
return (
|
||||
p.state === 'quota' ||
|
||||
p.state === 'expired' ||
|
||||
(left != null && left <= Math.max(p.expire_warn, 3)) ||
|
||||
(!!p.quota_limit && p.quota_used >= p.quota_limit * 0.9)
|
||||
);
|
||||
return p.state === 'quota' || p.state === 'expired' || endsSoon(p, left) || (!!p.quota_limit && p.quota_used >= p.quota_limit * 0.9);
|
||||
}
|
||||
|
||||
/** A month more, from the end date or from today once it has passed. */
|
||||
@@ -357,12 +354,12 @@ export class PeoplePage {
|
||||
const pills: Node[] = [];
|
||||
const why = stopReason(p);
|
||||
if (p.expires && why !== 'expired') {
|
||||
const soon = left != null && left >= 0 && left <= Math.max(p.expire_warn, 3);
|
||||
const soon = endsSoon(p, left);
|
||||
const over = left != null && left < 0;
|
||||
pills.push(
|
||||
E('span', { class: `dl-pill-ic${over ? ' bad' : soon ? ' warn' : ''}`, title: `Access ends ${date(p.expires)}` }, [
|
||||
icon('calendar'),
|
||||
over ? `ended ${date(p.expires)}` : soon ? `ends in ${left} day${left === 1 ? '' : 's'}` : `until ${date(p.expires)}`,
|
||||
over ? `ended ${date(p.expires)}` : soon ? endsIn(left as number) : `until ${date(p.expires)}`,
|
||||
]),
|
||||
);
|
||||
}
|
||||
@@ -410,7 +407,7 @@ export class PeoplePage {
|
||||
|
||||
// Ending soon (the strip below handles an end that has passed).
|
||||
const fixes: Node[] = [];
|
||||
if (p.expires && left != null && left <= Math.max(p.expire_warn, 3) && why !== 'expired')
|
||||
if (p.expires && endsSoon(p, left) && why !== 'expired')
|
||||
fixes.push(
|
||||
E(
|
||||
'button',
|
||||
|
||||
@@ -106,8 +106,8 @@ export function rename(page: PersonPage) {
|
||||
button(
|
||||
'Save',
|
||||
async () => {
|
||||
closeModal();
|
||||
await page.patch({ name: input.value }, 'Renamed');
|
||||
// The dialog stays open on a refusal, with the name still typed.
|
||||
if (await page.patch({ name: input.value.trim() }, 'Renamed')) closeModal();
|
||||
},
|
||||
'positive',
|
||||
),
|
||||
|
||||
@@ -136,16 +136,18 @@ export class PersonPage {
|
||||
* Apply a change now and repaint from the router's answer. Answers of
|
||||
* refreshes already on their way are dropped, so they can't paint the old state over it.
|
||||
*/
|
||||
async patch(patch: PersonPatch, ok?: string) {
|
||||
/** Save a change; true when the router took it (a refusal is already a toast). */
|
||||
async patch(patch: PersonPatch, ok?: string): Promise<boolean> {
|
||||
this.poller?.claim();
|
||||
const r = await attempt(() => api.personUpdate(this.p.id, patch), ok);
|
||||
if (!r) return;
|
||||
if (!r) return false;
|
||||
this.poller?.claim();
|
||||
const i = this.st.people.findIndex((x) => x.id === this.p.id);
|
||||
r.person.rate ??= this.p.rate;
|
||||
if (i >= 0) this.st.people[i] = r.person;
|
||||
this.p = r.person;
|
||||
this.paint();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Today on the router (the last day of its traffic series). */
|
||||
|
||||
@@ -7,7 +7,7 @@ import { notify } from '../../ui/toast';
|
||||
import { seg } from '../../ui/controls';
|
||||
import { attachTip } from '../../ui/tooltip';
|
||||
import { icon } from '../../../shared/icons';
|
||||
import { ACCESS_LABEL, bytes, date, daysLeft, shiftDay } from '../../../shared/format';
|
||||
import { ACCESS_LABEL, bytes, date, daysLeft, endsSoon, shiftDay } from '../../../shared/format';
|
||||
import { resetUsageDialog } from '../../logs';
|
||||
import { homeAccess } from '../../access';
|
||||
import { endSettings } from './dialogs';
|
||||
@@ -78,7 +78,7 @@ function endTile(page: PersonPage): HTMLElement {
|
||||
p.expires
|
||||
? E(
|
||||
'span',
|
||||
{ class: left != null && left < 0 ? 'dl-bad' : left != null && left <= p.expire_warn ? 'dl-warn' : 'dl-ok' },
|
||||
{ class: left != null && left < 0 ? 'dl-bad' : endsSoon(p, left) ? 'dl-warn' : 'dl-ok' },
|
||||
left != null && left < 0 ? 'ended' : `${left} day${left === 1 ? '' : 's'} left`,
|
||||
)
|
||||
: E('span', { class: 'dl-faint' }, 'no end date'),
|
||||
|
||||
@@ -10,6 +10,21 @@ import { section } from './common';
|
||||
|
||||
function uninstall() {
|
||||
const confirmInput = input('', { placeholder: 'remove' });
|
||||
// Live only once the word is typed, as the router itself demands.
|
||||
const go = button(
|
||||
'Remove Dawnline',
|
||||
async () => {
|
||||
if (await attempt(() => api.uninstall(confirmInput.value.trim()), 'Dawnline removed')) {
|
||||
closeModal();
|
||||
setTimeout(() => location.reload(), 800);
|
||||
}
|
||||
},
|
||||
'negative',
|
||||
{ disabled: true },
|
||||
);
|
||||
confirmInput.addEventListener('input', () => {
|
||||
go.disabled = confirmInput.value.trim() !== 'remove';
|
||||
});
|
||||
modal(
|
||||
'Remove Dawnline?',
|
||||
[
|
||||
@@ -20,20 +35,7 @@ function uninstall() {
|
||||
),
|
||||
confirmInput,
|
||||
],
|
||||
[
|
||||
cancelButton(),
|
||||
' ',
|
||||
button(
|
||||
'Remove Dawnline',
|
||||
async () => {
|
||||
if (await attempt(() => api.uninstall(confirmInput.value.trim()), 'Dawnline removed')) {
|
||||
closeModal();
|
||||
setTimeout(() => location.reload(), 800);
|
||||
}
|
||||
},
|
||||
'negative',
|
||||
),
|
||||
],
|
||||
[cancelButton(), ' ', go],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import { portalPortHelp } from '../../netcheck';
|
||||
import { icon } from '../../../shared/icons';
|
||||
import { fmtDay } from '../../../shared/format';
|
||||
import { installMissing } from '../../pkgs';
|
||||
import { notify } from '../../ui/toast';
|
||||
import { section, type SettingsHost } from './common';
|
||||
|
||||
/** Summary of the portal checks: those that failed or warn, and the worst state. */
|
||||
@@ -380,8 +381,18 @@ export function portalCard(host: SettingsHost): HTMLElement {
|
||||
E('span'),
|
||||
button(
|
||||
'Save',
|
||||
() =>
|
||||
host.save(
|
||||
() => {
|
||||
// The port's help line already says what is wrong: do not send it anyway.
|
||||
const h = portalPortHelp(
|
||||
port.value.trim() === '' ? eff.portal_port : Number(port.value),
|
||||
host.d.tcp_taken ?? [],
|
||||
picked.some(isIp),
|
||||
);
|
||||
if (h.bad) {
|
||||
notify(`Listening port: ${h.text}`, 'warning');
|
||||
return;
|
||||
}
|
||||
return host.save(
|
||||
{
|
||||
portal_enabled: isOn(pOn) ? '1' : '0',
|
||||
portal_host: picked[0] ?? '',
|
||||
@@ -392,7 +403,8 @@ export function portalCard(host: SettingsHost): HTMLElement {
|
||||
},
|
||||
'Saved',
|
||||
'portal',
|
||||
),
|
||||
);
|
||||
},
|
||||
'positive',
|
||||
),
|
||||
],
|
||||
|
||||
+18
-9
@@ -5,7 +5,21 @@
|
||||
// devices on the left, access on the right.
|
||||
|
||||
import type { ClientConfig, Device, Kind, Person } from '../shared/types';
|
||||
import { ACCESS_LABEL, KIND_LABEL, addDays, ago, byDeviceState, bytes, date, daysLeft, initials, isoDay, parseDay } from '../shared/format';
|
||||
import {
|
||||
ACCESS_LABEL,
|
||||
KIND_LABEL,
|
||||
addDays,
|
||||
ago,
|
||||
byDeviceState,
|
||||
bytes,
|
||||
date,
|
||||
daysLeft,
|
||||
endsIn,
|
||||
endsSoon,
|
||||
initials,
|
||||
isoDay,
|
||||
parseDay,
|
||||
} from '../shared/format';
|
||||
import { iconSvg } from '../shared/icons';
|
||||
import { qrSvg } from '../shared/qr';
|
||||
import { vpnKey } from '../shared/vpnkey';
|
||||
@@ -430,7 +444,7 @@ function accessCard(st: State): HTMLElement {
|
||||
left != null
|
||||
? h(
|
||||
'span',
|
||||
{ class: `s ${left <= Math.max(p.expire_warn, 3) ? 'warn' : 'ok'}` },
|
||||
{ class: `s ${endsSoon(p, left) ? 'warn' : 'ok'}` },
|
||||
left >= 0 ? `${left} day${left === 1 ? '' : 's'} left` : 'ended',
|
||||
)
|
||||
: null,
|
||||
@@ -599,13 +613,8 @@ function main(st: State) {
|
||||
const notice =
|
||||
p.state !== 'active'
|
||||
? alertRow(stateTone(p), ...stateNotice(p))
|
||||
: left != null && left >= 0 && left <= Math.max(p.expire_warn, 1)
|
||||
? alertRow(
|
||||
'warn',
|
||||
'calendar',
|
||||
`Your access ends ${left === 0 ? 'today' : `in ${left} day${left === 1 ? '' : 's'}`}`,
|
||||
`On ${date(p.expires)}. Ask the admin to extend it.`,
|
||||
)
|
||||
: endsSoon(p, left)
|
||||
? alertRow('warn', 'calendar', `Your access ${endsIn(left as number)}`, `On ${date(p.expires)}. Ask the admin to extend it.`)
|
||||
: null;
|
||||
|
||||
// The device this page was opened from comes first.
|
||||
|
||||
@@ -127,6 +127,19 @@ export function daysLeft(s: string, today: string | number = Date.now()): number
|
||||
return diff >= 0 ? diff + 1 : diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an end date is close enough to warn about, by the person's own
|
||||
* setting (`expire_warn` days; 0 = never). `left` is daysLeft().
|
||||
*/
|
||||
export function endsSoon(p: { expire_warn: number }, left: number | null): boolean {
|
||||
return left != null && left > 0 && p.expire_warn > 0 && left <= p.expire_warn;
|
||||
}
|
||||
|
||||
/** "ends today", "ends tomorrow", "ends in 7 days" for daysLeft() > 0. */
|
||||
export function endsIn(left: number): string {
|
||||
return left <= 1 ? 'ends today' : left === 2 ? 'ends tomorrow' : `ends in ${left} days`;
|
||||
}
|
||||
|
||||
/** "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}`;
|
||||
|
||||
Reference in new issue
Block a user