mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix: classify TeamSpeak connection failures
This commit is contained in:
1 parent
6d8e289b81
commit
7e08ee54a5
7 files changed
+177
-29
No files matched your search
@@ -20,6 +20,7 @@ export interface AdminConnectionRecord {
|
||||
durationSeconds: number | null;
|
||||
status: "active" | "connecting" | "disconnected" | "failed";
|
||||
reason: string | null;
|
||||
failureDetail: string | null;
|
||||
}
|
||||
|
||||
export interface AdminRouterOptions {
|
||||
@@ -473,6 +474,7 @@ export function readConnectionHistory(logFile: string | undefined, limit: number
|
||||
durationSeconds: number | null;
|
||||
status: AdminConnectionRecord["status"];
|
||||
reason: string | null;
|
||||
failureDetail: string | null;
|
||||
}>();
|
||||
for (const log of readStructuredLogs(logFile)) {
|
||||
const entryId = typeof log.raw.entryId === "string" ? log.raw.entryId : "";
|
||||
@@ -490,6 +492,7 @@ export function readConnectionHistory(logFile: string | undefined, limit: number
|
||||
durationSeconds: null,
|
||||
status: "connecting" as const,
|
||||
reason: null,
|
||||
failureDetail: null,
|
||||
};
|
||||
const nickname = typeof log.raw.nickname === "string" ? log.raw.nickname : "";
|
||||
const clientIp = typeof log.raw.clientIp === "string" ? log.raw.clientIp : "";
|
||||
@@ -501,9 +504,13 @@ export function readConnectionHistory(logFile: string | undefined, limit: number
|
||||
if (target) current.target = target;
|
||||
if (relayName) current.relayName = relayName;
|
||||
if (relayTarget) current.relayTarget = relayTarget;
|
||||
if (typeof log.raw.failureDetail === "string" && log.raw.failureDetail) current.failureDetail = log.raw.failureDetail;
|
||||
if (log.message === "WebClient connecting") {
|
||||
current.startedAt ??= log.timestamp;
|
||||
current.status = "connecting";
|
||||
} else if (log.message === "TS connect failed") {
|
||||
current.reason = typeof log.raw.code === "string" ? log.raw.code : current.reason;
|
||||
current.status = "failed";
|
||||
} else if (log.message === "Web client connected to TeamSpeak") {
|
||||
current.startedAt ??= log.timestamp;
|
||||
current.connectedAt = log.timestamp;
|
||||
@@ -523,7 +530,7 @@ export function readConnectionHistory(logFile: string | undefined, limit: number
|
||||
// rendered by the admin UI as the generic request-failed message.
|
||||
current.reason = typeof log.raw.failureCode === "string" && log.raw.failureCode
|
||||
? log.raw.failureCode
|
||||
: null;
|
||||
: current.reason;
|
||||
}
|
||||
records.set(entryId, current);
|
||||
}
|
||||
@@ -552,6 +559,7 @@ export function readConnectionHistory(logFile: string | undefined, limit: number
|
||||
// an untraceable failed connection explicitly visible as the generic
|
||||
// request-failed message instead of implying a guessed cause.
|
||||
reason: record.reason ?? (record.status === "failed" ? "CONNECTION_FAILED" : null),
|
||||
failureDetail: record.failureDetail,
|
||||
};
|
||||
})
|
||||
.sort((left, right) => Date.parse(right.disconnectedAt ?? right.startedAt) - Date.parse(left.disconnectedAt ?? left.startedAt))
|
||||
|
||||
+113
-14
@@ -1,6 +1,9 @@
|
||||
export type WebSpeakErrorCode =
|
||||
| "invalid_target"
|
||||
| "host_not_found"
|
||||
| "unreachable"
|
||||
| "connection_refused"
|
||||
| "connection_reset"
|
||||
| "timeout"
|
||||
| "authentication_failed"
|
||||
| "protocol_negotiation_failed"
|
||||
@@ -9,7 +12,10 @@ export type WebSpeakErrorCode =
|
||||
|
||||
export type ClientConnectionFailureCode =
|
||||
| "INVALID_TARGET"
|
||||
| "HOST_NOT_FOUND"
|
||||
| "UNREACHABLE"
|
||||
| "CONNECTION_REFUSED"
|
||||
| "CONNECTION_RESET"
|
||||
| "TIMEOUT"
|
||||
| "SERVER_PASSWORD_REQUIRED"
|
||||
| "INVALID_SERVER_PASSWORD"
|
||||
@@ -17,43 +23,62 @@ export type ClientConnectionFailureCode =
|
||||
| "SERVER_REJECTED"
|
||||
| "CONNECTION_FAILED";
|
||||
|
||||
export interface TeamSpeakErrorDiagnostics {
|
||||
name?: string;
|
||||
code?: string;
|
||||
id?: string;
|
||||
serverMessage?: string;
|
||||
message?: string;
|
||||
syscall?: string;
|
||||
address?: string;
|
||||
port?: number | string;
|
||||
cause?: string;
|
||||
}
|
||||
|
||||
export class WebSpeakError extends Error {
|
||||
readonly code: WebSpeakErrorCode;
|
||||
readonly retryable: boolean;
|
||||
readonly cause?: unknown;
|
||||
readonly diagnostics: TeamSpeakErrorDiagnostics;
|
||||
|
||||
constructor(code: WebSpeakErrorCode, message: string, retryable: boolean, cause?: unknown) {
|
||||
constructor(code: WebSpeakErrorCode, message: string, retryable: boolean, cause?: unknown, diagnostics: TeamSpeakErrorDiagnostics = {}) {
|
||||
super(message);
|
||||
this.name = "WebSpeakError";
|
||||
this.code = code;
|
||||
this.retryable = retryable;
|
||||
this.cause = cause;
|
||||
this.diagnostics = diagnostics;
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeTeamSpeakError(error: unknown): WebSpeakError {
|
||||
if (error instanceof WebSpeakError) return error;
|
||||
|
||||
const candidate = error as { code?: unknown; id?: unknown; serverMessage?: unknown; message?: unknown } | null;
|
||||
const code = typeof candidate?.code === "string" ? candidate.code : "";
|
||||
const id = typeof candidate?.id === "string" || typeof candidate?.id === "number" ? String(candidate.id) : "";
|
||||
const serverMessage = typeof candidate?.serverMessage === "string" ? candidate.serverMessage : "";
|
||||
const message = typeof candidate?.message === "string" ? candidate.message : String(error);
|
||||
const text = `${code} ${id} ${serverMessage} ${message}`.toLocaleLowerCase();
|
||||
const diagnostics = collectDiagnostics(error);
|
||||
const text = diagnosticText(error).toLocaleLowerCase();
|
||||
|
||||
if (/password|authenticate|authentication|not authorized|invalid.*(credential|password)/.test(text)) {
|
||||
return new WebSpeakError("authentication_failed", "TeamSpeak authentication failed", false, error);
|
||||
return new WebSpeakError("authentication_failed", "TeamSpeak authentication failed", false, error, diagnostics);
|
||||
}
|
||||
if (/timeout|timed out|ack timeout|idle timeout/.test(text)) {
|
||||
return new WebSpeakError("timeout", "TeamSpeak connection timed out", true, error);
|
||||
if (/enotfound|eai_again|host not found|name or service not known|dns/.test(text)) {
|
||||
return new WebSpeakError("host_not_found", "TeamSpeak server hostname could not be resolved", true, error, diagnostics);
|
||||
}
|
||||
if (/econnrefused|enotfound|ehostunreach|enetunreach|network|socket|dns/.test(text)) {
|
||||
return new WebSpeakError("unreachable", "TeamSpeak server is unreachable", true, error);
|
||||
if (/econnrefused|connection refused/.test(text)) {
|
||||
return new WebSpeakError("connection_refused", "TeamSpeak server refused the connection", true, error, diagnostics);
|
||||
}
|
||||
if (/econnreset|econnaborted|connection reset|connection aborted/.test(text)) {
|
||||
return new WebSpeakError("connection_reset", "TeamSpeak connection was reset", true, error, diagnostics);
|
||||
}
|
||||
if (/timeout|timed out|ack timeout|idle timeout|etimedout/.test(text)) {
|
||||
return new WebSpeakError("timeout", "TeamSpeak connection timed out", true, error, diagnostics);
|
||||
}
|
||||
if (/ehostunreach|enetunreach|network is unreachable|no route to host|network|socket/.test(text)) {
|
||||
return new WebSpeakError("unreachable", "TeamSpeak server is unreachable", true, error, diagnostics);
|
||||
}
|
||||
if (/protocol|handshake|crypto|init1/.test(text)) {
|
||||
return new WebSpeakError("protocol_negotiation_failed", "TeamSpeak protocol negotiation failed", true, error);
|
||||
return new WebSpeakError("protocol_negotiation_failed", "TeamSpeak protocol negotiation failed", true, error, diagnostics);
|
||||
}
|
||||
return new WebSpeakError("unknown", "TeamSpeak connection failed", false, error);
|
||||
return new WebSpeakError("unknown", "TeamSpeak connection failed", false, error, diagnostics);
|
||||
}
|
||||
|
||||
export function clientConnectionFailureCode(error: WebSpeakError, serverPassword = ""): ClientConnectionFailureCode {
|
||||
@@ -62,7 +87,10 @@ export function clientConnectionFailureCode(error: WebSpeakError, serverPassword
|
||||
}
|
||||
const mapping: Record<WebSpeakErrorCode, ClientConnectionFailureCode> = {
|
||||
invalid_target: "INVALID_TARGET",
|
||||
host_not_found: "HOST_NOT_FOUND",
|
||||
unreachable: "UNREACHABLE",
|
||||
connection_refused: "CONNECTION_REFUSED",
|
||||
connection_reset: "CONNECTION_RESET",
|
||||
timeout: "TIMEOUT",
|
||||
authentication_failed: "SERVER_PASSWORD_REQUIRED",
|
||||
protocol_negotiation_failed: "PROTOCOL_NEGOTIATION_FAILED",
|
||||
@@ -71,3 +99,74 @@ export function clientConnectionFailureCode(error: WebSpeakError, serverPassword
|
||||
};
|
||||
return mapping[error.code];
|
||||
}
|
||||
|
||||
/** Format useful SDK/Node details for a safe operational log field. */
|
||||
export function describeTeamSpeakError(error: WebSpeakError): string {
|
||||
const details = error.diagnostics;
|
||||
const parts = [
|
||||
details.name,
|
||||
details.code,
|
||||
details.id ? `id=${details.id}` : "",
|
||||
details.serverMessage,
|
||||
details.syscall,
|
||||
details.address ? `address=${details.address}` : "",
|
||||
details.port !== undefined ? `port=${details.port}` : "",
|
||||
details.cause,
|
||||
details.message,
|
||||
].filter(Boolean);
|
||||
return parts.length ? parts.join("; ") : error.message;
|
||||
}
|
||||
|
||||
function diagnosticText(error: unknown): string {
|
||||
const values: string[] = [];
|
||||
let current: unknown = error;
|
||||
const seen = new Set<unknown>();
|
||||
for (let depth = 0; depth < 4 && current && !seen.has(current); depth += 1) {
|
||||
seen.add(current);
|
||||
if (current instanceof Error) values.push(current.name, current.message);
|
||||
else values.push(String(current));
|
||||
if (typeof current === "object") {
|
||||
const candidate = current as { code?: unknown; id?: unknown; serverMessage?: unknown; cause?: unknown };
|
||||
for (const value of [candidate.code, candidate.id, candidate.serverMessage]) if (value !== undefined) values.push(String(value));
|
||||
current = candidate.cause;
|
||||
} else break;
|
||||
}
|
||||
return values.join(" ");
|
||||
}
|
||||
|
||||
function collectDiagnostics(error: unknown): TeamSpeakErrorDiagnostics {
|
||||
const result: TeamSpeakErrorDiagnostics = {};
|
||||
let current: unknown = error;
|
||||
const seen = new Set<unknown>();
|
||||
for (let depth = 0; depth < 4 && current && !seen.has(current); depth += 1) {
|
||||
seen.add(current);
|
||||
if (current instanceof Error) {
|
||||
result.name ??= current.name;
|
||||
result.message ??= current.message;
|
||||
const errorRecord = current as Error & Record<string, unknown>;
|
||||
if (typeof errorRecord.code === "string" || typeof errorRecord.code === "number") result.code ??= String(errorRecord.code);
|
||||
if (typeof errorRecord.id === "string" || typeof errorRecord.id === "number") result.id ??= String(errorRecord.id);
|
||||
if (typeof errorRecord.serverMessage === "string") result.serverMessage ??= errorRecord.serverMessage;
|
||||
if (typeof errorRecord.syscall === "string") result.syscall ??= errorRecord.syscall;
|
||||
if (typeof errorRecord.address === "string") result.address ??= errorRecord.address;
|
||||
if (typeof errorRecord.port === "string" || typeof errorRecord.port === "number") result.port ??= errorRecord.port;
|
||||
const cause = current.cause;
|
||||
if (cause && cause !== current) { current = cause; continue; }
|
||||
break;
|
||||
}
|
||||
if (typeof current !== "object") { result.cause ??= String(current); break; }
|
||||
const candidate = current as Record<string, unknown>;
|
||||
if (typeof candidate.name === "string") result.name ??= candidate.name;
|
||||
if (typeof candidate.code === "string" || typeof candidate.code === "number") result.code ??= String(candidate.code);
|
||||
if (typeof candidate.id === "string" || typeof candidate.id === "number") result.id ??= String(candidate.id);
|
||||
if (typeof candidate.serverMessage === "string") result.serverMessage ??= candidate.serverMessage;
|
||||
if (typeof candidate.message === "string") result.message ??= candidate.message;
|
||||
if (typeof candidate.syscall === "string") result.syscall ??= candidate.syscall;
|
||||
if (typeof candidate.address === "string") result.address ??= candidate.address;
|
||||
if (typeof candidate.port === "string" || typeof candidate.port === "number") result.port ??= candidate.port;
|
||||
const cause = candidate.cause;
|
||||
if (cause && cause !== current) { current = cause; continue; }
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import type { TeamSpeakProtocol } from "./teamspeak-adapter.js";
|
||||
export type ProbeErrorCode =
|
||||
| "HOST_NOT_FOUND"
|
||||
| "UNREACHABLE"
|
||||
| "CONNECTION_REFUSED"
|
||||
| "CONNECTION_RESET"
|
||||
| "TIMEOUT"
|
||||
| "PASSWORD_REQUIRED"
|
||||
| "INVALID_PASSWORD"
|
||||
@@ -103,6 +105,9 @@ export function toProbeError(error: unknown, password = ""): TeamSpeakProbeError
|
||||
const mapping: Record<WebSpeakErrorCode, ProbeErrorCode> = {
|
||||
invalid_target: "INTERNAL_ERROR",
|
||||
unreachable: "UNREACHABLE",
|
||||
host_not_found: "HOST_NOT_FOUND",
|
||||
connection_refused: "CONNECTION_REFUSED",
|
||||
connection_reset: "CONNECTION_RESET",
|
||||
timeout: "TIMEOUT",
|
||||
authentication_failed: password.trim() ? "INVALID_PASSWORD" : "PASSWORD_REQUIRED",
|
||||
protocol_negotiation_failed: "PROTOCOL_NEGOTIATION_FAILED",
|
||||
|
||||
+13
-3
@@ -14,6 +14,7 @@ import {
|
||||
type TextMessage,
|
||||
} from "@echosixhiya/teamspeak-client";
|
||||
import type { Logger } from "../logger.js";
|
||||
import { describeTeamSpeakError, normalizeTeamSpeakError } from "../errors.js";
|
||||
import { TeamSpeakAdapter, type TeamSpeakProtocol } from "./teamspeak-adapter.js";
|
||||
import type { TeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { createAccelerationRelayClient, type AccelerationRelayClient, type AccelerationRelayOptions } from "./acceleration-relay.js";
|
||||
@@ -138,8 +139,9 @@ export class TSClient extends EventEmitter {
|
||||
this.emit("directorySnapshot", { channels, clients });
|
||||
} catch (error: unknown) {
|
||||
this.logger.warn({
|
||||
err: error instanceof Error ? error.message : String(error),
|
||||
}, "Could not reconcile the TeamSpeak directory snapshot");
|
||||
failureCode: "DIRECTORY_SNAPSHOT_UNAVAILABLE",
|
||||
failureDetail: error instanceof Error ? error.message : String(error),
|
||||
}, "TeamSpeak directory snapshot unavailable");
|
||||
}
|
||||
|
||||
const connectedChannelId = client.channelID();
|
||||
@@ -193,7 +195,15 @@ export class TSClient extends EventEmitter {
|
||||
});
|
||||
|
||||
client.on("disconnected", (err) => {
|
||||
this.logger.warn({ err: err?.message }, "Disconnected from TS");
|
||||
if (err) {
|
||||
const normalized = normalizeTeamSpeakError(err);
|
||||
this.logger.warn({
|
||||
failureCode: normalized.code.toUpperCase(),
|
||||
failureDetail: describeTeamSpeakError(normalized),
|
||||
}, "TeamSpeak transport disconnected unexpectedly");
|
||||
} else {
|
||||
this.logger.info("TeamSpeak transport disconnected");
|
||||
}
|
||||
this.connected = false;
|
||||
this.clientId = 0;
|
||||
this.emit("disconnected", err);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { identityFromString } from "@echosixhiya/teamspeak-client";
|
||||
import { DirectorySynchronizer } from "./directory-sync.js";
|
||||
import { TSClient, type TSDirectorySnapshot, type TSVoiceData } from "./ts-client.js";
|
||||
import type { Logger as LoggerType } from "../logger.js";
|
||||
import { clientConnectionFailureCode, normalizeTeamSpeakError } from "../errors.js";
|
||||
import { clientConnectionFailureCode, describeTeamSpeakError, normalizeTeamSpeakError } from "../errors.js";
|
||||
import { formatTeamSpeakTarget, teamSpeakTargetKey, type TeamSpeakTarget } from "../domain/teamspeak-target.js";
|
||||
import { JoinTicketStore, type JoinTicketPayload } from "./join-ticket.js";
|
||||
import { IdentityLeaseStore } from "./identity-lease.js";
|
||||
@@ -436,7 +436,15 @@ export class VoiceBridge {
|
||||
const normalized = normalizeTeamSpeakError(error);
|
||||
const failureCode = clientConnectionFailureCode(normalized, serverPassword);
|
||||
entry!.connectionFailureCode = failureCode;
|
||||
this.logger.error({ code: failureCode, normalizedCode: normalized.code, entryId, reconnect: isReconnect, attempt: reconnectAttempt }, "TS connect failed");
|
||||
this.logger.warn({
|
||||
code: failureCode,
|
||||
normalizedCode: normalized.code,
|
||||
failureDetail: describeTeamSpeakError(normalized),
|
||||
...(Object.keys(normalized.diagnostics).length ? { failureDiagnostics: normalized.diagnostics } : {}),
|
||||
entryId,
|
||||
reconnect: isReconnect,
|
||||
attempt: reconnectAttempt,
|
||||
}, "TS connect failed");
|
||||
if (!isReconnect) {
|
||||
try {
|
||||
if (session.state !== "disconnecting" && session.state !== "idle") session.transition("failed");
|
||||
|
||||
@@ -1178,7 +1178,7 @@ export function useVoiceWebSocket() {
|
||||
}
|
||||
|
||||
function closeErrorCode(code: number, reason = ""): string {
|
||||
const known = new Set(["INVALID_TARGET", "UNREACHABLE", "TIMEOUT", "SERVER_PASSWORD_REQUIRED", "INVALID_SERVER_PASSWORD", "PROTOCOL_NEGOTIATION_FAILED", "SERVER_REJECTED", "CONNECTION_FAILED"]);
|
||||
const known = new Set(["INVALID_TARGET", "HOST_NOT_FOUND", "UNREACHABLE", "CONNECTION_REFUSED", "CONNECTION_RESET", "TIMEOUT", "SERVER_PASSWORD_REQUIRED", "INVALID_SERVER_PASSWORD", "PROTOCOL_NEGOTIATION_FAILED", "SERVER_REJECTED", "CONNECTION_FAILED"]);
|
||||
if (known.has(reason)) return reason;
|
||||
if (code === 4002) return "INVALID_TARGET";
|
||||
if (code === 4004) return "SERVER_REJECTED";
|
||||
@@ -1189,7 +1189,10 @@ export function useVoiceWebSocket() {
|
||||
function connectionFailureMessage(code: string): string {
|
||||
const messages: Record<string, string> = {
|
||||
INVALID_TARGET: "TeamSpeak 服务器地址无效",
|
||||
HOST_NOT_FOUND: "找不到 TeamSpeak 服务器主机名,请检查地址",
|
||||
UNREACHABLE: "无法到达 TeamSpeak 服务器,请检查网络或地址",
|
||||
CONNECTION_REFUSED: "TeamSpeak 服务器拒绝了连接,请检查端口和服务状态",
|
||||
CONNECTION_RESET: "TeamSpeak 连接被服务器或网络重置,请稍后重试",
|
||||
TIMEOUT: "连接 TeamSpeak 超时,请检查网络或服务器状态",
|
||||
SERVER_PASSWORD_REQUIRED: "该服务器需要密码,请输入密码后重试",
|
||||
INVALID_SERVER_PASSWORD: "服务器密码错误,请重新输入",
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</div>
|
||||
<div class="operations-grid lower-operations">
|
||||
<article class="operation-card diagnostics-card"><header><div><h3>{{ tr('diagnostics') }}</h3><p>{{ tr('diagnosticsLead') }}</p></div><a class="text-link" href="/api/admin/diagnostics/report">{{ tr('downloadReport') }}</a></header><dl class="diagnostic-list"><div><dt>{{ tr('version') }}</dt><dd>{{ operations.diagnostics.version || '—' }}</dd></div><div><dt>{{ tr('runtime') }}</dt><dd>{{ operations.diagnostics.node || '—' }}</dd></div><div><dt>{{ tr('platform') }}</dt><dd>{{ operations.diagnostics.platform || '—' }} / {{ operations.diagnostics.arch || '—' }}</dd></div><div><dt>{{ tr('databaseSchema') }}</dt><dd>v{{ operations.diagnostics.schemaVersion || '—' }}</dd></div><div><dt>{{ tr('createdSessions') }}</dt><dd>{{ operations.diagnostics.createdSessions }}</dd></div></dl><button class="secondary-button" type="button" @click="downloadBackup">{{ tr('exportBackup') }}</button></article>
|
||||
<article class="operation-card logs-card"><header><div><h3>{{ tr('logViewer') }}</h3><p>{{ tr('logViewerLead') }}</p></div><span v-if="!operations.logs.available" class="muted-label">{{ tr('logsUnavailable') }}</span></header><div v-if="operations.logs.sessions.length" class="connection-list"><div class="connection-history-heading"><strong>{{ tr('connectionHistory') }}</strong><small>{{ tr('connectionHistoryLead') }}</small></div><div v-for="record in operations.logs.sessions" :key="record.id" class="connection-row"><div class="connection-person"><strong>{{ record.nickname }}</strong><small>{{ record.target }}</small><small class="connection-route">{{ connectionRoute(record) }}</small></div><div class="connection-detail"><span :class="['connection-status', record.status]">{{ connectionStatusLabel(record.status) }}</span><small>{{ record.connectedAt ? tr('connectedAt') : tr('connectionAttemptedAt') }}:{{ formatDate(record.connectedAt || record.startedAt) }}</small><small>{{ tr('duration') }}:{{ formatAge(record.durationSeconds) }}</small><small v-if="record.disconnectedAt">{{ tr('disconnectedAt') }}:{{ formatDate(record.disconnectedAt) }}</small><small v-if="record.reason">{{ tr('failureReason') }}:{{ connectionFailureText(record.reason) }}</small></div></div></div><div v-if="operations.logs.entries.length" class="log-list"><div v-for="(entry, index) in operations.logs.entries" :key="`${entry.timestamp}-${index}`" class="log-row"><span :class="['log-level', entry.level.toLowerCase()]">{{ entry.level }}</span><div><strong>{{ entry.message || '—' }}</strong><small>{{ formatDate(entry.timestamp) }}<template v-if="Object.keys(entry.context).length"> · {{ formatContext(entry.context) }}</template></small></div></div></div><div v-if="!operations.logs.sessions.length && !operations.logs.entries.length" class="operation-empty"><Icon name="activity" :size="22" /><span>{{ tr('noLogs') }}</span></div></article>
|
||||
<article class="operation-card logs-card"><header><div><h3>{{ tr('logViewer') }}</h3><p>{{ tr('logViewerLead') }}</p></div><span v-if="!operations.logs.available" class="muted-label">{{ tr('logsUnavailable') }}</span></header><div v-if="operations.logs.sessions.length" class="connection-list"><div class="connection-history-heading"><strong>{{ tr('connectionHistory') }}</strong><small>{{ tr('connectionHistoryLead') }}</small></div><div v-for="record in operations.logs.sessions" :key="record.id" class="connection-row"><div class="connection-person"><strong>{{ record.nickname }}</strong><small>{{ record.target }}</small><small class="connection-route">{{ connectionRoute(record) }}</small></div><div class="connection-detail"><span :class="['connection-status', record.status]">{{ connectionStatusLabel(record.status) }}</span><small>{{ record.connectedAt ? tr('connectedAt') : tr('connectionAttemptedAt') }}:{{ formatDate(record.connectedAt || record.startedAt) }}</small><small>{{ tr('duration') }}:{{ formatAge(record.durationSeconds) }}</small><small v-if="record.disconnectedAt">{{ tr('disconnectedAt') }}:{{ formatDate(record.disconnectedAt) }}</small><small v-if="record.reason">{{ tr('failureReason') }}:{{ connectionFailureText(record.reason) }}</small><small v-if="record.failureDetail" class="failure-detail">{{ tr('failureDetail') }}:{{ record.failureDetail }}</small></div></div></div><div v-if="operations.logs.entries.length" class="log-list"><div v-for="(entry, index) in operations.logs.entries" :key="`${entry.timestamp}-${index}`" class="log-row"><span :class="['log-level', entry.level.toLowerCase()]">{{ entry.level }}</span><div><strong>{{ entry.message || '—' }}</strong><small>{{ formatDate(entry.timestamp) }}<template v-if="Object.keys(entry.context).length"> · {{ formatContext(entry.context) }}</template></small></div></div></div><div v-if="!operations.logs.sessions.length && !operations.logs.entries.length" class="operation-empty"><Icon name="activity" :size="22" /><span>{{ tr('noLogs') }}</span></div></article>
|
||||
<article class="operation-card audit-card"><header><div><h3>{{ tr('audit') }}</h3><p>{{ tr('auditLead') }}</p></div></header><ul class="event-list"><li v-for="event in operations.audit" :key="`${event.event}-${event.createdAt}`"><span><Icon name="check" :size="14" /></span><div><strong>{{ eventName(event.event) }}</strong><small>{{ formatDate(event.createdAt) }}</small></div></li><li v-if="!operations.audit.length" class="empty-event">{{ tr('auditEmpty') }}</li></ul></article>
|
||||
</div>
|
||||
</section>
|
||||
@@ -107,7 +107,7 @@ const overview = reactive({ gateway: { version: "", uptimeSeconds: 0 }, teamSpea
|
||||
interface AdminSession { id: string; nickname: string; target: string; state: string; createdAt: string; ageSeconds: number; tsClientId: number | null; channelId: string | null; memberCount: number }
|
||||
interface ManagedInvite { id: string; target: string; channel: string; expiresAt: string; maxUses: number; useCount: number; createdAt: string; revokedAt: string | null; status: "active" | "expired" | "exhausted" | "revoked" }
|
||||
interface AdminLog { timestamp: string | null; level: string; message: string; context: Record<string, string | number | boolean> }
|
||||
interface AdminConnectionRecord { id: string; nickname: string; clientIp: string; target: string; relayName: string | null; relayTarget: string | null; startedAt: string; connectedAt: string | null; disconnectedAt: string | null; durationSeconds: number | null; status: "active" | "connecting" | "disconnected" | "failed"; reason: string | null }
|
||||
interface AdminConnectionRecord { id: string; nickname: string; clientIp: string; target: string; relayName: string | null; relayTarget: string | null; startedAt: string; connectedAt: string | null; disconnectedAt: string | null; durationSeconds: number | null; status: "active" | "connecting" | "disconnected" | "failed"; reason: string | null; failureDetail: string | null }
|
||||
const operationsLoading = ref(false);
|
||||
const terminatingSession = ref("");
|
||||
const inviteForm = reactive({ channel: "", expiresInHours: 24, maxUses: 0 });
|
||||
@@ -170,8 +170,11 @@ const copy = {
|
||||
networkReachable: "网络可达(未验证密码)",
|
||||
networkReachableHint: "Ping 成功;管理员测试不会创建额外 TeamSpeak 成员,因此未验证服务器密码。",
|
||||
failureReason: "原因",
|
||||
failureDetail: "诊断",
|
||||
hostNotFoundError: "找不到服务器",
|
||||
networkUnreachableError: "网络不可达",
|
||||
connectionRefusedError: "服务器拒绝连接",
|
||||
connectionResetError: "连接被服务器或网络重置",
|
||||
networkTimeoutError: "网络请求超时",
|
||||
serverPasswordRequiredError: "服务器需要密码",
|
||||
invalidServerPasswordError: "服务器密码错误",
|
||||
@@ -369,8 +372,11 @@ const copy = {
|
||||
networkReachable: "Network reachable (password not verified)",
|
||||
networkReachableHint: "Ping succeeded. The admin test does not create an extra TeamSpeak client, so the server password was not verified.",
|
||||
failureReason: "Reason",
|
||||
failureDetail: "Diagnostics",
|
||||
hostNotFoundError: "Server not found",
|
||||
networkUnreachableError: "Network unreachable",
|
||||
connectionRefusedError: "Connection refused",
|
||||
connectionResetError: "Connection reset",
|
||||
networkTimeoutError: "Network request timed out",
|
||||
serverPasswordRequiredError: "Server password required",
|
||||
invalidServerPasswordError: "Invalid server password",
|
||||
@@ -565,8 +571,11 @@ const germanCopy = {
|
||||
networkReachable: "Netzwerk erreichbar (Passwort nicht geprüft)",
|
||||
networkReachableHint: "Ping erfolgreich. Der Admin-Test erstellt keinen zusätzlichen TeamSpeak-Client und prüft daher das Serverpasswort nicht.",
|
||||
failureReason: "Grund",
|
||||
failureDetail: "Diagnose",
|
||||
hostNotFoundError: "Server nicht gefunden",
|
||||
networkUnreachableError: "Netzwerk nicht erreichbar",
|
||||
connectionRefusedError: "Verbindung abgelehnt",
|
||||
connectionResetError: "Verbindung zurückgesetzt",
|
||||
networkTimeoutError: "Netzwerk-Zeitüberschreitung",
|
||||
serverPasswordRequiredError: "Serverpasswort erforderlich",
|
||||
invalidServerPasswordError: "Falsches Serverpasswort",
|
||||
@@ -683,6 +692,8 @@ const testResultTitle = computed(() => {
|
||||
INVALID_TARGET: "serverAddress",
|
||||
HOST_NOT_FOUND: "hostNotFoundError",
|
||||
UNREACHABLE: "networkUnreachableError",
|
||||
CONNECTION_REFUSED: "connectionRefusedError",
|
||||
CONNECTION_RESET: "connectionResetError",
|
||||
TIMEOUT: "networkTimeoutError",
|
||||
PASSWORD_REQUIRED: "serverPasswordRequiredError",
|
||||
INVALID_PASSWORD: "invalidServerPasswordError",
|
||||
@@ -754,14 +765,18 @@ function connectionFailureText(code?: string) {
|
||||
const names: Record<string, keyof typeof copy.zh> = {
|
||||
PASSWORD_REQUIRED: "serverPasswordRequiredError",
|
||||
SERVER_PASSWORD_REQUIRED: "serverPasswordRequiredError",
|
||||
INVALID_PASSWORD: "invalidServerPasswordError",
|
||||
INVALID_SERVER_PASSWORD: "invalidServerPasswordError",
|
||||
HOST_NOT_FOUND: "hostNotFoundError",
|
||||
UNREACHABLE: "networkUnreachableError",
|
||||
TIMEOUT: "networkTimeoutError",
|
||||
INVALID_PASSWORD: "invalidServerPasswordError",
|
||||
INVALID_SERVER_PASSWORD: "invalidServerPasswordError",
|
||||
INVALID_TARGET: "serverAddress",
|
||||
HOST_NOT_FOUND: "hostNotFoundError",
|
||||
UNREACHABLE: "networkUnreachableError",
|
||||
CONNECTION_REFUSED: "connectionRefusedError",
|
||||
CONNECTION_RESET: "connectionResetError",
|
||||
TIMEOUT: "networkTimeoutError",
|
||||
PROTOCOL_NEGOTIATION_FAILED: "protocolFailureError",
|
||||
SERVER_REJECTED: "serverRejectedError",
|
||||
PING_UNAVAILABLE: "pingUnavailableError",
|
||||
PING_UNAVAILABLE: "pingUnavailableError",
|
||||
CONNECTION_FAILED: "connectionFailed",
|
||||
};
|
||||
return names[code || ""] ? tr(names[code || ""]) : errorText(code);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user