mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
fix(voice): read server banner from client handshake
This commit is contained in:
1 parent
398a4d6c7f
commit
6c57868903
5 files changed
+39
-33
No files matched your search
@@ -12,7 +12,7 @@
|
||||
|
||||
## 当前检查点(2026-10-11)
|
||||
|
||||
- KAAK 当前源码版本为 3.1.68;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。
|
||||
- KAAK 当前源码版本为 3.1.68;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用客户端握手携带的真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。
|
||||
- 语音布局、成员卡、频道/聊天收起、音量反馈、性能卡片、设备下拉交互和字体层级均已有对应实现;音频设置标签为 KOOK 已记录的 14px/400,表单卡与字段行按实测宽度/行高调整。
|
||||
- 直接观察记录覆盖语音侧栏/频道树、成员卡与悬停姓名、当前语音频道聊天开合、语音坞、音频设置字体及设备列表尺寸和状态。独立文字频道不复刻;KOOK 的付费分享呈现不复刻,WebSpeak 自带屏幕分享入口和播放器保留。
|
||||
- 设备选择菜单已按皮肤实际高度限位;KAAK 音频滑杆、性能反馈、字体和成员卡交互均有对应实现。3.1.66 完整验证为 680/680,服务端 TypeScript 构建、前端类型检查和生产构建通过。用户已明确 KOOK 音乐语音频道附带聊天默认收起、普通语音频道默认展开。TeamSpeak `ChannelInfo` 与皮肤上下文没有音乐类别字段;当前实现按频道分别记住聊天开合,尚不能判断从未设置过的频道是否为音乐频道。
|
||||
@@ -482,8 +482,16 @@
|
||||
## 本轮修改节点(2026-10-11,KAAK 3.1.68 服务器横幅与欢迎语)
|
||||
|
||||
- 目标:按网页示例为语音侧栏增加服务器横幅和欢迎内容,数据来自当前 TeamSpeak 虚拟服务器;不添加示例站点的运营内容或无效控件。
|
||||
- 数据与安全边界:宿主读取 `serverinfo` 的公开横幅 URL 和欢迎语;限制 URL 长度并只接受无凭据的 HTTP(S) 地址,欢迎语限长后作为纯文本显示。字段仅进入 WebSpeak 的公共服务器信息消息,不将连接目标或身份材料交给皮肤代码。读取失败或字段为空时隐藏相应内容。
|
||||
- 数据与安全边界:宿主从 SDK 提供的 TeamSpeak `initserver` 握手信息读取公开横幅 URL 和欢迎语;限制 URL 长度并只接受无凭据的 HTTP(S) 地址,欢迎语限长后作为纯文本显示。字段仅进入 WebSpeak 的公共服务器信息消息,不将连接目标或身份材料交给皮肤代码。字段为空时隐藏相应内容。
|
||||
- 界面与兼容:新增受信任的 `voice.server-banner` 宿主组件,放在服务器头部和频道树之间;皮肤可调整图片、欢迎卡片、图标、标题和正文部件。样式限制在 KAAK 作用域,其他皮肤保持现有表现。
|
||||
- 版本与分发包:KAAK 升至 3.1.68;更新组件定义、目录、开发文档、示例包及内置 `.wskin`。
|
||||
- 验证:皮肤包构建与完整 `npm run verify` 通过(682/682 测试,服务端 TypeScript、前端类型检查和 Vite 生产构建通过);`git diff --check` 通过。
|
||||
- 当前状态:实现及自动验证完成,按既有指示提交并推送到 `dev`。
|
||||
|
||||
## 本轮修复节点(2026-10-11,普通客户端权限下读取服务器横幅)
|
||||
|
||||
- 用户反馈:TeamSpeak 桌面客户端能显示已设置的横幅图片和欢迎语,WebSpeak 页面却没有横幅。
|
||||
- 根因:WebSpeak 曾在连接后额外执行 `serverinfo`;实际测试连接返回“权限不足”,导致 SDK 查询失败后字段被置空。TeamSpeak 连接握手 `initserver` 已包含横幅 URL 和欢迎语,SDK 之前只保留了服务器名与图标。
|
||||
- 修改范围:SDK 将握手中的横幅 URL、欢迎语加入公开 `ServerInfo`;WebSpeak 改读握手字段并继续做 URL/长度校验,删除依赖额外 `serverinfo` 权限的读取。没有改皮肤布局或图片样式。
|
||||
- 实测:用已授权测试连接确认握手能提供横幅 URL 和欢迎语;本次 `serverinfo` 查询确实因权限不足被拒绝。测试输出只记录字段是否存在、长度和协议,不记录 URL 或服务器地址。
|
||||
- 提交方向:SDK 与 WebSpeak 分别提交推送;部署后在 3040 复核连接和页面响应。
|
||||
Generated
+2
-2
@@ -10,7 +10,7 @@
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#56d426d24852c39439f7bfe1d5850b574a1b0811",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#956d29c9e7199736aa90a3c9fe5b20fb9ead5a7f",
|
||||
"express": "^5.2.1",
|
||||
"pino": "^10.3.1",
|
||||
"postcss": "^8.5.29",
|
||||
@@ -66,7 +66,7 @@
|
||||
},
|
||||
"node_modules/@echosixhiya/teamspeak-client": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#2ce968e07a4384cdc873cc368b5b9d25de0b3c52",
|
||||
"resolved": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#956d29c9e7199736aa90a3c9fe5b20fb9ead5a7f",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@noble/curves": "^2.0.1"
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.10.0",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#2ce968e07a4384cdc873cc368b5b9d25de0b3c52",
|
||||
"@echosixhiya/teamspeak-client": "git+https://github.com/EchoSixHIYA/teamspeak-js.git#956d29c9e7199736aa90a3c9fe5b20fb9ead5a7f",
|
||||
"express": "^5.2.1",
|
||||
"pino": "^10.3.1",
|
||||
"postcss": "^8.5.29",
|
||||
|
||||
@@ -18,8 +18,9 @@ const transfer = { size: 6n };
|
||||
class SdkStub extends EventEmitter {
|
||||
inputCommands: string[] = [];
|
||||
fileTransfers: Array<{ channelId: bigint; path: string; password: string }> = [];
|
||||
serverInfo: { name: string; iconId: number | null } | null = { name: "兄弟们的teamspeak", iconId: 123456 };
|
||||
serverPresentationRows: Array<Record<string, string>> = [];
|
||||
serverInfo: { name: string; iconId: number | null; hostBannerGfxUrl: string | null; welcomeMessage: string } | null = {
|
||||
name: "兄弟们的teamspeak", iconId: 123456, hostBannerGfxUrl: null, welcomeMessage: "",
|
||||
};
|
||||
inputUpdate = async (_command: string): Promise<void> => {};
|
||||
async execCommand(command: string) { this.inputCommands.push(command); await this.inputUpdate(command); }
|
||||
initialized = 0;
|
||||
@@ -29,7 +30,7 @@ class SdkStub extends EventEmitter {
|
||||
download = async (destination: Writable) => { destination.write(Buffer.from("GIF89a")); };
|
||||
execCommandWithResponse(command = "") {
|
||||
this.inputCommands.push(command);
|
||||
return command === "serverinfo" ? Promise.resolve(this.serverPresentationRows) : this.metadata();
|
||||
return this.metadata();
|
||||
}
|
||||
async fileTransferInitDownload(channelId: bigint, path: string, password: string) {
|
||||
this.initialized++;
|
||||
@@ -67,26 +68,30 @@ test("server info uses the name and icon id captured by the SDK handshake", asyn
|
||||
const f = fixture();
|
||||
assert.deepEqual(await f.client.getServerInfo(), { name: "兄弟们的teamspeak", iconId: 123456 });
|
||||
assert.deepEqual(f.sdk.inputCommands, [], "server identity does not issue a ServerQuery-only command over the client session");
|
||||
f.sdk.serverInfo = { name: "No icon", iconId: null };
|
||||
f.sdk.serverInfo = { name: "No icon", iconId: null, hostBannerGfxUrl: null, welcomeMessage: "" };
|
||||
assert.deepEqual(await f.client.getServerInfo(), { name: "No icon", iconId: null });
|
||||
});
|
||||
|
||||
test("server presentation reads bounded public banner and welcome fields", async () => {
|
||||
const f = fixture();
|
||||
f.sdk.serverPresentationRows = [{
|
||||
virtualserver_hostbanner_gfx_url: "https://assets.example.invalid/teamspeak/banner.png",
|
||||
virtualserver_welcomemessage: "欢迎来到服务器!\n请遵守频道规则。",
|
||||
}];
|
||||
f.sdk.serverInfo = {
|
||||
name: "兄弟们的teamspeak",
|
||||
iconId: 123456,
|
||||
hostBannerGfxUrl: "https://assets.example.invalid/teamspeak/banner.png",
|
||||
welcomeMessage: "欢迎来到服务器!\n请遵守频道规则。",
|
||||
};
|
||||
assert.deepEqual(await f.client.getServerPresentation(), {
|
||||
bannerUrl: "https://assets.example.invalid/teamspeak/banner.png",
|
||||
welcomeMessage: "欢迎来到服务器!\n请遵守频道规则。",
|
||||
});
|
||||
assert.deepEqual(f.sdk.inputCommands, ["serverinfo"]);
|
||||
assert.deepEqual(f.sdk.inputCommands, [], "server presentation comes from the connection handshake without extra permissions");
|
||||
|
||||
f.sdk.serverPresentationRows = [{
|
||||
virtualserver_hostbanner_gfx_url: "javascript:alert(1)",
|
||||
virtualserver_welcomemessage: "x".repeat(5_000),
|
||||
}];
|
||||
f.sdk.serverInfo = {
|
||||
name: "兄弟们的teamspeak",
|
||||
iconId: null,
|
||||
hostBannerGfxUrl: "javascript:alert(1)",
|
||||
welcomeMessage: "x".repeat(5_000),
|
||||
};
|
||||
const sanitized = await f.client.getServerPresentation();
|
||||
assert.equal(sanitized.bannerUrl, null);
|
||||
assert.equal(sanitized.welcomeMessage.length, 4_096);
|
||||
|
||||
+8
-15
@@ -295,7 +295,8 @@ export class TSClient extends EventEmitter {
|
||||
if (this.client !== client || !this.connected || this.connectionGeneration !== generation) {
|
||||
throw new Error("TeamSpeak session changed while reading server information");
|
||||
}
|
||||
return client.serverInfo ?? { name: "", iconId: null };
|
||||
const info = client.serverInfo;
|
||||
return info ? { name: info.name, iconId: info.iconId } : { name: "", iconId: null };
|
||||
}
|
||||
|
||||
/** Read only the public banner and welcome message from the active virtual server. */
|
||||
@@ -305,20 +306,12 @@ export class TSClient extends EventEmitter {
|
||||
const generation = this.connectionGeneration;
|
||||
const isCurrent = () => this.client === client && this.connected && this.connectionGeneration === generation;
|
||||
const empty: TSClientServerPresentation = { bannerUrl: null, welcomeMessage: "" };
|
||||
try {
|
||||
const rows = await client.execCommandWithResponse("serverinfo", 5_000);
|
||||
if (!isCurrent()) throw new Error("TeamSpeak session changed while reading server presentation");
|
||||
const row = rows[0] ?? {};
|
||||
return {
|
||||
bannerUrl: normalizeTeamSpeakBannerUrl(row.virtualserver_hostbanner_gfx_url),
|
||||
welcomeMessage: normalizeTeamSpeakWelcomeMessage(row.virtualserver_welcomemessage),
|
||||
};
|
||||
} catch (error: unknown) {
|
||||
if (!isCurrent()) throw error;
|
||||
// Some servers restrict serverinfo. Keep the voice connection usable and
|
||||
// omit the optional presentation when the fields cannot be read.
|
||||
return empty;
|
||||
}
|
||||
const info = client.serverInfo;
|
||||
if (!isCurrent() || !info) return empty;
|
||||
return {
|
||||
bannerUrl: normalizeTeamSpeakBannerUrl(info.hostBannerGfxUrl),
|
||||
welcomeMessage: normalizeTeamSpeakWelcomeMessage(info.welcomeMessage),
|
||||
};
|
||||
}
|
||||
|
||||
/** Download the public virtual-server icon using TeamSpeak's normal file-transfer port. */
|
||||
|
||||
Reference in new issue
Block a user