diff --git a/docs/KAAK-CLONE-WORKLOG.zh-CN.md b/docs/KAAK-CLONE-WORKLOG.zh-CN.md index 9fa24a3..0efdfd3 100644 --- a/docs/KAAK-CLONE-WORKLOG.zh-CN.md +++ b/docs/KAAK-CLONE-WORKLOG.zh-CN.md @@ -10,9 +10,9 @@ - 相关节点累积后统一验证,避免每个小改动都重跑完整验证。 - 记录中不放服务器地址、密码、密钥、成员名单、聊天内容或其他隐私数据。 -## 当前检查点(2026-10-11) - -- KAAK 当前源码版本为 3.1.76;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用客户端握手携带的真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;降噪关闭状态新增红色斜杠提示;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。频道树成员行与成员卡片右键均使用 KOOK 深色浮层格式,菜单项和行为仍为 WebSpeak 原有操作;频道树成员行支持悬停反馈和跨频道拖放移动。屏幕共享播放器限定在中央语音舞台内,具有明确响应高度;成员卡片使用播放器下方剩余区域。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。 +## 当前检查点(2026-10-12) + +- KAAK 当前源码版本为 3.1.77;最近新增 TeamSpeak 服务器横幅与欢迎语展示,沿用客户端握手携带的真实服务器信息并在缺少内容时隐藏卡片;同时保留真实服务器名与收藏/历史快速切换入口,并以宿主频道树呈现嵌套语音频道、频道成员头像和状态。服务器显示名过滤像地址的内容;快速切换不向皮肤暴露连接目标。控制坞保留 WebSpeak 现有分享、降噪、伴奏、麦克风、扬声器和设置操作;降噪关闭状态新增红色斜杠提示;已移除无效的录制占位,仅保留屏幕共享和伴奏入口。频道树成员行与成员卡片右键均使用 KOOK 深色浮层格式,菜单项和行为仍为 WebSpeak 原有操作;频道树成员行支持悬停反馈和跨频道拖放移动。屏幕共享播放器限定在中央语音舞台内,具有明确响应高度;成员卡片使用播放器下方剩余区域。3.1.55 的横向单行方案已被用户明确否决,不再沿用;3.1.53 已移除皮肤布局运行时对宿主控件强加的 44px 尺寸。 - 语音布局、成员卡、频道/聊天收起、音量反馈、性能卡片、设备下拉交互和字体层级均已有对应实现;音频设置标签为 KOOK 已记录的 14px/400,表单卡与字段行按实测宽度/行高调整。 - 直接观察记录覆盖语音侧栏/频道树、成员卡与悬停姓名、当前语音频道聊天开合、语音坞、音频设置字体及设备列表尺寸和状态。独立文字频道不复刻;KOOK 的付费分享呈现不复刻,WebSpeak 自带屏幕分享入口和播放器保留。 - 设备选择菜单已按皮肤实际高度限位;KAAK 音频滑杆、性能反馈、字体和成员卡交互均有对应实现。3.1.66 完整验证为 680/680,服务端 TypeScript 构建、前端类型检查和生产构建通过。用户已明确 KOOK 音乐语音频道附带聊天默认收起、普通语音频道默认展开。TeamSpeak `ChannelInfo` 与皮肤上下文没有音乐类别字段;当前实现按频道分别记住聊天开合,尚不能判断从未设置过的频道是否为音乐频道。 @@ -600,3 +600,10 @@ - 根因:播放器组件在非全屏状态会以内联 `aspect-ratio: auto` 覆盖皮肤 CSS;KAAK 先前设置 `height: auto`,而视频与控件为绝对定位,因此舞台失去可计算高度。 - 修复范围:仅 KAAK 皮肤显式设定桌面和窄屏播放器高度,保持视频 `object-fit: contain` 和黑边;保留播放器与成员卡片分区布局,不改宿主播放器逻辑或其他皮肤。KAAK 升至 3.1.76。 - 验证:示例和内置 `.wskin` 已重建;高度断言和完整 `npm run verify` 通过(690/690 测试、服务端构建、前端类型检查与 Vite 生产构建);`git diff --check` 通过。3040 的新版 KAAK 包返回 HTTP 200(21,950 字节);未做活动语音会话的浏览器目视验收。 + +## 本轮频道图标回归修复(2026-10-12) + +- 用户反馈:频道树的上锁频道仍显示喇叭,当前频道标题仍显示半圆图标。 +- 根因:TeamSpeak 初始频道查询未请求 flags,密码标记无法进入共享频道模型;KAAK 当前频道标题使用皮肤模板中的固定半圆字符。此外,已安装的 KAAK 包按皮肤版本复用,本地 3.1.76 包会覆盖服务端更新后的同版本包。 +- 修复:初始查询请求 `channellist -flags`,将密码状态送到树形频道图标;普通成员栏也按同一状态显示锁或喇叭。KAAK 标题符号换为喇叭,并升至 3.1.77 触发本地包更新。 +- 验证:完整验证通过(692/692 测试、服务端构建、前端类型检查和生产构建);示例皮肤包与内置包同步。3040 已重启并返回健康状态;未在浏览器中进行目视验收。 diff --git a/docs/examples/KAAK-VOICE.md b/docs/examples/KAAK-VOICE.md index b06721a..4eb19ba 100644 --- a/docs/examples/KAAK-VOICE.md +++ b/docs/examples/KAAK-VOICE.md @@ -30,7 +30,7 @@ The owner authorized inspection of the first two voice rooms in the KOOK server. ## Components and permissions -The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, cached profile-avatar display inside the trusted member-card widget, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen-share status/read/control. Its member-card widget explicitly enables share status and watch actions; the KAAK dock uses the host's screen-share control. The performance panel hides only share transport metrics. The host renders trusted connection, language, skin, and audio controls. KAAK 3.1.76 keeps the shared-screen player inside the central voice-stage column with an explicit responsive height, so the player cannot collapse when the host applies its inline video sizing; member cards scroll in the remaining area. The full source image remains visible with black letterboxing. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control. +The connection page and voice workspace are full-page declarative surfaces in [components.json](./kaak-voice/components.json). The voice surface requests only the capabilities it uses: visible server shortcuts, channel and member data, cached profile-avatar display inside the trusted member-card widget, channel joining, channel chat, voice status, microphone/output controls, whisper controls, disconnect, and screen-share status/read/control. Its member-card widget explicitly enables share status and watch actions; the KAAK dock uses the host's screen-share control. The performance panel hides only share transport metrics. The host renders trusted connection, language, skin, and audio controls. KAAK 3.1.77 keeps the shared-screen player inside the central voice-stage column with an explicit responsive height, so the player cannot collapse when the host applies its inline video sizing; member cards scroll in the remaining area. The full source image remains visible with black letterboxing. It rechecks permissions and connection state when each action runs; approval is local to this skin version and can be revoked from the host access control. The server header uses the live, privacy-filtered TeamSpeak server label and a trusted `voice.server-switcher` menu backed by favorites and recent connections. Its click handler reuses WebSpeak's existing connection flow with an opaque local ID; addresses and credentials never enter skin data. The left panel uses the trusted `voice.channel-tree` widget to retain TeamSpeak channel nesting, member counts and capacity, available avatars, and mute/speaking/away states. Expanding a branch is local UI state, a single click selects a channel, and double-click joins it. With `memberActions` enabled, right-clicking another member row opens WebSpeak's existing host-owned action menu. With `memberDragDrop` enabled, another member can be dragged onto a different channel row; the member row and target channel receive visual feedback, and the host reuses its existing move-client operation. Both options default off for other skins. The skin does not add KOOK's separate text-channel list. diff --git a/docs/examples/kaak-voice.wskin b/docs/examples/kaak-voice.wskin index 2439c92..2a54d99 100644 Binary files a/docs/examples/kaak-voice.wskin and b/docs/examples/kaak-voice.wskin differ diff --git a/docs/examples/kaak-voice/components.json b/docs/examples/kaak-voice/components.json index 810b462..1635157 100644 --- a/docs/examples/kaak-voice/components.json +++ b/docs/examples/kaak-voice/components.json @@ -638,7 +638,7 @@ }, "children": [ { - "text": "◖" + "text": "🔊︎" } ] }, diff --git a/docs/examples/kaak-voice/manifest.json b/docs/examples/kaak-voice/manifest.json index 4e87c65..9704cf5 100644 --- a/docs/examples/kaak-voice/manifest.json +++ b/docs/examples/kaak-voice/manifest.json @@ -3,7 +3,7 @@ "packageType": "open-skin", "id": "community.kaak-voice", "name": "KAAK", - "version": "3.1.76", + "version": "3.1.77", "author": "WebSpeak Project", "license": "AGPL-3.0-only", "description": "A KOOK-inspired voice workspace with a searchable server header, TeamSpeak banner and welcome message, nested channel members, attached channel chat, and a compact WebSpeak audio dock.", diff --git a/docs/examples/kaak-voice/skin.css b/docs/examples/kaak-voice/skin.css index 58cb576..9f5b79b 100644 --- a/docs/examples/kaak-voice/skin.css +++ b/docs/examples/kaak-voice/skin.css @@ -756,7 +756,7 @@ } [data-ws-plugin-part="kaak-workspace.voice-stage-heading-item"] { display: contents; } -[data-ws-plugin-part="kaak-workspace.voice-stage-glyph"] { color: var(--skin-kaak-muted); font-size: 17px; } +[data-ws-plugin-part="kaak-workspace.voice-stage-glyph"] { color: var(--skin-kaak-muted); font-family: "Segoe UI Symbol", "Apple Symbols", sans-serif; font-size: 15px; filter: grayscale(1); } [data-ws-plugin-part="kaak-workspace.voice-stage-title"] { min-width: 0; margin: 0; overflow: hidden; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; } [data-ws-plugin-part="kaak-workspace.voice-stage-member-count"] { color: var(--skin-kaak-muted); font-size: 12px; } [data-ws-plugin-part="kaak-workspace.voice-stage-member-count"]::before { content: "-"; margin-right: 6px; color: var(--skin-kaak-dim); } diff --git a/src/server/channel-capacity.test.ts b/src/server/channel-capacity.test.ts index 83bb049..6069328 100644 --- a/src/server/channel-capacity.test.ts +++ b/src/server/channel-capacity.test.ts @@ -1,6 +1,11 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { applyChannelCapacityNotification, parseChannelCapacities } from "./channel-capacity.js"; +import { + applyChannelCapacityNotification, + applyChannelPasswordProtectionNotification, + parseChannelCapacities, + parseChannelPasswordProtections, +} from "./channel-capacity.js"; test("channel capacity rows keep finite limits and distinguish unlimited channels", () => { const capacities = parseChannelCapacities([ @@ -35,3 +40,25 @@ test("channel capacity notifications merge edits and remove deleted channels", ( applyChannelCapacityNotification("notifychanneldeleted", { cid: "2" }, capacities); assert.equal(capacities.has(2n), false); }); + +test("channel password protection is parsed as a public boolean and tracks channel edits", () => { + const protections = parseChannelPasswordProtections([ + { cid: "1", channel_flag_password: "1" }, + { cid: "2", channel_flag_password: "0" }, + { cid: "3", channel_flag_password: "unknown" }, + { cid: "18446744073709551616", channel_flag_password: "1" }, + ]); + assert.deepEqual([...protections], [[1n, true], [2n, false]]); + + assert.deepEqual( + applyChannelPasswordProtectionNotification("notifychanneledited", { cid: "1", channel_flag_password: "0" }, protections), + { channelId: 1n, passwordProtected: false }, + ); + assert.deepEqual( + applyChannelPasswordProtectionNotification("notifychannelcreated", { cid: "4", channel_flag_password: "1" }, protections), + { channelId: 4n, passwordProtected: true }, + ); + assert.equal(applyChannelPasswordProtectionNotification("notifychanneldeleted", { cid: "4" }, protections), null); + assert.equal(protections.has(4n), false); + assert.equal(protections.has(3n), false, "unknown flag values are not interpreted as unlocked"); +}); diff --git a/src/server/channel-capacity.ts b/src/server/channel-capacity.ts index b98d859..c6209d0 100644 --- a/src/server/channel-capacity.ts +++ b/src/server/channel-capacity.ts @@ -3,6 +3,10 @@ export interface ChannelCapacity { maxClientsLimited: boolean; } +export interface ChannelPasswordProtection { + passwordProtected: boolean; +} + const UINT64_MAX = 18_446_744_073_709_551_615n; function parseChannelId(value: string | undefined): bigint | null { @@ -34,6 +38,44 @@ export function parseChannelCapacities(rows: readonly Record[]): return capacities; } +/** The password flag reveals whether a password is required, never the password itself. */ +export function parseChannelPasswordProtection(row: Record): boolean | null { + if (row.channel_flag_password === "1") return true; + if (row.channel_flag_password === "0") return false; + return null; +} + +export function parseChannelPasswordProtections(rows: readonly Record[]): Map { + const protections = new Map(); + for (const row of rows) { + const id = parseChannelId(row.cid); + const passwordProtected = parseChannelPasswordProtection(row); + if (id !== null && passwordProtected !== null) protections.set(id, passwordProtected); + } + return protections; +} + +/** Keep the password-required flag current as channels are created or edited. */ +export function applyChannelPasswordProtectionNotification( + name: string, + params: Record, + protections: Map, +): { channelId: bigint; passwordProtected: boolean } | null { + const id = parseChannelId(params.cid); + if (id === null) return null; + + if (name === "notifychanneldeleted") { + protections.delete(id); + return null; + } + if (name !== "notifychannelcreated" && name !== "notifychanneledited") return null; + + const passwordProtected = parseChannelPasswordProtection(params); + if (passwordProtected === null) return null; + protections.set(id, passwordProtected); + return { channelId: id, passwordProtected }; +} + /** Keep capacity metadata in step with TeamSpeak's incremental channel events. */ export function applyChannelCapacityNotification( name: string, diff --git a/src/server/directory-view.test.ts b/src/server/directory-view.test.ts index 7fa1f31..735b006 100644 --- a/src/server/directory-view.test.ts +++ b/src/server/directory-view.test.ts @@ -5,7 +5,7 @@ import { mapChannelTree, normalizeDirectorySnapshot } from "./directory-view.js" import { parseServerMessage } from "../shared/server-messages.js"; const directory = (): TSDirectorySnapshot => ({ - channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Lobby", description: "" }, { id: 18446744073709551615n, parentID: 1n, order: 1n, name: "Room", description: "", maxClients: 10, maxClientsLimited: true }], + channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Lobby", description: "" }, { id: 18446744073709551615n, parentID: 1n, order: 1n, name: "Room", description: "", maxClients: 10, maxClientsLimited: true, passwordProtected: true }], clients: [{ id: 2, channelID: 1n, nickname: "Member", uid: "uid-2", type: 0, serverGroups: [], away: true, inputMuted: true }], }); @@ -38,5 +38,6 @@ test("directory presentation survives JSON transport with large IDs, member flag assert.equal(decoded.channels[0]?.members?.[0]?.avatar, "data:image/png;base64,test"); assert.equal(decoded.channels[1]?.maxClients, 10); assert.equal(decoded.channels[1]?.maxClientsLimited, true); + assert.equal(decoded.channels[1]?.passwordProtected, true); assert.deepEqual(decoded.channels[1]?.members, []); }); diff --git a/src/server/directory-view.ts b/src/server/directory-view.ts index b21d62e..0c87ff8 100644 --- a/src/server/directory-view.ts +++ b/src/server/directory-view.ts @@ -11,6 +11,7 @@ export function mapChannelTree(snapshot: TSDirectorySnapshot, avatarCache = new ...(typeof channel.maxClients === "number" && typeof channel.maxClientsLimited === "boolean" ? { maxClients: channel.maxClients, maxClientsLimited: channel.maxClientsLimited } : {}), + ...(typeof channel.passwordProtected === "boolean" ? { passwordProtected: channel.passwordProtected } : {}), members: snapshot.clients .filter((client) => client.channelID === channel.id) .map((client) => { diff --git a/src/server/session-events.test.ts b/src/server/session-events.test.ts index 9be6138..4b9db8a 100644 --- a/src/server/session-events.test.ts +++ b/src/server/session-events.test.ts @@ -98,6 +98,24 @@ test("channel changes preserve large identifiers and publish only actual create, assert.equal(f.events.length, 0); }); +test("live channel password changes update and publish the lock state without a full tree refresh", t => { + const f = fixture(t); + f.client.emit("directorySnapshot", snapshot(member(1))); + f.coordinator.syncSelf(); f.phase.published = true; + + f.client.emit("channelPasswordProtectionChanged", { channelId: 2n, passwordProtected: true }); + assert.equal(f.state.channelTree.find(item => item.id === "2")?.passwordProtected, true); + let published = f.messages.at(-1); + assert.equal(published?.type, "channelList"); + if (published?.type === "channelList") assert.equal(published.channels.find(item => item.id === "2")?.passwordProtected, true); + + f.client.emit("channelPasswordProtectionChanged", { channelId: 2n, passwordProtected: false }); + assert.equal(f.state.channelTree.find(item => item.id === "2")?.passwordProtected, false); + published = f.messages.at(-1); + assert.equal(published?.type, "channelList"); + if (published?.type === "channelList") assert.equal(published.channels.find(item => item.id === "2")?.passwordProtected, false); +}); + test("reset rejects backoff events and close detaches only owned listeners including captured callbacks", t => { const f = fixture(t); f.client.emit("directorySnapshot", snapshot(member(1), member(2))); diff --git a/src/server/session-events.ts b/src/server/session-events.ts index 9b748e8..81b2350 100644 --- a/src/server/session-events.ts +++ b/src/server/session-events.ts @@ -23,6 +23,7 @@ interface SdkEvents { clientMoved: { id: number; targetChannelID?: bigint }; clientUpdated: TSDirectoryClient; directoryClientsSnapshot: TSDirectoryClient[]; + channelPasswordProtectionChanged: { channelId: bigint; passwordProtected: boolean }; rawNotification: TSRawNotification; voiceData: TSVoiceData; textMessage: TSChatMessage; @@ -135,6 +136,14 @@ export class SessionEventCoordinator { this.refresh(); this.publishDirectory(); }); + this.listenDirectory("channelPasswordProtectionChanged", change => { + const channelId = String(change.channelId); + if (!state.channelTree.some(channel => channel.id === channelId)) return; + state.channelTree = state.channelTree.map(channel => channel.id === channelId + ? { ...channel, passwordProtected: change.passwordProtected } + : channel); + this.publishDirectory(); + }); this.listen("rawNotification", options.onNotification); this.listen("voiceData", options.onVoice); this.listen("textMessage", message => { diff --git a/src/server/ts-client.test.ts b/src/server/ts-client.test.ts index ffa4c5a..854abf1 100644 --- a/src/server/ts-client.test.ts +++ b/src/server/ts-client.test.ts @@ -313,14 +313,14 @@ test("a current avatar download preserves its bytes and rejects a mismatched ide assert.equal(f.sdk.downloaded, 1); }); -test("public channel capacity survives directory snapshots and follows channel edits", () => { +test("public channel metadata survives directory snapshots and follows channel edits", () => { const f = fixture(); - const snapshots: Array<{ channels: Array<{ id: bigint; maxClients?: number; maxClientsLimited?: boolean }>; clients: unknown[] }> = []; + const snapshots: Array<{ channels: Array<{ id: bigint; maxClients?: number; maxClientsLimited?: boolean; passwordProtected?: boolean }>; clients: unknown[] }> = []; f.client.on("directorySnapshot", snapshot => snapshots.push(snapshot)); f.sdk.emit("rawNotification", { name: "notifychannelcreated", - params: { cid: "1", channel_maxclients: "10", channel_flag_maxclients_unlimited: "0" }, + params: { cid: "1", channel_maxclients: "10", channel_flag_maxclients_unlimited: "0", channel_flag_password: "1" }, }); f.sdk.emit("directorySnapshot", { channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Room", description: "" }], @@ -328,6 +328,7 @@ test("public channel capacity survives directory snapshots and follows channel e }); assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, 10); assert.equal(snapshots.at(-1)?.channels[0]?.maxClientsLimited, true); + assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, true); f.sdk.emit("rawNotification", { name: "notifychanneledited", params: { cid: "1", channel_maxclients: "12" } }); f.sdk.emit("directorySnapshot", { @@ -336,6 +337,14 @@ test("public channel capacity survives directory snapshots and follows channel e }); assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, 12); assert.equal(snapshots.at(-1)?.channels[0]?.maxClientsLimited, true); + assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, true, "partial edits retain the previously reported password flag"); + + f.sdk.emit("rawNotification", { name: "notifychanneledited", params: { cid: "1", channel_flag_password: "0" } }); + f.sdk.emit("directorySnapshot", { + channels: [{ id: 1n, parentID: 0n, order: 0n, name: "Room", description: "" }], + clients: [], + }); + assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, false); f.sdk.emit("rawNotification", { name: "notifychanneldeleted", params: { cid: "1" } }); f.sdk.emit("directorySnapshot", { @@ -343,6 +352,7 @@ test("public channel capacity survives directory snapshots and follows channel e clients: [], }); assert.equal(snapshots.at(-1)?.channels[0]?.maxClients, undefined); + assert.equal(snapshots.at(-1)?.channels[0]?.passwordProtected, undefined); }); test("a retired SDK client's disconnect cannot invalidate a current avatar request", async () => { diff --git a/src/server/ts-client.ts b/src/server/ts-client.ts index 621fab5..3829482 100644 --- a/src/server/ts-client.ts +++ b/src/server/ts-client.ts @@ -20,7 +20,14 @@ import { describeTeamSpeakError, normalizeTeamSpeakError, normalizeTeamSpeakKick 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"; -import { applyChannelCapacityNotification, parseChannelCapacities, type ChannelCapacity } from "./channel-capacity.js"; +import { + applyChannelCapacityNotification, + applyChannelPasswordProtectionNotification, + parseChannelCapacities, + parseChannelPasswordProtections, + type ChannelCapacity, + type ChannelPasswordProtection, +} from "./channel-capacity.js"; export interface TSClientOptions { target: TeamSpeakTarget; @@ -62,7 +69,7 @@ const MAX_SERVER_ICON_BYTES = 128 * 1024; const MAX_SERVER_BANNER_URL_LENGTH = 2_048; const MAX_SERVER_WELCOME_MESSAGE_LENGTH = 4_096; -export type TSDirectoryChannel = DirectorySnapshot["channels"][number] & Partial; +export type TSDirectoryChannel = DirectorySnapshot["channels"][number] & Partial & Partial; export type TSDirectorySnapshot = Omit & { channels: TSDirectoryChannel[] }; export type TSDirectoryClient = DirectoryClientInfo; export type TSRawNotification = RawNotification; @@ -108,6 +115,7 @@ export class TSClient extends EventEmitter { private preferredChannelId = 0n; private accelerationClient: AccelerationRelayClient | null = null; private readonly channelCapacities = new Map(); + private readonly channelPasswordProtection = new Map(); // Reason id of the most recent self leave, kept so the SDK `kicked` event can // tell a plain kick (4) from a kick with ban (5). The SDK only forwards the // reason message to its `kicked` handler, not the reason id. @@ -126,6 +134,7 @@ export class TSClient extends EventEmitter { this.inputStateQueue = Promise.resolve(); this.selfLeaveReasonId = null; this.channelCapacities.clear(); + this.channelPasswordProtection.clear(); if (!this.adapter || !this.client) { let transportTarget = this.options.target; if (this.options.acceleration && !this.accelerationClient) { @@ -184,14 +193,19 @@ export class TSClient extends EventEmitter { // The high-level SDK directory type intentionally omits channel limit // metadata. Its raw client-protocol rows still include the public // maximum-client properties, so retain those without another SDK API. - const rows = await client.execCommandWithResponse("channellist", 5_000); + // TeamSpeak only includes channel flag fields (including the public + // password-required bit) when the client asks for flags explicitly. + const rows = await client.execCommandWithResponse("channellist -flags", 5_000); const capacities = parseChannelCapacities(rows); for (const [id, capacity] of capacities) this.channelCapacities.set(id, capacity); + for (const [id, passwordProtected] of parseChannelPasswordProtections(rows)) { + this.channelPasswordProtection.set(id, passwordProtected); + } } catch (error: unknown) { this.logger.warn({ err: error instanceof Error ? error.message : String(error) }, "Could not read TeamSpeak channel limits"); } this.emit("directorySnapshot", { - channels: channels.map((channel) => ({ ...channel, ...this.channelCapacities.get(channel.id) })), + channels: this.applyChannelMetadata(channels), clients, }); } catch (error: unknown) { @@ -356,7 +370,7 @@ export class TSClient extends EventEmitter { client.on("directorySnapshot", (snapshot) => { if (this.client !== client) return; this.emit("directorySnapshot", { - channels: snapshot.channels.map((channel) => ({ ...channel, ...this.channelCapacities.get(channel.id) })), + channels: this.applyChannelMetadata(snapshot.channels), clients: snapshot.clients.slice(), }); }); @@ -364,6 +378,12 @@ export class TSClient extends EventEmitter { client.on("rawNotification", (notification: RawNotification) => { if (this.client !== client) return; applyChannelCapacityNotification(notification.name, notification.params, this.channelCapacities); + const protectionChange = applyChannelPasswordProtectionNotification( + notification.name, + notification.params, + this.channelPasswordProtection, + ); + if (protectionChange) this.emit("channelPasswordProtectionChanged", protectionChange); this.emit("rawNotification", { name: notification.name, params: { ...notification.params }, @@ -395,6 +415,7 @@ export class TSClient extends EventEmitter { this.connected = false; this.clientId = 0; this.channelCapacities.clear(); + this.channelPasswordProtection.clear(); this.emit("disconnected", err); }); @@ -590,6 +611,16 @@ export class TSClient extends EventEmitter { this.clientId = 0; } } + + private applyChannelMetadata(channels: readonly TSDirectoryChannel[]): TSDirectoryChannel[] { + return channels.map((channel) => ({ + ...channel, + ...this.channelCapacities.get(channel.id), + ...(this.channelPasswordProtection.has(channel.id) + ? { passwordProtected: this.channelPasswordProtection.get(channel.id)! } + : {}), + })); + } } function normalizeTeamSpeakBannerUrl(value: unknown): string | null { diff --git a/src/shared/server-messages.test.ts b/src/shared/server-messages.test.ts index 9c07972..d879b1c 100644 --- a/src/shared/server-messages.test.ts +++ b/src/shared/server-messages.test.ts @@ -16,7 +16,7 @@ const samples: Record = { memberEnter: { type: "memberEnter", id: 2, nickname: "Visitor", uid: "uid-2", isSelf: false }, memberLeave: { type: "memberLeave", id: 2 }, memberAvatar: { type: "memberAvatar", id: 2, avatar: "data:image/png;base64,test" }, - channelList: { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10, maxClientsLimited: true, members: [{ id: 1, nickname: "Owner" }] }] }, + channelList: { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10, maxClientsLimited: true, passwordProtected: true, members: [{ id: 1, nickname: "Owner" }] }] }, chatMessage: { type: "chatMessage", scope: "channel", targetId: "1", invokerId: 2, message: "hello" }, pokeReceived: { type: "pokeReceived", invokerId: 2, message: "poke" }, serverEvent: { type: "serverEvent", event }, @@ -70,6 +70,7 @@ test("malformed nested directory and event data is rejected before client state { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", members: [{}] }] }, { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 10 }] }, { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", maxClients: 65536, maxClientsLimited: true }] }, + { type: "channelList", channels: [{ id: "1", parentID: "0", name: "Lobby", passwordProtected: "yes" }] }, { type: "memberEnter", id: 65536, nickname: "bad id" }, { type: "memberEnter", id: 1, nickname: "bad flag", inputMuted: "false" }, { type: "serverEvent", event: { ...event, timestamp: Infinity } }, diff --git a/src/shared/server-messages.ts b/src/shared/server-messages.ts index 80ce754..3a71dc5 100644 --- a/src/shared/server-messages.ts +++ b/src/shared/server-messages.ts @@ -72,6 +72,7 @@ function channel(value: unknown): value is ChannelInfo { && text(value.name) && optional(value.order, text) && optional(value.description, text) && optional(value.maxClients, maximum => finite(maximum) && Number.isInteger(maximum) && maximum >= 0 && maximum <= 65_535) && optional(value.maxClientsLimited, boolean) + && optional(value.passwordProtected, boolean) && (value.maxClients === undefined) === (value.maxClientsLimited === undefined) && optional(value.members, members => arrayOf(members, member)); } diff --git a/src/shared/voice-models.ts b/src/shared/voice-models.ts index f99ff72..6eabe86 100644 --- a/src/shared/voice-models.ts +++ b/src/shared/voice-models.ts @@ -23,6 +23,8 @@ export interface ChannelInfo { maxClients?: number; /** False means the channel has no individual client limit. */ maxClientsLimited?: boolean; + /** TeamSpeak's public channel flag; absent when the connected server omits it. */ + passwordProtected?: boolean; members?: ChannelMember[]; } diff --git a/web/public/skins/kaak-voice.wskin b/web/public/skins/kaak-voice.wskin index 2439c92..2a54d99 100644 Binary files a/web/public/skins/kaak-voice.wskin and b/web/public/skins/kaak-voice.wskin differ diff --git a/web/src/components/Icon.vue b/web/src/components/Icon.vue index a4613f2..5a02619 100644 --- a/web/src/components/Icon.vue +++ b/web/src/components/Icon.vue @@ -36,8 +36,12 @@ - - + + +