Expose outbound traffic totals and simplify Direct chart breakdown
Build and Deploy Gateway / build-and-push (push) Successful in 20s
Build and Deploy Gateway / deploy (push) Successful in 13s

This commit is contained in:
2026-08-12 22:43:40 +03:00
parent 9d43e74d97
commit 72c085a5b8
10 changed files with 173 additions and 69 deletions
+31 -2
View File
@@ -548,13 +548,32 @@ test('device outbound history keeps sing-box routes and kernel Direct on separat
}),
});
assert.deepEqual((await service.refresh()).devices[0].outboundTrafficHistory, []);
let snapshot = await service.refresh();
assert.deepEqual(snapshot.devices[0].outboundTraffic, {
observedAt,
singboxObservedAt: observedAt,
directIpv4ObservedAt: observedAt,
vpnBytes: '300',
directTrackedBytes: '30',
directIpv4Bytes: '100',
unknownBytes: '3',
});
assert.deepEqual(snapshot.devices[0].outboundTrafficHistory, []);
observedAt = '2026-08-12T12:00:15.000Z';
vpn = ['150', '250'];
trackedDirect = ['30', '50'];
unknown = ['4', '8'];
directIpv4 = ['70', '90'];
let snapshot = await service.refresh();
snapshot = await service.refresh();
assert.deepEqual(snapshot.devices[0].outboundTraffic, {
observedAt,
singboxObservedAt: observedAt,
directIpv4ObservedAt: observedAt,
vpnBytes: '400',
directTrackedBytes: '80',
directIpv4Bytes: '160',
unknownBytes: '12',
});
assert.deepEqual(snapshot.devices[0].outboundTrafficHistory, [{
observedAt,
vpnBytes: '100',
@@ -570,6 +589,15 @@ test('device outbound history keeps sing-box routes and kernel Direct on separat
unknown = ['0', '1'];
directIpv4 = ['5', '6'];
snapshot = await service.refresh();
assert.deepEqual(snapshot.devices[0].outboundTraffic, {
observedAt,
singboxObservedAt: observedAt,
directIpv4ObservedAt: observedAt,
vpnBytes: '7',
directTrackedBytes: '3',
directIpv4Bytes: '11',
unknownBytes: '1',
});
assert.deepEqual(snapshot.devices[0].outboundTrafficHistory.at(-1), {
observedAt,
vpnBytes: '0',
@@ -578,6 +606,7 @@ test('device outbound history keeps sing-box routes and kernel Direct on separat
unknownBytes: '0',
});
assert.doesNotMatch(fs.readFileSync(filePath, 'utf8'), /outboundTrafficHistory/);
assert.doesNotMatch(fs.readFileSync(filePath, 'utf8'), /outboundTraffic/);
});
test('global traffic stays monotonic when a device expires and returns in the same epoch', async (t) => {