Compare commits

...
Author SHA1 Message Date
MoepchiandClaude Sonnet 5 faeb269fdd Add URL-based and build-time auto-connect (closes #10)
Landing pages can now send visitors straight into a TeamSpeak server:
a ?connect=host&nickname=&channel=&token= share link auto-connects on
any deployment, or a self-hoster can bake in a default server at build
time (VITE_DEFAULT_SERVER/VITE_DEFAULT_CHANNEL, mirroring the existing
DONATE_URL Docker ARG pattern) so every visitor auto-joins with zero
params. A share link always overrides the build-time default. Waits
for the mandatory first-visit ToS gate where applicable, falls back to
a prefilled reopened connect dialog on failure, and generates a
Guest-XXXX nickname when none is available.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-16 12:34:14 +00:00
MoepchiandClaude Sonnet 5 f44327aabc ROADMAP: add concrete accessibility milestone for the web client
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-15 18:03:32 +00:00
MoepchiandClaude Sonnet 5 7357dfa85d Bump tsclientlib: fix live stream start/stop not seen by connected clients
An already-connected client only learned about another client's TS6
stream via the initial snapshot; a live start/stop toggle mid-session
went out via notifyclientupdated, whose attribute list didn't include
client_is_streaming, so tsclientlib silently dropped it. Fixed upstream
in tsdeclarations/Messages.toml; only a reconnect used to pick it up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-15 17:37:00 +00:00
MoepchiandClaude Sonnet 5 ceeba24f86 ROADMAP: fix stale note about streaming UI flag being off
client.webspeak3.de's gateway has answered setupStream/joinStream/
sendStreamSignal since v0.11.0-beta.1 (2026-09-11); STREAM_UI_ENABLED
was flipped back on then but this doc never caught up.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-15 17:16:13 +00:00
MoepchiandClaude Sonnet 5 817aa0f5f6 Gracefully disconnect live sessions on SIGTERM before exiting
Previously the container was killed with connector child processes still
mid-session, so the target TS3/TeaSpeak server only noticed the drop via
its own timeout. A client's automatic reconnect (see App.tsx's
scheduleReconnect) landing before that timeout got rejected as a
duplicate identity (e.g. ClientTooManyClonesConnected).

Now SIGTERM disconnects every live connection first (bounded to 5s) so
the target server frees the slot immediately. The connector's own
resulting "disconnected" event is suppressed from reaching the browser
during shutdown (shuttingDown flag) so the browser sees a raw socket
close, which it treats as an unexpected drop and retries, rather than an
explicit disconnect, which it treats as deliberate and gives up on.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-15 06:56:19 +00:00
MoepchiandClaude Sonnet 5 bc6022b45f Add optional token-authenticated /api/broadcast endpoint
Lets the operator send a free-text maintenance notice to every connected
browser tab via POST /api/broadcast (Bearer BROADCAST_TOKEN). Reuses the
existing {type:"notice"} WebSocket message the frontend already renders
for the SIGTERM restart notice, so no frontend changes are needed. Off
(404) unless BROADCAST_TOKEN is set, same opt-in convention as
FEEDBACK_ENABLED/LOG_CONNECTIONS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-09-15 05:25:33 +00:00
6 changed files with 236 additions and 20 deletions

No files matched your search

