fix(api): проверять параметры запуска теста скорости до операции

This commit is contained in:
Denozordec committed 2026-10-07 17:30:52 +07:00
1 parent b0e114b56d
commit b59944b573
7 files changed
+114 -62

No files matched your search

+12
View File
@@ -44,3 +44,15 @@ export const emptySpeedProbeObservations = {
lastRunAt: null, lastTxAvgMbps: null, lastRxAvgMbps: null, lastStatus: null, lastError: null,
lastPingRttMs: null, lastPingLossPct: null, lastPingAt: null, lastPingError: null,
}
const speedCommandText = z.string().refine(value => !value.includes(String.fromCharCode(0)), "Недопустимый символ в параметре теста")
const speedOptionalId = speedCommandText.trim().transform(value => value || undefined).optional()
export const speedTestCommandSchema = z.object({
runId: speedOptionalId, probeId: speedOptionalId,
srcServerId: speedPositiveInteger, dstServerId: speedPositiveInteger,
srcInterface: speedCommandText.trim().default(""), dstInterface: speedCommandText.trim().default(""),
protocol: z.enum(["tcp", "udp"]).default("tcp"),
direction: z.enum(["transmit", "receive", "both"]).default("both"),
durationSec: speedPositiveInteger.pipe(z.number().min(3).max(2147483647)).default(10),
}).refine(row => row.srcServerId !== row.dstServerId, "Источник и назначение должны отличаться")
export type SpeedTestCommand = z.infer<typeof speedTestCommandSchema>