























@@ -18,6 +18,7 @@ export const ConnectErrorDetailCodes = {
1818AUTH_TAILSCALE_WHOIS_FAILED: "AUTH_TAILSCALE_WHOIS_FAILED",
1919AUTH_TAILSCALE_IDENTITY_MISMATCH: "AUTH_TAILSCALE_IDENTITY_MISMATCH",
2020CONTROL_UI_ORIGIN_NOT_ALLOWED: "CONTROL_UI_ORIGIN_NOT_ALLOWED",
21+PROTOCOL_MISMATCH: "PROTOCOL_MISMATCH",
2122CONTROL_UI_DEVICE_IDENTITY_REQUIRED: "CONTROL_UI_DEVICE_IDENTITY_REQUIRED",
2223DEVICE_IDENTITY_REQUIRED: "DEVICE_IDENTITY_REQUIRED",
2324DEVICE_AUTH_INVALID: "DEVICE_AUTH_INVALID",
@@ -461,5 +462,41 @@ export function formatConnectErrorMessage(params: { message?: string; details?:
461462if (readConnectErrorDetailCode(params.details) === ConnectErrorDetailCodes.PAIRING_REQUIRED) {
462463return formatConnectPairingRequiredMessage(params.details);
463464}
465+if (readConnectErrorDetailCode(params.details) === ConnectErrorDetailCodes.PROTOCOL_MISMATCH) {
466+return formatProtocolMismatchMessage(params.message, params.details);
467+}
464468return normalizeOptionalString(params.message) ?? "gateway request failed";
465469}
470+471+function formatProtocolMismatchMessage(message: string | undefined, details: unknown): string {
472+const raw = details as {
473+clientMinProtocol?: unknown;
474+clientMaxProtocol?: unknown;
475+expectedProtocol?: unknown;
476+minimumProbeProtocol?: unknown;
477+};
478+const clientMin = normalizeProtocolNumber(raw.clientMinProtocol);
479+const clientMax = normalizeProtocolNumber(raw.clientMaxProtocol);
480+const expected = normalizeProtocolNumber(raw.expectedProtocol);
481+const probeMin = normalizeProtocolNumber(raw.minimumProbeProtocol);
482+const parts: string[] = [];
483+if (clientMin !== undefined && clientMax !== undefined) {
484+parts.push(
485+clientMin === clientMax
486+ ? `Control UI v${clientMin}`
487+ : `Control UI v${clientMin}-v${clientMax}`,
488+);
489+}
490+if (expected !== undefined) {
491+parts.push(`Gateway v${expected}`);
492+}
493+if (probeMin !== undefined) {
494+parts.push(`probe min v${probeMin}`);
495+}
496+const normalized = normalizeOptionalString(message) ?? "protocol mismatch";
497+return parts.length > 0 ? `${normalized}: ${parts.join(", ")}` : normalized;
498+}
499+500+function normalizeProtocolNumber(value: unknown): number | undefined {
501+return typeof value === "number" && Number.isInteger(value) && value > 0 ? value : undefined;
502+}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。