refactor: ICMP checker type 从 ping 统一改为 icmp,修复前端 UI 细节
- ICMP checker 的 type/configKey/YAML 配置键/接口属性名从 ping 改为 icmp - IcmpChecker 添加 platform 构造函数注入,修复 Windows 测试兼容性 - 前端 target 表格延迟列优化:标题简化为「延迟」,单位下移到单元格,宽度 80px - Drawer 概览页 Descriptions 添加 tableLayout=auto 收窄 label 宽度 - 同步更新 README.md、DEVELOPMENT.md、probes.example.yaml、JSON Schema 和全部测试
This commit is contained in:
@@ -10,15 +10,15 @@ import { issue, joinPath } from "../../schema/issues";
|
||||
export function validatePingConfig(input: CheckerValidationInput): ConfigValidationIssue[] {
|
||||
const issues: ConfigValidationIssue[] = [];
|
||||
|
||||
const defaults = input.defaults["ping"];
|
||||
const defaults = input.defaults["icmp"];
|
||||
if (defaults !== undefined && defaults !== null) {
|
||||
const targetName = "defaults.ping";
|
||||
const targetName = "defaults.icmp";
|
||||
if (!isPlainObject(defaults)) {
|
||||
issues.push(issue("invalid-type", "defaults.ping", "必须为对象", targetName));
|
||||
issues.push(issue("invalid-type", "defaults.icmp", "必须为对象", targetName));
|
||||
} else {
|
||||
const pingDefaults = defaults as Record<string, unknown>;
|
||||
for (const key of Object.keys(pingDefaults)) {
|
||||
issues.push(issue("unknown-field", joinPath("defaults.ping", key), "是未知字段", targetName));
|
||||
const icmpDefaults = defaults as Record<string, unknown>;
|
||||
for (const key of Object.keys(icmpDefaults)) {
|
||||
issues.push(issue("unknown-field", joinPath("defaults.icmp", key), "是未知字段", targetName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ export function validatePingConfig(input: CheckerValidationInput): ConfigValidat
|
||||
const target = input.targets[i] as unknown;
|
||||
if (!isPlainObject(target)) continue;
|
||||
const targetRecord = target as Record<string, unknown>;
|
||||
if (targetRecord["type"] !== "ping") continue;
|
||||
if (targetRecord["type"] !== "icmp") continue;
|
||||
issues.push(...validatePingTarget(targetRecord, `targets[${i}]`));
|
||||
}
|
||||
|
||||
@@ -71,39 +71,39 @@ function validatePingExpect(target: Record<string, unknown>, path: string): Conf
|
||||
function validatePingTarget(target: Record<string, unknown>, path: string): ConfigValidationIssue[] {
|
||||
const issues: ConfigValidationIssue[] = [];
|
||||
const targetName = getTargetName(target);
|
||||
const rawPing = target["ping"];
|
||||
const rawIcmp = target["icmp"];
|
||||
|
||||
if (!isPlainObject(rawPing)) {
|
||||
issues.push(issue("required", joinPath(path, "ping"), "缺少 ping 配置分组", targetName));
|
||||
if (!isPlainObject(rawIcmp)) {
|
||||
issues.push(issue("required", joinPath(path, "icmp"), "缺少 icmp 配置分组", targetName));
|
||||
issues.push(...validatePingExpect(target, path));
|
||||
return issues;
|
||||
}
|
||||
const ping = rawPing as Record<string, unknown>;
|
||||
const icmp = rawIcmp as Record<string, unknown>;
|
||||
|
||||
if (!isString(ping["host"]) || ping["host"].trim() === "") {
|
||||
issues.push(issue("required", joinPath(joinPath(path, "ping"), "host"), "缺少 ping.host 字段", targetName));
|
||||
if (!isString(icmp["host"]) || icmp["host"].trim() === "") {
|
||||
issues.push(issue("required", joinPath(joinPath(path, "icmp"), "host"), "缺少 icmp.host 字段", targetName));
|
||||
}
|
||||
if (ping["count"] !== undefined) {
|
||||
const count = ping["count"];
|
||||
if (icmp["count"] !== undefined) {
|
||||
const count = icmp["count"];
|
||||
if (!isNumber(count) || !Number.isInteger(count) || count < 1 || count > 100) {
|
||||
issues.push(
|
||||
issue("invalid-value", joinPath(joinPath(path, "ping"), "count"), "必须为 1-100 的正整数", targetName),
|
||||
issue("invalid-value", joinPath(joinPath(path, "icmp"), "count"), "必须为 1-100 的正整数", targetName),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (ping["packetSize"] !== undefined) {
|
||||
const packetSize = ping["packetSize"];
|
||||
if (icmp["packetSize"] !== undefined) {
|
||||
const packetSize = icmp["packetSize"];
|
||||
if (!isNumber(packetSize) || !Number.isInteger(packetSize) || packetSize < 1 || packetSize > 65500) {
|
||||
issues.push(
|
||||
issue("invalid-value", joinPath(joinPath(path, "ping"), "packetSize"), "必须为 1-65500 的正整数", targetName),
|
||||
issue("invalid-value", joinPath(joinPath(path, "icmp"), "packetSize"), "必须为 1-65500 的正整数", targetName),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const allowedPingKeys = new Set(["count", "host", "packetSize"]);
|
||||
for (const key of Object.keys(ping)) {
|
||||
if (!allowedPingKeys.has(key)) {
|
||||
issues.push(issue("unknown-field", joinPath(joinPath(path, "ping"), key), "是未知字段", targetName));
|
||||
const allowedIcmpKeys = new Set(["count", "host", "packetSize"]);
|
||||
for (const key of Object.keys(icmp)) {
|
||||
if (!allowedIcmpKeys.has(key)) {
|
||||
issues.push(issue("unknown-field", joinPath(joinPath(path, "icmp"), key), "是未知字段", targetName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user