mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix: make admin diagnostics clientless
This commit is contained in:
1 parent
a295ff4b27
commit
166cb543a1
7 files changed
+110
-34
No files matched your search
+3
-3
@@ -8,7 +8,7 @@
|
||||
- 增加桌面端整体音量滑块,默认收起并在悬停时展开。
|
||||
- 修复伴奏音量忽大忽小的问题。
|
||||
- 增加可展开的网络性能面板,显示浏览器、WebSpeak 与 TeamSpeak 之间的延迟和丢包率。
|
||||
- 管理员连接测试改用多次网络探测并显示丢包率。
|
||||
- 管理员连接测试改用服务端多次主机 Ping 并显示丢包率,不再创建临时 TeamSpeak 客户端。
|
||||
- 统一中文、English、Deutsch 的旗帜代码语言菜单。
|
||||
- 修复 TeamSpeak 使用 TCP 探测导致的误报丢包,并修正语言菜单异常留白。
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
- Added a compact desktop master-volume slider that expands on hover.
|
||||
- Fixed accompaniment volume fluctuations.
|
||||
- Added an expandable network performance panel with latency and packet loss across the browser, WebSpeak, and TeamSpeak path.
|
||||
- Updated the administrator connection test to use repeated reachability probes and report packet loss.
|
||||
- Updated the administrator connection test to use repeated host pings, report packet loss, and avoid creating temporary TeamSpeak clients.
|
||||
- Unified the Chinese, English, and German flag/code language menu.
|
||||
- Fixed false packet-loss reports caused by probing the TeamSpeak UDP service with TCP, and corrected excess space in the language menu.
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
- Kompakten Gesamtlautstärkeregler für den Desktop ergänzt, der sich beim Überfahren öffnet.
|
||||
- Schwankende Lautstärke bei der Begleittonfreigabe behoben.
|
||||
- Aufklappbares Netzwerkleistungsfeld mit Latenz und Paketverlust zwischen Browser, WebSpeak und TeamSpeak ergänzt.
|
||||
- Verbindungstest in der Administration auf wiederholte Erreichbarkeitsprüfungen mit Paketverlustanzeige umgestellt.
|
||||
- Verbindungstest in der Administration auf wiederholte Host-Pings mit Paketverlustanzeige umgestellt, ohne temporäre TeamSpeak-Clients zu erzeugen.
|
||||
- Einheitliches Sprachmenü mit Flaggen und Sprachcodes für Chinesisch, Englisch und Deutsch ergänzt.
|
||||
- Falsche Paketverlustmeldungen durch TCP-Prüfung des UDP-Dienstes behoben und übermäßigen Leerraum im Sprachmenü korrigiert.
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ WebSpeak 面向希望通过网页提供 TeamSpeak 语音服务的个人、社区
|
||||
|
||||
| 版本 | 日期 | 摘要 |
|
||||
| --- | --- | --- |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | 增加德语支持、Telegram 群组入口、网络性能面板和丢包率测试,修复 TeamSpeak 探测误报、语言菜单留白与伴奏音量波动。 |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | 增加德语支持、Telegram 群组入口、网络性能面板和丢包率测试;管理员测试不再创建临时客户端,并修复语言菜单留白与伴奏音量波动。 |
|
||||
| [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) | 2026-09-04 | 新增桌面端伴奏、身份保持提醒和网站图标,并修复 WebRTC 下的成员独立音量。 |
|
||||
| [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) | 2026-09-04 | 修复身份保持逻辑,优化主题切换按钮。 |
|
||||
| [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) | 2026-09-03 | 修复 WebRTC 语音和频道聊天,优化管理页、日志与移动端布局。 |
|
||||
@@ -268,7 +268,7 @@ WebSpeak is built for individuals, communities, and server operators who want to
|
||||
|
||||
| Version | Date | Summary |
|
||||
| --- | --- | --- |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | Added German support, a Telegram community link, network performance and packet-loss checks; fixed false TeamSpeak probe results, language-menu spacing, and accompaniment volume fluctuations. |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | Added German support, a Telegram community link, network performance and packet-loss checks; admin tests no longer create temporary clients, and language-menu spacing and accompaniment volume fluctuations were fixed. |
|
||||
| [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) | 2026-09-04 | Added desktop accompaniment, remembered-identity guidance, and the site icon; fixed per-member volume under WebRTC. |
|
||||
| [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) | 2026-09-04 | Fixed identity persistence and refined the theme switch. |
|
||||
| [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) | 2026-09-03 | Fixed WebRTC voice and channel chat; improved administration, logs, and mobile layouts. |
|
||||
@@ -406,7 +406,7 @@ WebSpeak ist ein selbst gehosteter TeamSpeak-3-/TeamSpeak-6-Webclient und ein Sp
|
||||
|
||||
| Version | Datum | Zusammenfassung |
|
||||
| --- | --- | --- |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | Deutsche Oberfläche, Telegram-Link sowie Netzwerk- und Paketverlustprüfung hinzugefügt; falsche TeamSpeak-Messungen, Sprachmenü-Leerraum und Begleitton-Schwankungen behoben. |
|
||||
| [v0.1.7](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.7) | 2026-09-06 | Deutsche Oberfläche, Telegram-Link sowie Netzwerk- und Paketverlustprüfung hinzugefügt; Admin-Tests erzeugen keine temporären Clients mehr, außerdem wurden Sprachmenü-Leerraum und Begleitton-Schwankungen behoben. |
|
||||
| [v0.1.6](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.6) | 2026-09-04 | Desktop-Begleitton, Hinweise zur Identität und Website-Symbol hinzugefügt; individuelle Lautstärke unter WebRTC korrigiert. |
|
||||
| [v0.1.5](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.5) | 2026-09-04 | Identitätsspeicherung korrigiert und Designumschaltung verbessert. |
|
||||
| [v0.1.4](https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/releases/tag/v0.1.4) | 2026-09-03 | WebRTC und Kanalchat korrigiert; Administrationsseite, Protokolle und Mobilansicht verbessert. |
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
export type TeamSpeakPingErrorCode =
|
||||
| "HOST_NOT_FOUND"
|
||||
| "UNREACHABLE"
|
||||
@@ -25,6 +27,8 @@ export interface TeamSpeakPingResult {
|
||||
|
||||
export type TeamSpeakCommandExecutor = (command: string, timeoutMs?: number) => Promise<unknown>;
|
||||
|
||||
export type HostPingExecutor = (host: string, timeoutMs: number) => Promise<number>;
|
||||
|
||||
/**
|
||||
* Measure an already connected TeamSpeak session using the protocol's own
|
||||
* command channel. TeamSpeak voice/query traffic is UDP; a TCP connect to
|
||||
@@ -63,6 +67,27 @@ export async function collectTeamSpeakPings(
|
||||
return summarizeTeamSpeakPings(results, attempts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ping the TeamSpeak host from the WebSpeak machine without creating a
|
||||
* TeamSpeak client. This is intentionally a host/network diagnostic: the
|
||||
* TeamSpeak voice port is UDP, so a TCP socket probe is not meaningful and a
|
||||
* client-protocol probe would create an extra visible member.
|
||||
*/
|
||||
export async function pingTeamSpeakHost(
|
||||
host: string,
|
||||
options: { attempts?: number; timeoutMs?: number; execute?: HostPingExecutor } = {},
|
||||
): Promise<TeamSpeakPingResult> {
|
||||
const timeoutMs = Math.max(250, Math.min(5_000, Math.floor(options.timeoutMs ?? 1_000)));
|
||||
const execute = options.execute ?? pingHostOnce;
|
||||
return collectTeamSpeakPings(async () => {
|
||||
try {
|
||||
return { ok: true, latencyMs: await execute(host, timeoutMs) };
|
||||
} catch (error: unknown) {
|
||||
return { ok: false, latencyMs: null, errorCode: classifyProbeError(error) };
|
||||
}
|
||||
}, { attempts: options.attempts ?? 4 });
|
||||
}
|
||||
|
||||
export function summarizeTeamSpeakPings(results: TeamSpeakPingAttempt[], attempts = results.length): TeamSpeakPingResult {
|
||||
const normalizedAttempts = Math.max(1, attempts);
|
||||
const samples = results
|
||||
@@ -85,7 +110,7 @@ export function summarizeTeamSpeakPings(results: TeamSpeakPingAttempt[], attempt
|
||||
function classifyProbeError(error: unknown): TeamSpeakPingErrorCode {
|
||||
const text = error instanceof Error ? error.message : String(error);
|
||||
const lower = text.toLocaleLowerCase();
|
||||
if (/enotfound|eai_again|getaddrinfo|host not found/.test(lower)) return "HOST_NOT_FOUND";
|
||||
if (/enotfound|eai_again|getaddrinfo|host not found|unknown host|could not find host|name or service not known/.test(lower)) return "HOST_NOT_FOUND";
|
||||
if (/timeout|timed out|packet ack timeout|idle timeout/.test(lower)) return "TIMEOUT";
|
||||
if (/password|authentication|invalid.*credential/.test(lower)) return "INVALID_PASSWORD";
|
||||
if (/protocol|version|handshake|negotiat/.test(lower)) return "PROTOCOL_NEGOTIATION_FAILED";
|
||||
@@ -93,6 +118,45 @@ function classifyProbeError(error: unknown): TeamSpeakPingErrorCode {
|
||||
return "UNREACHABLE";
|
||||
}
|
||||
|
||||
function pingHostOnce(host: string, timeoutMs: number): Promise<number> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const windows = process.platform === "win32";
|
||||
const command = windows ? "ping.exe" : "ping";
|
||||
const args = windows
|
||||
? ["-n", "1", "-w", String(timeoutMs), host]
|
||||
: ["-c", "1", "-W", String(Math.max(1, Math.ceil(timeoutMs / 1_000))), host];
|
||||
const child = spawn(command, args, { stdio: ["ignore", "pipe", "pipe"] });
|
||||
let output = "";
|
||||
let settled = false;
|
||||
const finish = (callback: () => void) => {
|
||||
if (settled) return;
|
||||
settled = true;
|
||||
clearTimeout(timer);
|
||||
callback();
|
||||
};
|
||||
const timer = setTimeout(() => finish(() => {
|
||||
child.kill();
|
||||
reject(new Error("ping timeout"));
|
||||
}), timeoutMs + 250);
|
||||
child.stdout.setEncoding("utf8");
|
||||
child.stderr.setEncoding("utf8");
|
||||
child.stdout.on("data", (chunk: string) => { output += chunk; });
|
||||
child.stderr.on("data", (chunk: string) => { output += chunk; });
|
||||
child.once("error", (error) => finish(() => reject(error)));
|
||||
child.once("close", (code) => finish(() => {
|
||||
const match = output.match(/(?:time|时间)\s*[=<]\s*([\d.,]+)\s*(?:ms|毫秒)?/i);
|
||||
if (code === 0 && match) {
|
||||
const latencyMs = Number.parseFloat(match[1].replace(",", "."));
|
||||
if (Number.isFinite(latencyMs)) {
|
||||
resolve(Math.max(0, latencyMs));
|
||||
return;
|
||||
}
|
||||
}
|
||||
reject(new Error(output.trim() || `ping exited with code ${code ?? "unknown"}`));
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep a small compatibility helper for callers that only need one protocol
|
||||
* attempt. It deliberately has no host/port argument because the connected
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { collectTeamSpeakPings, pingTeamSpeakSession, summarizeTeamSpeakPings } from "../src/server/network-probe.js";
|
||||
import { collectTeamSpeakPings, pingTeamSpeakHost, pingTeamSpeakSession, summarizeTeamSpeakPings } from "../src/server/network-probe.js";
|
||||
|
||||
test("TeamSpeak latency probe uses the protocol command channel", async () => {
|
||||
let command = "";
|
||||
@@ -49,3 +49,27 @@ test("TeamSpeak ping summary reports complete loss without fake latency", () =>
|
||||
errorCode: "UNREACHABLE",
|
||||
});
|
||||
});
|
||||
|
||||
test("admin host ping measures the route without opening a TeamSpeak client", async () => {
|
||||
const calls: Array<[string, number]> = [];
|
||||
let attempt = 0;
|
||||
const result = await pingTeamSpeakHost("203.0.113.10", {
|
||||
attempts: 4,
|
||||
timeoutMs: 900,
|
||||
execute: async (host, timeoutMs) => {
|
||||
calls.push([host, timeoutMs]);
|
||||
attempt += 1;
|
||||
if (attempt === 3) throw new Error("ping timeout");
|
||||
return attempt * 2;
|
||||
},
|
||||
});
|
||||
assert.deepEqual(calls, [
|
||||
["203.0.113.10", 900],
|
||||
["203.0.113.10", 900],
|
||||
["203.0.113.10", 900],
|
||||
["203.0.113.10", 900],
|
||||
]);
|
||||
assert.equal(result.ok, true);
|
||||
assert.equal(result.packetLossPercent, 25);
|
||||
assert.equal(result.latencyMs, 4);
|
||||
});
|
||||
@@ -157,7 +157,7 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
|
||||
align-items: start;
|
||||
align-content: start;
|
||||
gap: 3px;
|
||||
width: 218px;
|
||||
width: 280px;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
padding: 7px;
|
||||
@@ -217,12 +217,12 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
|
||||
}
|
||||
|
||||
.language-option strong {
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.language-option small {
|
||||
color: #91a19c;
|
||||
font-size: 9px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ onUnmounted(() => document.removeEventListener("pointerdown", onDocumentPointerD
|
||||
}
|
||||
|
||||
.language-dropdown {
|
||||
width: 200px;
|
||||
width: 250px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1884,6 +1884,8 @@ function stopWhisperTalk(): void {
|
||||
.join-page { min-height: 100dvh; display: flex; flex-direction: column; overflow: hidden; background: #f7f9f8; }
|
||||
.join-header, .join-content, .join-footer { width: min(1240px, calc(100% - 64px)); margin: 0 auto; }
|
||||
.join-header, .join-content, .join-footer { position: relative; z-index: 1; }
|
||||
.join-header { z-index: 10; }
|
||||
.join-header .language-switcher { z-index: 50; }
|
||||
.join-header { min-height: 84px; display: flex; align-items: center; justify-content: space-between; }
|
||||
.brand-lockup { display: flex; align-items: center; gap: 12px; }
|
||||
.brand-mark, .rail-logo { display: grid; place-items: center; color: #fff; background: #006a64; box-shadow: 0 8px 18px rgba(0, 106, 100, .15); }
|
||||
|
||||
Reference in new issue
Block a user