feat: add tunnel probe target UI

This commit is contained in:
sagitchu
2026-05-01 23:36:14 +08:00
parent 869d726b7a
commit 42c5492c1d
4 changed files with 117 additions and 10 deletions
+19
View File
@@ -8,6 +8,8 @@ interface TunnelFormInput {
inNodeId: TunnelChainNode[];
outNodeId?: TunnelChainNode[];
trafficRatio: number;
probeTargetHost?: string;
probeTargetPort?: number;
}
interface TunnelNodeInput {
@@ -26,6 +28,8 @@ export const createTunnelFormDefaults = () => {
trafficRatio: 1.0,
inIp: "",
ipPreference: "",
probeTargetHost: "",
probeTargetPort: 0,
status: 1,
};
};
@@ -63,6 +67,21 @@ export const validateTunnelForm = (
errors.trafficRatio = "流量倍率须大于0,支持小数(如 0.5)";
}
const probeHost = (form.probeTargetHost || "").trim();
const probePort = Number(form.probeTargetPort || 0);
if (probeHost || probePort > 0) {
if (!probeHost) {
errors.probeTargetHost = "请输入测试目标 Host";
} else if (probeHost.includes("://") || /[\s/?#]/.test(probeHost)) {
errors.probeTargetHost = "Host 不能包含协议、空格或路径";
}
if (!Number.isInteger(probePort) || probePort < 1 || probePort > 65535) {
errors.probeTargetPort = "端口必须是 1-65535";
}
}
if (form.type === 2) {
if (!form.outNodeId || form.outNodeId.length === 0) {
errors.outNodeId = "请至少选择一个出口节点";