fix: make admin diagnostics clientless

This commit is contained in:
illusia committed 2026-09-06 14:18:41 +08:00
1 parent a295ff4b27
commit 166cb543a1
7 files changed
+110 -34

No files matched your search

+8 -22
View File
@@ -7,7 +7,7 @@ import { type AccessMode, type ManagedInviteRecord, type SettingsUpdate, WebSpea
import { hashAdminPassword, validateAdminPassword, verifyAdminPassword } from "../security/admin-password.js";
import { decryptSecret, encryptSecret } from "../security/secret-crypto.js";
import { probeTeamSpeak, TeamSpeakProbeError } from "../server/teamspeak-probe.js";
import { collectTeamSpeakPings, type TeamSpeakPingAttempt } from "../server/network-probe.js";
import { pingTeamSpeakHost } from "../server/network-probe.js";
import type { WebRtcAudioOptions } from "../server/webrtc-audio.js";
import { DEFAULT_WEBRTC_UDP_PORT_RANGE, WEBRTC_UDP_PORT_MAX, WEBRTC_UDP_PORT_MIN } from "../server/webrtc-config.js";
@@ -164,31 +164,17 @@ export class AdminService {
throw new AdminInputError("INVALID_TARGET", "TeamSpeak target is invalid");
}
try {
// The admin connection test uses the real TeamSpeak client protocol.
// A raw TCP connect is not valid here because TeamSpeak voice/client
// traffic is UDP; it would report 100% loss while normal voice works.
// Keep the injected probe for tests and compatibility with callers that
// explicitly need protocol discovery.
// The admin connection test must not create a temporary TeamSpeak
// client: that client becomes visible in the target channel. Use the
// WebSpeak host's ICMP route measurement instead. The injected probe is
// retained for unit tests and explicit protocol-probe callers.
if (this.probe === probeTeamSpeak) {
let lastServerName: string | null = null;
const result = await collectTeamSpeakPings(async (): Promise<TeamSpeakPingAttempt> => {
try {
const probe = await this.probe(target, password, this.logger);
lastServerName = probe.serverName;
return { ok: true, latencyMs: probe.latencyMs };
} catch (error: unknown) {
return {
ok: false,
latencyMs: null,
errorCode: error instanceof TeamSpeakProbeError ? error.code : "INTERNAL_ERROR",
};
}
}, { attempts: 4 });
const result = await pingTeamSpeakHost(target.host, { attempts: 4 });
const publicResult = {
ok: result.ok,
latencyMs: result.latencyMs ?? 0,
serverName: lastServerName,
requiresPassword: Boolean(password),
serverName: null,
requiresPassword: false,
packetLossPercent: result.packetLossPercent,
attempts: result.attempts,
successfulAttempts: result.successfulAttempts,