feat(TrafficRoutes, App): implement interface speed test route and UI integration; update error handling for interface measurement
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m37s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m37s
This commit is contained in:
@@ -235,9 +235,7 @@ async function measureInterfaceSpeed(req, res) {
|
||||
String(i.name).trim() === String(interfaceName).trim()
|
||||
);
|
||||
if (!iface) {
|
||||
throw new Error(
|
||||
`Интерфейс "${interfaceName}" не найден на RouterOS (${serverId})`
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const rx =
|
||||
iface['rx-byte'] != null
|
||||
@@ -253,9 +251,17 @@ async function measureInterfaceSpeed(req, res) {
|
||||
};
|
||||
}
|
||||
|
||||
const notFoundMessage = `Интерфейс "${interfaceName}" не найден на RouterOS (${serverId})`;
|
||||
|
||||
const start = await readOne();
|
||||
if (!start) {
|
||||
return sendError(res, 400, notFoundMessage, 'E_IFACE_NOT_FOUND');
|
||||
}
|
||||
await sleep(durationSeconds * 1000);
|
||||
const end = await readOne();
|
||||
if (!end) {
|
||||
return sendError(res, 400, notFoundMessage, 'E_IFACE_NOT_FOUND');
|
||||
}
|
||||
|
||||
const rxBytesDelta = Math.max(0, (end.rxBytes || 0) - (start.rxBytes || 0));
|
||||
const txBytesDelta = Math.max(0, (end.txBytes || 0) - (start.txBytes || 0));
|
||||
|
||||
Reference in New Issue
Block a user