WebSpeak

WebSpeak 是一个自托管的 TeamSpeak 浏览器客户端与访客接入网关。每个浏览器 Session 都拥有独立的普通 TeamSpeak Client 连接;频道、成员和权限来自该用户自己的可见数据,不依赖 ServerQuery、WebQuery 或维护机器人。

中文 · English · AGPL-3.0 License

中文

当前能力

  • TeamSpeak 3 / TeamSpeak 6 自动探测,无需选择协议。
  • 每个浏览器 Session 独立连接,硬上限固定为 100。
  • Session 生命周期统一管理:连接状态机、WebSocket 心跳、幂等清理和优雅关闭。
  • TeamSpeak 临时断线自动重连,固定退避策略最长持续 5 分钟;认证失败不会无限重试,并尽量恢复原频道。
  • 完整频道/成员树、频道切换、频道文字聊天和成员实时移动。
  • PCM/Opus 语音桥接、自由麦、按键说话、麦克风选择与音量控制。
  • 发言成员头像显示绿色动态边框。
  • 中英文访客页面和中英文管理控制台。
  • Web 管理闭环:默认账号首次登录强制改密、单管理员登录、概览、服务器设置和真实连接测试。
  • fixed 与 open 两种访问模式。
  • TeamSpeak 密码使用安装级主密钥加密保存,不向管理 API 返回明文。
  • 旧 config.json 一次性导入,导入后不再作为实时配置源。

环境要求

  • Node.js 22.5.0 或更高版本。
  • Linux 推荐;Windows 也可用于开发和运行。
  • @discordjs/opus 所需的原生编译工具。
  • 可访问的 TeamSpeak 3 或 TeamSpeak 6 服务器。
  • 较新的 Chrome 或 Edge;生产环境应使用 HTTPS。

Docker 部署(推荐)

全新 Linux 主机只需要 Docker:

docker run -d \
  --name webspeak \
  --restart unless-stopped \
  -p 3040:3040 \
  -v webspeak-data:/data \
  ghcr.io/EchoSixHIYA/webspeak:latest

容器内部端口固定为 3040,SQLite 数据库、主密钥和日志持久化在 /data。启动后打开 http://你的地址:3040/admin,使用 admin/admin 登录并按页面要求修改密码。生产环境请在前面配置 HTTPS 反向代理。

也可以使用仓库附带的 docker-compose.yml:

docker compose up -d
docker logs webspeak

Ubuntu / Debian:

sudo apt-get update
sudo apt-get install -y build-essential python3

Windows 请安装 Visual Studio Build Tools,并勾选“使用 C++ 的桌面开发”。

本地安装与启动

npm install
npm --prefix web install
npm --prefix web run build
npm run build
node dist/index.js

WebSpeak 内部端口固定为 3040。首次启动会自动创建默认管理员账号:

账号:admin
密码:admin

然后打开管理入口:

http://127.0.0.1:3040/admin

首次登录后必须设置一个至少 12 个字符的新密码。改密完成后,在“服务器设置”中填写 TeamSpeak 目标并执行连接测试,再保存访问模式和站点信息。

后续管理入口仍为 /admin。管理员账号名固定为 admin,当前版本不提供用户列表或角色系统。

访问模式

fixed 是默认模式。访客页只显示昵称和频道,TeamSpeak 目标与服务器密码由服务端管理。

欢迎页没有邀请链接目标参数时,地址和端口输入框会预填管理控制台中配置的“默认 TeamSpeak 目标”;邀请链接中的目标参数优先使用。

open 模式允许访客输入其他公网 TeamSpeak 地址和本次 Session 使用的密码。WebSpeak 会解析 DNS,并阻止 loopback、私网、链路本地、组播、广播及保留地址;实际连接使用已经验证过的 IP,避免 DNS rebinding。

访客密码只存在于一次性 Join Ticket 中,不写入 URL、本地存储或数据库。普通分享链接也不会包含密码。

持久化与安全

运行数据位于项目的 data/ 目录:

data/
  webspeak.db   SQLite 配置、管理员凭据和有限审计事件
  master.key    32 字节安装级主密钥
  logs/         本地日志
  • 管理员密码使用 Node.js crypto.scrypt、随机 salt 和 constant-time compare。
  • 新部署首次使用 admin/admin 登录后必须立即修改密码;修改完成后默认密码失效。
  • TeamSpeak 服务器密码使用 AES-256-GCM 加密。
  • 管理 Session 是随机服务端 Session;Cookie 为 HttpOnly、SameSite=Strict,直接 HTTPS 下同时启用 Secure。
  • 管理 mutation 检查同源请求、JSON Content-Type、服务端 Session 与 CSRF token。
  • 管理登录具有固定窗口限速和连续失败延迟。
  • 日志、管理 API 和 Overview 不返回服务器密码、管理员密码或身份私钥。

请备份整个 data/ 目录。只有数据库而没有对应 master.key 时,已加密的 TeamSpeak 密码无法恢复。不要提交 data/、config.json、证书、私钥或日志。

从旧版本升级

首次使用新版启动时,如果项目根目录存在旧 config.json,WebSpeak 只导入:

  • tsHost
  • tsPort
  • tsServerPassword

以下字段会被忽略并废弃:

  • port
  • tsServerProtocol
  • maxClients
  • trustProxy

原文件不会被删除或改写。导入成功后,data/webspeak.db 成为唯一实时配置源,管理控制台会显示一次迁移提示。config.example.json 仅用于说明旧版迁移格式,新部署不需要复制它。

HTTPS 与反向代理

