Dawnline 0.17.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
- Redraw the admin's charts in the connection map's style: the live speed as lines, the last 30 days and a device's week as stacked download and upload bars, a device's days as a strip, data use as meters. - Read any chart point by point with the pointer, a tap or the arrow keys; a day's tooltip compares it with the average and shows its download and upload. - Show where a data limit leads at the recent pace: the week ahead on the meter, and when the limit fills or what a monthly one reaches by the reset. - Make Speed now live, one point a second, on a person's page, in the People list and in an online person's card. - Name every place an online person's devices connect from, and the city each device connects from now. - Portal: read the month and the week by tap or arrow keys, see how a day compares with the others, the pace toward the data limit and how long the allowed hours still run. - Send VPN clients' DNS to the LAN's DNS after its interceptors, so transparent proxies such as forkop also handle their lookups.
This commit is contained in:
1 parent
b0d9982796
commit
18e3013047
50 files changed
+1683
-425
No files matched your search
@@ -114,3 +114,25 @@ describe('live meter', () => {
|
||||
expect(m.speed('a', 4000).error).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('live meter, a person', () => {
|
||||
it('adds up their devices; a device left out of a second moved nothing', () => {
|
||||
const m = new LiveMeter();
|
||||
const pts: MeterPoint[] = [
|
||||
{ ts: 1001, servers: { a: [30, 60] }, dev: { d1: [10, 20], d2: [20, 40] } },
|
||||
{ ts: 1002, servers: { a: [5, 5] }, dev: { d3: [5, 5] } },
|
||||
// Server a was not read this second: no point for anyone on it.
|
||||
{ ts: 1003, servers: {} },
|
||||
{ ts: 1004, servers: { a: [7, 9] }, dev: { d1: [7, 9] } },
|
||||
];
|
||||
m.take({ meter: meter(pts) }, 0);
|
||||
const s = m.speed('a', 0, ['d1', 'd2']);
|
||||
expect(s.pts).toEqual([
|
||||
[1001, 30, 60],
|
||||
[1002, 0, 0],
|
||||
[1004, 7, 9],
|
||||
]);
|
||||
expect(s).toMatchObject({ rx: 7, tx: 9 });
|
||||
expect(m.speed('a', 0, []).pts.map((p) => p[1])).toEqual([0, 0, 0]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { forecast, paceOf, vsAverage, weekAhead } from '../src/shared/pace';
|
||||
|
||||
const GB = 1024 ** 3;
|
||||
|
||||
describe('pace', () => {
|
||||
it('averages the complete days before today, the last 7 at most', () => {
|
||||
// Ten days, today (999) left out: the 7 before it are 1..7.
|
||||
expect(paceOf([50, 50, 1, 2, 3, 4, 5, 6, 7, 999])).toBe(4);
|
||||
expect(paceOf([3, 5, 100])).toBe(4);
|
||||
expect(paceOf([100])).toBe(0);
|
||||
expect(paceOf([])).toBe(0);
|
||||
});
|
||||
|
||||
it('compares a day with the average, today left out', () => {
|
||||
expect(vsAverage([10, 10, 10, 20, 0], 3)).toBe(60);
|
||||
expect(vsAverage([10, 30, 5], 0)).toBe(-50);
|
||||
expect(vsAverage([0, 0, 5], 2)).toBe(0);
|
||||
});
|
||||
|
||||
it('says when a limit fills at this pace', () => {
|
||||
expect(forecast(46 * GB, 50 * GB, 2 * GB, false, '2026-11-02')).toEqual({ kind: 'fills', days: 2, on: '2026-11-04' });
|
||||
// A monthly limit filling before the 1st is the same.
|
||||
expect(forecast(40 * GB, 50 * GB, 1 * GB, true, '2026-11-15')).toEqual({ kind: 'fills', days: 10, on: '2026-11-25' });
|
||||
});
|
||||
|
||||
it('says what a monthly limit reaches by the reset when that comes first', () => {
|
||||
const f = forecast(12 * GB, 100 * GB, 1 * GB, true, '2026-11-02');
|
||||
expect(f).toEqual({ kind: 'holds', on: '2026-12-01', reach: 41 * GB });
|
||||
});
|
||||
|
||||
it('has nothing to say without a limit, when full or idle', () => {
|
||||
expect(forecast(5, 0, 1, true, '2026-11-02').kind).toBe('none');
|
||||
expect(forecast(10, 10, 1, true, '2026-11-02').kind).toBe('none');
|
||||
expect(forecast(1, 10, 0, true, '2026-11-02').kind).toBe('none');
|
||||
});
|
||||
|
||||
it('takes a week ahead, capped at the limit', () => {
|
||||
expect(weekAhead(10, 100, 1)).toBe(17);
|
||||
expect(weekAhead(90, 100, 5)).toBe(100);
|
||||
expect(weekAhead(5, 0, 1)).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { smooth } from '../src/admin/ui/plot';
|
||||
|
||||
/** Every y a path's points and control points reach. */
|
||||
const ys = (d: string) => [...d.matchAll(/(-?[\d.]+),(-?[\d.]+)/g)].map((m) => Number(m[2]));
|
||||
|
||||
describe('smooth line', () => {
|
||||
it('never overshoots its points, so a quiet stretch stays flat', () => {
|
||||
const pts: [number, number][] = [
|
||||
[0, 40],
|
||||
[10, 40],
|
||||
[20, 2],
|
||||
[30, 40],
|
||||
[40, 40],
|
||||
];
|
||||
const y = ys(smooth(pts));
|
||||
expect(Math.min(...y)).toBeGreaterThanOrEqual(2);
|
||||
expect(Math.max(...y)).toBeLessThanOrEqual(40);
|
||||
});
|
||||
|
||||
it('draws one point as a move and nothing as nothing', () => {
|
||||
expect(smooth([[3, 4]])).toBe('M3.0,4.0');
|
||||
expect(smooth([])).toBe('');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user