+8 -2
View File
@@ -29,10 +29,16 @@ COPY web/ ./
# exists because an unset build arg and an empty one are indistinguishable # exists because an unset build arg and an empty one are indistinguishable
# inside RUN - without it, "not passed" would silently mean "remove". # inside RUN - without it, "not passed" would silently mean "remove".
ARG DONATE_URL=keep ARG DONATE_URL=keep
# A self-hosted build can bake in a server to auto-connect to with zero user
# input (see web/src/App.tsx's AUTO_CONNECT_FROM_URL/DEFAULT_SERVER, GitHub
# issue #10). Unlike DONATE_URL, unset already means "no default" - no "keep"
# sentinel needed.
ARG DEFAULT_SERVER=
ARG DEFAULT_CHANNEL=
# tsc -b currently fails on pre-existing type errors unrelated to this build; # tsc -b currently fails on pre-existing type errors unrelated to this build;
# vite build alone is enough to produce the production bundle. # vite build alone is enough to produce the production bundle.
RUN if [ "$DONATE_URL" = "keep" ]; then npx vite build; \ RUN if [ "$DONATE_URL" = "keep" ]; then DONATE_URL_ENV=; else DONATE_URL_ENV="VITE_DONATE_URL=$DONATE_URL"; fi; \
else VITE_DONATE_URL="$DONATE_URL" npx vite build; fi env $DONATE_URL_ENV VITE_DEFAULT_SERVER="$DEFAULT_SERVER" VITE_DEFAULT_CHANNEL="$DEFAULT_CHANNEL" npx vite build
# --- Gateway ---------------------------------------------------------------- # --- Gateway ----------------------------------------------------------------
FROM node:22-bookworm-slim AS gateway-builder FROM node:22-bookworm-slim AS gateway-builder
+7
View File
@@ -180,6 +180,13 @@ docker run -d -p 8080:8080 --name webspeak3 moepchi/webspeak3:latest
The UI shows a small **Ko-fi donation button** in the bottom right corner. Building it yourself and would rather not carry someone else's donation link? `docker compose build --build-arg DONATE_URL=` removes it (any other value points it somewhere else). Outside Docker the same thing is a build-time variable: `VITE_DONATE_URL= npm run build` in `web/`. The UI shows a small **Ko-fi donation button** in the bottom right corner. Building it yourself and would rather not carry someone else's donation link? `docker compose build --build-arg DONATE_URL=` removes it (any other value points it somewhere else). Outside Docker the same thing is a build-time variable: `VITE_DONATE_URL= npm run build` in `web/`.
Want your instance to auto-connect visitors to a specific TeamSpeak server? Two ways, and either works with no user input at all:
- **Share link**: send anyone `https://your-instance/?connect=your.ts.server&nickname=Guest&channel=Lobby&token=...` - `connect` is the only required part, the rest are optional. Works on any deployment, no rebuild needed.
- **Baked-in default**: `docker compose build --build-arg DEFAULT_SERVER=your.ts.server --build-arg DEFAULT_CHANNEL=Lobby` (or `VITE_DEFAULT_SERVER=your.ts.server npm run build` in `web/`) makes every visitor auto-connect there by default. A share link still overrides it when present.
Visitors with no nickname of their own get an auto-generated `Guest-XXXX` one.
<details> <details>
<summary><b>🛠️ Manual installation (without Docker)</b></summary> <summary><b>🛠️ Manual installation (without Docker)</b></summary>
+27 -8
View File
@@ -25,13 +25,15 @@ This roadmap is intentionally outcome-focused. It does not promise fixed dates.
does not document, so the wire format was derived from observed behavior and does not document, so the wire format was derived from observed behavior and
may break with any TS6 update. Connection setup, picture quality, and viewer may break with any TS6 update. Connection setup, picture quality, and viewer
admission are not yet dependable. The "Server" connection mode (TS6's SFU) is admission are not yet dependable. The "Server" connection mode (TS6's SFU) is
not implemented; only direct P2P works. The UI is currently switched off by a not implemented; only direct P2P works. The UI is gated by a build-time flag,
build-time flag, because the hosted client updates on every push while the because the hosted client updates on every push while the gateway image is
gateway image is deployed by hand, and a browser that offers streaming to a deployed by hand, and a browser that offers streaming to a gateway too old to
gateway too old to answer waits forever instead of reporting an error. The answer waits forever instead of reporting an error — on since 2026-09-11 for
fix is a capability handshake so the client can detect what its gateway client.webspeak3.de now that its gateway answers setupStream/joinStream/
supports rather than assuming; until then the flag is flipped by hand after sendStreamSignal (v0.11.0-beta.1+). The durable fix is a capability handshake
the gateway has been updated. so the client can detect what its gateway supports rather than assuming;
until then the flag is flipped by hand whenever the frontend gains a stream
feature the deployed gateway doesn't have yet.
- Safari and Mobile Safari audio/microphone behavior - Safari and Mobile Safari audio/microphone behavior
- Uncommon TeamSpeak permission combinations and large permission sets - Uncommon TeamSpeak permission combinations and large permission sets
- Very large servers and long-running browser sessions - Very large servers and long-running browser sessions
@@ -44,9 +46,26 @@ This roadmap is intentionally outcome-focused. It does not promise fixed dates.
- Expand real-browser audio testing, especially Safari - Expand real-browser audio testing, especially Safari
- Improve reconnect and recovery behavior under unstable networks - Improve reconnect and recovery behavior under unstable networks
- Continue accessibility, keyboard-navigation, and mobile usability work
- Turn recurring deployment and compatibility reports into documentation - Turn recurring deployment and compatibility reports into documentation
### Accessibility
The interface currently assumes a mouse and sighted use; a real pass is
still needed:
- Replace clickable `<div>`s that aren't real `<button>`s with actual
buttons, so they're reachable and operable by keyboard
- Add keyboard handlers next to the many click-only interactions (channel
tree, context menus, client list)
- Label icon-only toggle controls (mute, away, streaming, recording, ...)
with `aria-label`/`aria-pressed` so their state is announced, not just shown
as a color/icon change
- Fix the document's `lang` attribute to follow the active UI language
instead of staying fixed
- Manage focus in modals and dialogs: move it in on open, return it on close
- Do a full screen-reader pass (NVDA/VoiceOver) through a real connect
session to find what else is missing beyond the above
### Deployment experience ### Deployment experience
- Keep the one-command Docker path reliable - Keep the one-command Docker path reliable
+128 -9
View File
@@ -2,6 +2,7 @@ import { createServer, type IncomingMessage, type ServerResponse } from "node:ht
import { createServer as createSecureServer } from "node:https"; import { createServer as createSecureServer } from "node:https";
import { readFileSync } from "node:fs"; import { readFileSync } from "node:fs";
import { readFile, appendFile, rename, stat } from "node:fs/promises"; import { readFile, appendFile, rename, stat } from "node:fs/promises";
import { timingSafeEqual } from "node:crypto";
import path from "node:path"; import path from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { WebSocketServer, type WebSocket } from "ws"; import { WebSocketServer, type WebSocket } from "ws";
@@ -85,6 +86,84 @@ const FEEDBACK_LOG_MAX_BYTES = 5 * 1024 * 1024;
const FEEDBACK_CATEGORIES = new Set(["bug", "idea", "report", "other"]); const FEEDBACK_CATEGORIES = new Set(["bug", "idea", "report", "other"]);
const FEEDBACK_MESSAGE_MAX_LENGTH = 4000; const FEEDBACK_MESSAGE_MAX_LENGTH = 4000;
// --- Broadcast endpoint ---------------------------------------------------
//
// Opt-in only, same convention as LOG_CONNECTIONS/FEEDBACK_ENABLED above: lets
// the operator push a free-text maintenance notice to every connected browser
// tab (reuses the same {type:"notice"} message the SIGTERM handler already
// sends, which the frontend renders even without a messageKey). Unset
// BROADCAST_TOKEN and the endpoint 404s, same as feedback when disabled.
const BROADCAST_TOKEN = process.env.BROADCAST_TOKEN;
const BROADCAST_MESSAGE_MAX_LENGTH = 500;
function isValidBroadcastToken(provided: string): boolean {
if (!BROADCAST_TOKEN) return false;
const a = Buffer.from(provided);
const b = Buffer.from(BROADCAST_TOKEN);
return a.length === b.length && timingSafeEqual(a, b);
}
async function handleBroadcast(req: IncomingMessage, res: ServerResponse) {
if (!BROADCAST_TOKEN) {
res.writeHead(404, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "not_found" }));
return;
}
if (req.method !== "POST") {
res.writeHead(405, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "method_not_allowed" }));
return;
}
const authHeader = req.headers.authorization ?? "";
const token = authHeader.startsWith("Bearer ") ? authHeader.slice("Bearer ".length) : "";
if (!isValidBroadcastToken(token)) {
res.writeHead(401, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "unauthorized" }));
return;
}
let raw = "";
for await (const chunk of req) {
raw += chunk;
if (raw.length > 5_000) {
res.writeHead(413, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "payload_too_large" }));
return;
}
}
let body: { message?: unknown };
try {
body = JSON.parse(raw || "{}");
} catch {
res.writeHead(400, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "invalid_json" }));
return;
}
const message = typeof body.message === "string" ? body.message.trim().slice(0, BROADCAST_MESSAGE_MAX_LENGTH) : "";
if (!message) {
res.writeHead(400, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "message_required" }));
return;
}
const payload = JSON.stringify({ type: "notice", message });
let sent = 0;
for (const socket of wss.clients) {
try {
socket.send(payload);
sent++;
} catch {
/* socket already gone */
}
}
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ ok: true, sent }));
}
async function rotateFeedbackLogIfNeeded(): Promise<void> { async function rotateFeedbackLogIfNeeded(): Promise<void> {
try { try {
const { size } = await stat(FEEDBACK_LOG_FILE); const { size } = await stat(FEEDBACK_LOG_FILE);
@@ -278,6 +357,10 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => {
await handleFeedback(req, res); await handleFeedback(req, res);
return; return;
} }
if (requestUrl.pathname === "/api/broadcast") {
await handleBroadcast(req, res);
return;
}
// Container healthcheck target (see Dockerfile). Deliberately its own // Container healthcheck target (see Dockerfile). Deliberately its own
// route rather than "/": with WEB_STATIC=0 every browser-facing path // route rather than "/": with WEB_STATIC=0 every browser-facing path
@@ -345,6 +428,17 @@ interface HeartbeatState {
const heartbeats = new WeakMap<WebSocket, HeartbeatState>(); const heartbeats = new WeakMap<WebSocket, HeartbeatState>();
// Tracked so SIGTERM (below) can tell every live TS3/TeaSpeak session to
// disconnect properly before the process exits, instead of leaving the
// target server to notice on its own timeout.
const liveConnections = new Set<Ts3Connection>();
// Set right before that graceful disconnect: suppresses forwarding the
// connector's own "disconnected" event to the browser during shutdown, so
// the browser sees a raw socket close (which it auto-reconnects from) rather
// than an explicit disconnect (which it treats as deliberate and gives up
// on) — see the SIGTERM handler.
let shuttingDown = false;
const heartbeatTimer = setInterval(() => { const heartbeatTimer = setInterval(() => {
for (const socket of wss.clients) { for (const socket of wss.clients) {
const state = heartbeats.get(socket); const state = heartbeats.get(socket);
@@ -365,16 +459,35 @@ wss.on("close", () => clearInterval(heartbeatTimer));
// browser tab so an active call/stream doesn't just silently drop, then // browser tab so an active call/stream doesn't just silently drop, then
// exit quickly rather than waiting out the grace period doing nothing. // exit quickly rather than waiting out the grace period doing nothing.
process.on("SIGTERM", () => { process.on("SIGTERM", () => {
const payload = JSON.stringify({ type: "notice", messageKey: "restartNotice.body" }); void (async () => {
for (const socket of wss.clients) { const payload = JSON.stringify({ type: "notice", messageKey: "restartNotice.body" });
try { for (const socket of wss.clients) {
socket.send(payload); try {
} catch { socket.send(payload);
/* socket already gone */ } catch {
/* socket already gone */
}
} }
} console.log(`[gateway] SIGTERM received, notified ${wss.clients.size} client(s), disconnecting ${liveConnections.size} live session(s)`);
console.log(`[gateway] SIGTERM received, notified ${wss.clients.size} client(s), shutting down`);
setTimeout(() => process.exit(0), 500); // Tell every connector to leave its TS3/TeaSpeak server *before* the
// process exits. Without this, `docker stop`'s grace period expires and
// the container is killed, taking the connector child processes with it
// mid-session - the target server only notices via its own timeout
// (which can take a while), during which a client's automatic reconnect
// (see App.tsx's scheduleReconnect) gets rejected by the server as a
// duplicate identity (e.g. "ClientTooManyClonesConnected"). shuttingDown
// suppresses forwarding the resulting "disconnected" event to the
// browser - the browser must see a raw socket close here, not an
// explicit disconnect, or it treats it as deliberate and won't retry.
shuttingDown = true;
await Promise.race([
Promise.all([...liveConnections].map((c) => c.disconnect().catch(() => {}))),
new Promise((resolve) => setTimeout(resolve, 5000)),
]);
console.log(`[gateway] shutting down`);
process.exit(0);
})();
}); });
server.listen(PORT, () => { server.listen(PORT, () => {
@@ -414,6 +527,7 @@ wss.on("connection", (socket: WebSocket) => {
} catch { } catch {
/* ignore */ /* ignore */
} }
liveConnections.delete(connection);
connection = undefined; connection = undefined;
} }
const options: Ts3ConnectOptions = { const options: Ts3ConnectOptions = {
@@ -427,7 +541,9 @@ wss.on("connection", (socket: WebSocket) => {
privilegeKey: parsePrivilegeKey(msg), privilegeKey: parsePrivilegeKey(msg),
}; };
connection = new Ts3Connection(options); connection = new Ts3Connection(options);
liveConnections.add(connection);
connection.onEvent((event) => { connection.onEvent((event) => {
if (shuttingDown) return;
if (LOG_CONNECTIONS) { if (LOG_CONNECTIONS) {
if (event.type === "connected") { if (event.type === "connected") {
console.log( console.log(
@@ -694,6 +810,8 @@ wss.on("connection", (socket: WebSocket) => {
} }
case "disconnect": { case "disconnect": {
await connection?.disconnect(msg.message ?? ""); await connection?.disconnect(msg.message ?? "");
if (connection) liveConnections.delete(connection);
connection = undefined;
break; break;
} }
default: default:
@@ -705,6 +823,7 @@ wss.on("connection", (socket: WebSocket) => {
socket.on("close", () => { socket.on("close", () => {
heartbeats.delete(socket); heartbeats.delete(socket);
if (connection) liveConnections.delete(connection);
connection?.disconnect(); connection?.disconnect();
}); });
}); });
+65
View File
@@ -115,6 +115,34 @@ const DONATE_URL = import.meta.env.VITE_DONATE_URL ?? "https://ko-fi.com/moepchi
const OWN_HOSTED_HOSTNAMES = new Set(["client.webspeak3.de"]); const OWN_HOSTED_HOSTNAMES = new Set(["client.webspeak3.de"]);
const IS_OWN_HOSTED_INSTANCE = !DEMO_MODE && OWN_HOSTED_HOSTNAMES.has(window.location.hostname); const IS_OWN_HOSTED_INSTANCE = !DEMO_MODE && OWN_HOSTED_HOSTNAMES.has(window.location.hostname);
// Auto-connect from a share link (?connect=host[:port]&nickname=&channel=&token=,
// see GitHub issue #10). Parsed once at module load and immediately stripped
// from the URL via replaceState so a reload/refresh doesn't silently
// reconnect off a stale link sitting in the address bar or browser history.
const AUTO_CONNECT_FROM_URL = (() => {
const params = new URLSearchParams(window.location.search);
const connectHost = params.get("connect");
if (!connectHost) return null;
const target = {
host: connectHost,
nickname: params.get("nickname") || undefined,
defaultChannel: params.get("channel") || undefined,
privilegeKey: params.get("token") || undefined,
};
for (const key of ["connect", "nickname", "channel", "token"]) params.delete(key);
const rest = params.toString();
window.history.replaceState(null, "", window.location.pathname + (rest ? `?${rest}` : "") + window.location.hash);
return target;
})();
// A self-hosted build can also bake in a default server so the page
// auto-connects with zero URL params at all - set via `docker compose build
// --build-arg DEFAULT_SERVER=...` (see Dockerfile/README) or plain
// VITE_DEFAULT_SERVER= at build time. AUTO_CONNECT_FROM_URL above always wins
// when a share link is present.
const DEFAULT_SERVER = import.meta.env.VITE_DEFAULT_SERVER || null;
const DEFAULT_CHANNEL = import.meta.env.VITE_DEFAULT_CHANNEL || "";
// Terms of use, own-hosted instance only (see TODO.md #2/#7.1). Versioned so // Terms of use, own-hosted instance only (see TODO.md #2/#7.1). Versioned so
// a rule change can re-surface the modal: bump TOS_VERSION and everyone who // a rule change can re-surface the modal: bump TOS_VERSION and everyone who
// accepted an older version is asked again. // accepted an older version is asked again.
@@ -7191,6 +7219,43 @@ function AppInner() {
wireSocket(sessionId, socket, params); wireSocket(sessionId, socket, params);
}; };
// Auto-connect from a ?connect=... share link or a build-time default
// server (issue #10). Fires once, after the mandatory first-visit ToS gate
// (if any) is out of the way, so it never races the gate or connects
// before the user has had a chance to accept it.
const autoConnectedRef = useRef(false);
const autoConnectPendingRef = useRef(false);
useEffect(() => {
if (autoConnectedRef.current) return;
if (tosMandatory && tosOpen) return;
const target = AUTO_CONNECT_FROM_URL ??
(DEFAULT_SERVER
? { host: DEFAULT_SERVER, nickname: undefined, defaultChannel: DEFAULT_CHANNEL, privilegeKey: undefined }
: null);
if (!target) return;
autoConnectedRef.current = true;
autoConnectPendingRef.current = true;
handleConnect({
host: target.host,
nickname: target.nickname || nickname || `Guest-${Math.floor(1000 + Math.random() * 9000)}`,
defaultChannel: target.defaultChannel,
privilegeKey: target.privilegeKey,
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [tosMandatory, tosOpen]);
// A manual connect attempt leaves its error as a dismissable banner with the
// dialog already closed - fine, since the user just closed it themselves.
// An auto-connect attempt has no dialog open at all, so on failure reopen it
// prefilled with the attempted host, letting the user fix and retry by hand.
useEffect(() => {
if (!autoConnectPendingRef.current || !connectError) return;
autoConnectPendingRef.current = false;
setHost(AUTO_CONNECT_FROM_URL?.host ?? DEFAULT_SERVER ?? host);
setConnectDialogOpen(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [connectError]);
// Opens a fresh socket for a session that already exists (active or // Opens a fresh socket for a session that already exists (active or
// parked) and re-runs the same connect handshake, reusing the params // parked) and re-runs the same connect handshake, reusing the params
// stored at connect time. Used to recover from an unexpected drop — // stored at connect time. Used to recover from an unexpected drop —