如果项目根目录存在 certs/cert.pem 与 certs/key.pem,WebSpeak 会直接提供 HTTPS。公网部署建议由 Caddy 或 Nginx 终止 TLS,再代理到固定的 127.0.0.1:3040。

Nginx 示例:

server {
    listen 443 ssl;
    server_name ts.example.com;

    ssl_certificate /etc/letsencrypt/live/ts.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ts.example.com/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3040;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

WebSpeak 不使用 X-Forwarded-* 作为认证或授权边界。麦克风和 WebCodecs 在公网环境需要浏览器安全上下文。

健康检查与开发命令

无需认证的最小健康检查:

GET /health
GET /api/health

开发命令:

# 后端开发服务(固定 3040)
npm run dev

# 前端开发服务;/api 和 /ws 代理到 3040
npm run web:dev

# 自动测试(覆盖 M000–M003)
npm test

# 后端类型检查与构建
npm run build

# 前端类型检查与生产构建
npm --prefix web run build

# 依赖安全审计
npm audit

项目结构

src/
  admin/                         管理服务、API、Session 与登录限速
  persistence/database.ts        SQLite schema、repository 和迁移边界
  security/                      主密钥、秘密加密、scrypt 与网络策略
  domain/teamspeak-target.ts     host[:port] 规范化解析
  server/teamspeak-adapter.ts    TeamSpeak 协议边界与 endpoint 协议缓存
  server/teamspeak-probe.ts      可清理的短连接测试
  server/join-ticket.ts          一次性访客连接票据
  server/voice-bridge.ts         每用户语音 WebSocket 桥接
web/src/views/
  AdminView.vue                  双语 Login/Password change/Overview/Server UI
  WebClient.vue                  双语访客与语音工作台

English

WebSpeak is a self-hosted TeamSpeak web client and guest gateway. Every browser session owns an independent normal TeamSpeak client connection, so its channel/member view comes from that identity rather than a Query or maintenance account.

Features

  • Automatic TeamSpeak 3 / TeamSpeak 6 detection.
  • Independent browser sessions with a fixed hard limit of 100.
  • Managed session lifecycle with a connection state machine, WebSocket heartbeat, idempotent teardown, and graceful shutdown.
  • Temporary TeamSpeak failures recover with bounded jittered backoff for up to five minutes; authentication failures are not retried forever, and the previous channel is restored when possible.
  • Channel/member directory, channel switching, channel text chat, and live member movement.
  • PCM/Opus voice bridge, VOX, push-to-talk, microphone selection, and volume controls.
  • Bilingual guest UI and bilingual admin console.
  • Browser-based admin login, mandatory first-login password change, Overview, server settings, and a real short-lived connection test.
  • Fixed and open guest access modes.
  • Encrypted TeamSpeak server password and one-time legacy config import.
  • No ServerQuery, WebQuery, admin token, or maintenance bot.

Requirements and startup

  • Node.js 22.5.0 or newer.
  • Native build tools for @discordjs/opus.
  • A reachable TS3 or TS6 server.
  • A recent Chrome or Edge browser; use HTTPS in production.

On a fresh Linux host, Docker is the only requirement:

docker run -d \
  --name webspeak \
  --restart unless-stopped \
  -p 3040:3040 \
  -v webspeak-data:/data \
  ghcr.io/EchoSixHIYA/webspeak:latest

The container always listens on 3040. SQLite, the installation master key, and logs persist under /data. Open http://your-host:3040/admin, sign in with admin/admin, and change the password when prompted. Put an HTTPS reverse proxy in front of the container for production microphone access.

The repository also includes docker-compose.yml:

docker compose up -d
docker logs webspeak
npm install
npm --prefix web install
npm --prefix web run build
npm run build
node dist/index.js

WebSpeak always listens on internal port 3040. On first boot it creates the default administrator admin with password admin. Open the admin console:

http://127.0.0.1:3040/admin

The first login is forced to a password-change screen. Set a password of at least 12 characters, then configure and test the TeamSpeak target from Server settings. Future administration is performed at /admin; no JSON editing or restart is needed for normal setting changes.

Security and persistence

Local state is stored under data/ in SQLite plus a 32-byte master.key. Admin passwords use crypto.scrypt. A new instance starts with admin/admin and marks that credential for mandatory rotation on first login. TeamSpeak secrets use AES-256-GCM. Admin sessions are server-side with HttpOnly/SameSite Strict cookies, same-origin and CSRF checks, and fixed login throttling.

In fixed mode, guests cannot override the configured target. In open mode, arbitrary public targets are validated after DNS resolution; private, loopback, link-local, multicast, broadcast, and reserved addresses are rejected. Session passwords travel through an opaque one-time Join Ticket and are never placed in share or WebSocket URLs.

When the welcome page has no target parameters from an invite link, its address and port field is prefilled from the admin-configured default TeamSpeak target. Invite-link target parameters take precedence.

If a legacy config.json exists on the first upgraded start, only tsHost, tsPort, and tsServerPassword are imported. The original file is preserved, and SQLite becomes the sole live settings source.

Development

npm run dev
npm run web:dev
npm test
npm run build
npm --prefix web run build
npm audit

License

WebSpeak is licensed under the GNU Affero General Public License v3.0 only (AGPL-3.0-only). If you run a modified version as a network service, you must offer its users the corresponding source code as required by the license.

社区 / Community

群号 / Group ID: 869500475

WebSpeak 群聊二维码

Languages
TypeScript 71.8%
Vue 12.1%
JavaScript 9%
CSS 6.1%
HTML 0.4%
Other 0.5%