Compare commits

...
Author SHA1 Message Date
MoepchiandClaude Opus 5.5 4afab66d6b Bump tsclientlib: 60 ms minimum audio pre-buffer against jitter wobble
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-14 17:09:38 +00:00
MoepchiandClaude Opus 5.5 e19ced1bd1 Optional Cloudflare Turnstile bot check before connecting
With TURNSTILE_SITE_KEY and TURNSTILE_SECRET set, the gateway answers a
connect without a valid pass with "turnstileRequired". The browser solves
the (usually invisible) check and resends the connect with the token; the
gateway verifies it and hands out a pass bound to the client IP for 12 h,
so reconnects and new tabs skip the check. Off by default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-14 16:50:10 +00:00
MoepchiandClaude Opus 5.5 4e04ddb526 Gateway: log rejected connections over the per-IP limit
Rejections at the WebSocket upgrade (429) were silent, so a client
hammering MAX_CONNECTIONS_PER_IP left no trace. Now logged as a
[ratelimit] line like the connect rate limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-14 11:31:54 +00:00
MoepchiandClaude Opus 5.5 169d32a292 Client tree: own icons for TeamSpeak's built-in group icons
Built-in group icons (Server Admin, Channel Admin, ...) were plain coloured
letter circles. Now a small person with the group's initial in a coloured
badge, in the style of the mute icons. Own artwork, not a copy of the
native client's icons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-12 21:01:16 +00:00
MoepchiandClaude Opus 5.5 de94859a16 Client tree: channel group icon after the server group icons
Like the native client: server group icons, channel group icon, then the
flag on the far right. The channel group list is now fetched on connect
like the server group list, and its custom icons are downloaded too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-12 20:28:16 +00:00
MoepchiandClaude Opus 5.5 810d922b09 Client tree: flags on the far right, work in Chromium on Windows, zzz for away
- Country flag is the rightmost icon, after the group icons.
- Flags render through the Twemoji Country Flags font (CC-BY 4.0), since
  Chromium on Windows has no flag emoji and shows the two letters.
  unicode-range keeps it to flag characters and loads it only on demand.
- Away is the 💤 again, still in place of the talk dot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-12 20:22:34 +00:00
MoepchiandClaude Opus 5.5 5e76bd3bdf Client tree: away and sound mute replace the talk dot, like the native client
Sound mute is a crossed-out speaker instead of a bell, away a moon.
Order as in TeamSpeak: away, sound muted, mic muted, talking/idle.
Icon pack ids stay the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
2026-11-12 20:18:53 +00:00
13 changed files with 303 additions and 65 deletions

No files matched your search

+3
View File
@@ -243,6 +243,7 @@ All optional; add them under `environment:` in your compose override next to `PO
| `TURN_URLS` | unset | Comma-separated TURN URLs (e.g. `turn:turn.example.com:3478`) offered to browsers for screen streams, for viewers or publishers behind NATs where direct P2P fails. Pair with `TURN_SECRET` (coturn's `use-auth-secret`; each browser gets its own credential valid for 24 h) or with static `TURN_USERNAME` / `TURN_CREDENTIAL`, which every visitor can read. | | `TURN_URLS` | unset | Comma-separated TURN URLs (e.g. `turn:turn.example.com:3478`) offered to browsers for screen streams, for viewers or publishers behind NATs where direct P2P fails. Pair with `TURN_SECRET` (coturn's `use-auth-secret`; each browser gets its own credential valid for 24 h) or with static `TURN_USERNAME` / `TURN_CREDENTIAL`, which every visitor can read. |
| `ALLOWED_ORIGINS` | unset (any origin) | Comma-separated list of web origins allowed to open `/ws` (e.g. `https://client.example.com`). Stops other websites from silently using your gateway as their relay. | | `ALLOWED_ORIGINS` | unset (any origin) | Comma-separated list of web origins allowed to open `/ws` (e.g. `https://client.example.com`). Stops other websites from silently using your gateway as their relay. |
| `MAX_CONNECTIONS_PER_IP` / `MAX_CONNECTIONS` | `10` / `60` | Concurrent `/ws` connections per client IP and in total (each can hold a live TeamSpeak session). `0` disables a limit. | | `MAX_CONNECTIONS_PER_IP` / `MAX_CONNECTIONS` | `10` / `60` | Concurrent `/ws` connections per client IP and in total (each can hold a live TeamSpeak session). `0` disables a limit. |
| `TURNSTILE_SITE_KEY` / `TURNSTILE_SECRET` | *(unset)* | Optional [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/) bot check before connecting. With both set, a browser solves the (usually invisible) check once and gets a pass bound to its IP for 12 h. Keeps scripts from opening TeamSpeak connections through your gateway. |
| `CONNECT_RATE_LIMIT` | `30` | Server connects per client IP per minute. Each one starts a new TeamSpeak session, so this stops anyone from flooding a server through your gateway. `0` disables it. | | `CONNECT_RATE_LIMIT` | `30` | Server connects per client IP per minute. Each one starts a new TeamSpeak session, so this stops anyone from flooding a server through your gateway. `0` disables it. |
| `TRUST_PROXY` | off | Only when the gateway is reachable **solely** through a proxy/tunnel, so per-IP limits see the real client instead of the proxy: `cloudflare` (Cloudflare Tunnel or proxy) uses `CF-Connecting-IP`; `1` (your own nginx/Caddy/Traefik) uses the last `X-Forwarded-For` entry, the one your proxy appended. Don't set it on a directly exposed gateway - clients could then fake their IP. | | `TRUST_PROXY` | off | Only when the gateway is reachable **solely** through a proxy/tunnel, so per-IP limits see the real client instead of the proxy: `cloudflare` (Cloudflare Tunnel or proxy) uses `CF-Connecting-IP`; `1` (your own nginx/Caddy/Traefik) uses the last `X-Forwarded-For` entry, the one your proxy appended. Don't set it on a directly exposed gateway - clients could then fake their IP. |
| `TELEMETRY` | on | Set to `0` to turn off the anonymous usage ping (see below). | | `TELEMETRY` | on | Set to `0` to turn off the anonymous usage ping (see below). |
@@ -397,6 +398,8 @@ The UI texts live in flat JSON files in [`web/src/locales/`](web/src/locales/),
The vast majority of this project's code was written by [Claude Code](https://claude.com/claude-code) (Anthropic's Claude), working iteratively with the repo owner one feature at a time. The vast majority of this project's code was written by [Claude Code](https://claude.com/claude-code) (Anthropic's Claude), working iteratively with the repo owner one feature at a time.
Country flags use the [Twemoji Country Flags](https://github.com/talkjs/country-flag-emoji-polyfill) font, artwork from [Twemoji](https://github.com/twitter/twemoji) under [CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/).
## 🌈 In Memory of Akimo ## 🌈 In Memory of Akimo
<!-- Permanent: never remove this section. --> <!-- Permanent: never remove this section. -->
+18 -1
View File
@@ -11,6 +11,7 @@ import { handleStore } from "./store.js";
import { handleNewsConfig } from "./news.js"; import { handleNewsConfig } from "./news.js";
import { logFeedback, logConnectionEvent } from "./activity-log.js"; import { logFeedback, logConnectionEvent } from "./activity-log.js";
import { clientIp, createRateLimiter } from "./net.js"; import { clientIp, createRateLimiter } from "./net.js";
import { TURNSTILE_ENABLED, TURNSTILE_SITE_KEY, isValidPass, issuePass, verifyToken } from "./turnstile.js";
import "./telemetry.js"; import "./telemetry.js";
// TeamSpeak 2 support is experimental and opt-in (ENABLE_TS2=1). // TeamSpeak 2 support is experimental and opt-in (ENABLE_TS2=1).
@@ -490,7 +491,7 @@ const requestHandler = (req: IncomingMessage, res: ServerResponse) => {
// Same list as the "hello" message, readable before any connect // Same list as the "hello" message, readable before any connect
// (the connect dialog offers TeamSpeak 2 only when it is enabled). // (the connect dialog offers TeamSpeak 2 only when it is enabled).
res.writeHead(200, { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Cache-Control": "public, max-age=300" }); res.writeHead(200, { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "Cache-Control": "public, max-age=300" });
res.end(JSON.stringify({ features: GATEWAY_FEATURES })); res.end(JSON.stringify({ features: GATEWAY_FEATURES, ...(TURNSTILE_ENABLED ? { turnstileSiteKey: TURNSTILE_SITE_KEY } : {}) }));
return; return;
} }
if (requestUrl.pathname === "/api/news") { if (requestUrl.pathname === "/api/news") {
@@ -583,6 +584,7 @@ const wss = new WebSocketServer({
} }
const ip = clientIp(req); const ip = clientIp(req);
if (MAX_CONNECTIONS_PER_IP > 0 && (connectionsPerIp.get(ip) ?? 0) >= MAX_CONNECTIONS_PER_IP) { if (MAX_CONNECTIONS_PER_IP > 0 && (connectionsPerIp.get(ip) ?? 0) >= MAX_CONNECTIONS_PER_IP) {
console.warn(`[ratelimit] too many open connections from one IP (limit ${MAX_CONNECTIONS_PER_IP})`);
return done(false, 429, "Too many connections"); return done(false, 429, "Too many connections");
} }
done(true); done(true);
@@ -754,6 +756,21 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => {
); );
break; break;
} }
if (TURNSTILE_ENABLED && !isValidPass(msg.turnstilePass, ip)) {
// No (valid) pass yet: ask the browser to solve the check, it
// resends this connect with the token.
if (msg.turnstileToken === undefined) {
socket.send(JSON.stringify({ type: "turnstileRequired" }));
break;
}
if (!(await verifyToken(msg.turnstileToken, ip))) {
socket.send(
JSON.stringify({ type: "error", code: "turnstile_failed", message: "Bot check failed. Please try again." }),
);
break;
}
socket.send(JSON.stringify({ type: "turnstilePass", pass: issuePass(ip) }));
}
// Replacing a connection on the same socket: tear down the previous // Replacing a connection on the same socket: tear down the previous
// connector so we don't leak processes. // connector so we don't leak processes.
if (connection) { if (connection) {
+49
View File
@@ -0,0 +1,49 @@
// Optional Cloudflare Turnstile bot check before a "connect". Off unless both
// TURNSTILE_SITE_KEY and TURNSTILE_SECRET are set. A solved check earns a
// signed pass (bound to the client IP, valid PASS_TTL_MS) that later connects
// and silent reconnects present instead, so a real user sees the check at
// most once in that window.
import { createHmac, timingSafeEqual } from "node:crypto";
export const TURNSTILE_SITE_KEY = process.env.TURNSTILE_SITE_KEY ?? "";
const SECRET = process.env.TURNSTILE_SECRET ?? "";
export const TURNSTILE_ENABLED = TURNSTILE_SITE_KEY !== "" && SECRET !== "";
const PASS_TTL_MS = 12 * 60 * 60 * 1000;
// Derived from the secret, so passes survive a gateway restart.
const PASS_KEY = createHmac("sha256", SECRET).update("webspeak3-turnstile-pass").digest();
const sign = (ip: string, expires: number) =>
createHmac("sha256", PASS_KEY).update(`${ip}|${expires}`).digest("base64url");
export function issuePass(ip: string): string {
const expires = Date.now() + PASS_TTL_MS;
return `${expires}.${sign(ip, expires)}`;
}
export function isValidPass(pass: unknown, ip: string): boolean {
if (typeof pass !== "string") return false;
const [exp, mac] = pass.split(".");
const expires = Number(exp);
if (!Number.isFinite(expires) || expires < Date.now() || !mac) return false;
const expected = Buffer.from(sign(ip, expires));
const given = Buffer.from(mac);
return given.length === expected.length && timingSafeEqual(given, expected);
}
export async function verifyToken(token: unknown, ip: string): Promise<boolean> {
if (typeof token !== "string" || token.length === 0 || token.length > 2048) return false;
try {
const res = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
method: "POST",
body: new URLSearchParams({ secret: SECRET, response: token, remoteip: ip }),
signal: AbortSignal.timeout(10_000),
});
const data = (await res.json()) as { success?: boolean; "error-codes"?: string[] };
if (!data.success) console.warn(`[turnstile] rejected: ${(data["error-codes"] ?? []).join(",")}`);
return data.success === true;
} catch (err) {
console.warn(`[turnstile] siteverify failed: ${err}`);
return false;
}
}
+31 -10
View File
@@ -2322,6 +2322,25 @@
display: block; display: block;
} }
/* Flags from the Twemoji Country Flags font (CC-BY 4.0), because Chromium on
Windows has no flag emoji and shows the two letters instead. unicode-range
keeps the font to flag characters and loads it only when one is shown. */
@font-face {
font-family: "Twemoji Country Flags";
src: url("./assets/fonts/TwemojiCountryFlags.woff2") format("woff2");
unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
font-display: swap;
}
.ts-flag {
font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.ts-talk-lamp-away {
font-size: 11px;
line-height: 1;
}
.ts-client-icons { .ts-client-icons {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
@@ -2345,17 +2364,10 @@
} }
.ts-group-badge { .ts-group-badge {
display: inline-flex; display: block;
align-items: center; width: 15px;
justify-content: center; height: 15px;
width: 14px;
height: 14px;
border-radius: 50%;
flex-shrink: 0; flex-shrink: 0;
font-size: 9px;
font-weight: 700;
line-height: 1;
color: #fff;
} }
.ts-poke-button { .ts-poke-button {
@@ -5903,3 +5915,12 @@ input.ts-identities-uid {
.ts-app.ts-mobile.ts-design-ide .ts-tree-panel { .ts-app.ts-mobile.ts-design-ide .ts-tree-panel {
max-height: none; max-height: none;
} }
/* Cloudflare Turnstile: empty unless Cloudflare wants an interaction. */
.ts-turnstile {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 10000;
}
+195 -53
View File
@@ -401,14 +401,73 @@ function loadServerType(): ServerType {
// The gateway's feature list, readable before connecting. TeamSpeak 2 is // The gateway's feature list, readable before connecting. TeamSpeak 2 is
// opt-in per gateway (ENABLE_TS2), so the connect dialog only offers it then. // opt-in per gateway (ENABLE_TS2), so the connect dialog only offers it then.
const FEATURES_URL = DEMO_MODE ? null : FEEDBACK_URL.replace(/\/api\/feedback$/, "/api/features"); const FEATURES_URL = DEMO_MODE ? null : FEEDBACK_URL.replace(/\/api\/feedback$/, "/api/features");
let gatewayFeaturesPromise: Promise<string[]> | null = null; type GatewayInfo = { features?: unknown; turnstileSiteKey?: unknown };
let gatewayInfoPromise: Promise<GatewayInfo> | null = null;
function fetchGatewayInfo(): Promise<GatewayInfo> {
if (!FEATURES_URL) return Promise.resolve({});
gatewayInfoPromise ??= fetch(FEATURES_URL)
.then((r) => (r.ok ? r.json() : {}))
.catch(() => ({}));
return gatewayInfoPromise;
}
function fetchGatewayFeatures(): Promise<string[]> { function fetchGatewayFeatures(): Promise<string[]> {
if (!FEATURES_URL) return Promise.resolve([]); return fetchGatewayInfo().then((d) => (Array.isArray(d.features) ? d.features : []));
gatewayFeaturesPromise ??= fetch(FEATURES_URL) }
.then((r) => (r.ok ? r.json() : { features: [] }))
.then((d) => (Array.isArray(d.features) ? d.features : [])) // Cloudflare Turnstile bot check, only when the gateway asks for it
.catch(() => []); // ("turnstileRequired"). Invisible for most visitors; the widget only shows
return gatewayFeaturesPromise; // up when Cloudflare wants an interaction. The gateway then hands out a pass
// (kept here) so later connects and reconnects skip the check.
const TURNSTILE_PASS_KEY = "ws3.turnstilePass";
type TurnstileApi = {
render: (el: HTMLElement, opts: Record<string, unknown>) => string;
remove: (id: string) => void;
};
let turnstileScript: Promise<TurnstileApi> | null = null;
function loadTurnstile(): Promise<TurnstileApi> {
turnstileScript ??= new Promise((resolve, reject) => {
const s = document.createElement("script");
s.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
s.async = true;
s.onload = () => {
const api = (window as unknown as { turnstile?: TurnstileApi }).turnstile;
if (api) resolve(api);
else reject(new Error("turnstile missing"));
};
s.onerror = () => {
turnstileScript = null;
reject(new Error("turnstile blocked"));
};
document.head.appendChild(s);
});
return turnstileScript;
}
async function getTurnstileToken(): Promise<string> {
const { turnstileSiteKey } = await fetchGatewayInfo();
if (typeof turnstileSiteKey !== "string") return "";
try {
const api = await loadTurnstile();
const box = document.createElement("div");
box.className = "ts-turnstile";
document.body.appendChild(box);
return await new Promise<string>((resolve) => {
let id = "";
const done = (token: string) => {
if (id) api.remove(id);
box.remove();
resolve(token);
};
id = api.render(box, {
sitekey: turnstileSiteKey,
appearance: "interaction-only",
callback: done,
"error-callback": () => done(""),
"timeout-callback": () => done(""),
});
});
} catch {
return "";
}
} }
/** Everything needed to (re)open a gateway connection for one session, kept /** Everything needed to (re)open a gateway connection for one session, kept
@@ -1309,15 +1368,30 @@ function ChannelIcon() {
} }
/** GTS2-style talk lamp: blue idle / green talking / muted mic. */ /** GTS2-style talk lamp: blue idle / green talking / muted mic. */
/** Red "off" badge in the lamp's bottom-right corner, shared by the mute icons. */
const OFF_BADGE = (
<>
<circle cx="10.35" cy="10.35" r="2.55" fill="#e53935" stroke="#1a1a1a" strokeWidth="0.55" />
<path d="M9.35 9.35l2 2M11.35 9.35l-2 2" stroke="#fff" strokeWidth="1.1" strokeLinecap="round" />
</>
);
/** The status slot in front of a client's name. Like the native client, away
* and mute replace the talk dot instead of being listed after the name.
* Order as in TeamSpeak: away, sound muted, mic muted, talking/idle. */
function TalkLamp({ function TalkLamp({
talking, talking,
inputMuted, inputMuted,
inputHardwareEnabled, inputHardwareEnabled,
outputMuted = false,
away = false,
commander = false, commander = false,
}: { }: {
talking: boolean; talking: boolean;
inputMuted: boolean; inputMuted: boolean;
inputHardwareEnabled: boolean; inputHardwareEnabled: boolean;
outputMuted?: boolean;
away?: boolean;
/** Channel commander: drawn as its own lamp when the design option asks for it. */ /** Channel commander: drawn as its own lamp when the design option asks for it. */
commander?: boolean; commander?: boolean;
}) { }) {
@@ -1326,40 +1400,57 @@ function TalkLamp({
const muted = inputMuted || !inputHardwareEnabled; const muted = inputMuted || !inputHardwareEnabled;
const asCommander = commander && tree.commanderLamp; const asCommander = commander && tree.commanderLamp;
if (muted) { const icon = (title: string, packIcon: string, paths: React.ReactNode) => (
<span className="ts-talk-lamp ts-talk-lamp-muted" title={title} aria-hidden="true" data-pack-icon={packIcon}>
<svg width="14" height="14" viewBox="0 0 14 14" focusable="false">
{paths}
</svg>
</span>
);
if (away) {
return ( return (
<span <span className="ts-talk-lamp ts-talk-lamp-muted ts-talk-lamp-away" title={t("tree.away")} aria-hidden="true" data-pack-icon="away">
className="ts-talk-lamp ts-talk-lamp-muted" 💤
title={t("tree.micMuted")}
aria-hidden="true"
data-pack-icon={inputMuted ? "micMuted" : "hardwareMicMuted"}
>
<svg width="14" height="14" viewBox="0 0 14 14" focusable="false">
<path
d="M7 1.4c-1.15 0-2.05.9-2.05 2.05v3.1c0 1.15.9 2.05 2.05 2.05s2.05-.9 2.05-2.05v-3.1C9.05 2.3 8.15 1.4 7 1.4Z"
fill="#9aa3ad"
/>
<path
d="M3.2 6.4v.4c0 2 1.7 3.55 3.8 3.55s3.8-1.55 3.8-3.55v-.4"
fill="none"
stroke="#8a939c"
strokeWidth="1.15"
strokeLinecap="round"
/>
<path d="M7 10.35v2" stroke="#8a939c" strokeWidth="1.15" strokeLinecap="round" />
<path d="M5.2 12.35h3.6" stroke="#8a939c" strokeWidth="1.15" strokeLinecap="round" />
<circle cx="10.35" cy="10.35" r="2.55" fill="#e53935" stroke="#1a1a1a" strokeWidth="0.55" />
<path
d="M9.35 9.35l2 2M11.35 9.35l-2 2"
stroke="#fff"
strokeWidth="1.1"
strokeLinecap="round"
/>
</svg>
</span> </span>
); );
} }
if (outputMuted) {
return icon(
t("tree.soundMuted"),
"soundMuted",
<>
<path d="M1.6 5h2.3l3.2-2.7v8.6L3.9 8.2H1.6Z" fill="#9aa3ad" stroke="#8a939c" strokeWidth="0.5" strokeLinejoin="round" />
<path d="M8.6 4.6c.7.6 1 1.3 1 2s-.3 1.4-1 2" fill="none" stroke="#8a939c" strokeWidth="1.1" strokeLinecap="round" />
{OFF_BADGE}
</>
);
}
if (muted) {
return icon(
t("tree.micMuted"),
inputMuted ? "micMuted" : "hardwareMicMuted",
<>
<path
d="M7 1.4c-1.15 0-2.05.9-2.05 2.05v3.1c0 1.15.9 2.05 2.05 2.05s2.05-.9 2.05-2.05v-3.1C9.05 2.3 8.15 1.4 7 1.4Z"
fill="#9aa3ad"
/>
<path
d="M3.2 6.4v.4c0 2 1.7 3.55 3.8 3.55s3.8-1.55 3.8-3.55v-.4"
fill="none"
stroke="#8a939c"
strokeWidth="1.15"
strokeLinecap="round"
/>
<path d="M7 10.35v2" stroke="#8a939c" strokeWidth="1.15" strokeLinecap="round" />
<path d="M5.2 12.35h3.6" stroke="#8a939c" strokeWidth="1.15" strokeLinecap="round" />
{OFF_BADGE}
</>
);
}
if (talking) { if (talking) {
return ( return (
<span <span
@@ -1383,15 +1474,13 @@ function TalkLamp({
function ClientStatusIcons({ client }: { client: ClientInfo }) { function ClientStatusIcons({ client }: { client: ClientInfo }) {
const t = useT(); const t = useT();
const { tree } = useContext(DisplayPrefsContext); const { tree } = useContext(DisplayPrefsContext);
// Mute is shown on the TalkLamp; keep secondary flags here. // Away and mute are shown on the TalkLamp; keep secondary flags here.
return ( return (
<span className="ts-status-icons"> <span className="ts-status-icons">
{client.isChannelCommander && !tree.commanderLamp && <span title={t("tree.channelCommander")}>⭐</span>} {client.isChannelCommander && !tree.commanderLamp && <span title={t("tree.channelCommander")}>⭐</span>}
{client.away && <span title={t("tree.away")} data-pack-icon="away">💤</span>}
{!client.inputMuted && client.inputHardwareEnabled && !client.hasTalkPower && ( {!client.inputMuted && client.inputHardwareEnabled && !client.hasTalkPower && (
<span title={t("tree.noTalkPower")}>🔒</span> <span title={t("tree.noTalkPower")}>🔒</span>
)} )}
{client.outputMuted && <span title={t("tree.soundMuted")} data-pack-icon="soundMuted">🔕</span>}
{client.isStreaming && <span title={t("tree.streaming")}>📺</span>} {client.isStreaming && <span title={t("tree.streaming")}>📺</span>}
</span> </span>
); );
@@ -1413,9 +1502,15 @@ function GroupIcon({ group, images }: { group: GroupEntry; images: Record<string
const base64 = group.iconId >= CUSTOM_ICON_ID_THRESHOLD ? images[`/icon_${group.iconId}`] : undefined; const base64 = group.iconId >= CUSTOM_ICON_ID_THRESHOLD ? images[`/icon_${group.iconId}`] : undefined;
if (base64) return <img className="ts-group-icon" src={iconDataUrl(base64)} alt="" title={group.name} />; if (base64) return <img className="ts-group-icon" src={iconDataUrl(base64)} alt="" title={group.name} />;
return ( return (
<span className="ts-group-badge" style={{ background: groupBadgeColor(group.iconId) }} title={group.name}> <svg className="ts-group-badge" width="16" height="16" viewBox="0 0 16 16" role="img" aria-label={group.name}>
{group.name.trim().charAt(0).toUpperCase() || "?"} <title>{group.name}</title>
</span> <circle cx="6.5" cy="4.6" r="2.9" fill="#8b95a1" />
<path d="M1 14.6c0-3.3 2.4-5.6 5.5-5.6s5.5 2.3 5.5 5.6Z" fill="#8b95a1" />
<circle cx="11.6" cy="11.4" r="4.1" fill={groupBadgeColor(group.iconId)} stroke="var(--bg, #fff)" strokeWidth="0.9" />
<text x="11.6" y="13.95" textAnchor="middle" fontSize="7" fontWeight="700" fill="#fff" fontFamily="system-ui, sans-serif">
{group.name.trim().charAt(0).toUpperCase() || "?"}
</text>
</svg>
); );
} }
@@ -1453,6 +1548,7 @@ function ChannelTree({
ownClientId, ownClientId,
talkers, talkers,
serverGroups, serverGroups,
channelGroups = null,
groupIconImages, groupIconImages,
selected, selected,
sessionKey, sessionKey,
@@ -1471,6 +1567,8 @@ function ChannelTree({
ownClientId: number | null; ownClientId: number | null;
talkers: Set<number>; talkers: Set<number>;
serverGroups: GroupEntry[] | null; serverGroups: GroupEntry[] | null;
/** For the channel group icon, shown after the server group icons like in the native client. */
channelGroups?: GroupEntry[] | null;
groupIconImages: Record<string, string>; groupIconImages: Record<string, string>;
selected: SelectedItem | null; selected: SelectedItem | null;
/** Identifies which multi-join tab this tree belongs to, so the manual /** Identifies which multi-join tab this tree belongs to, so the manual
@@ -1497,12 +1595,12 @@ function ChannelTree({
const children = channels.filter((c) => c.parent === parent).sort((a, b) => a.order - b.order); const children = channels.filter((c) => c.parent === parent).sort((a, b) => a.order - b.order);
if (children.length === 0) return null; if (children.length === 0) return null;
// Server group icons, then the channel group icon (the flag follows last).
const clientGroupBadges = (client: ClientInfo): GroupEntry[] => const clientGroupBadges = (client: ClientInfo): GroupEntry[] =>
serverGroups [
? client.serverGroups ...(serverGroups ? client.serverGroups.map((gid) => serverGroups.find((g) => g.id === gid)) : []),
.map((gid) => serverGroups.find((g) => g.id === gid)) channelGroups?.find((g) => g.id === client.channelGroup),
.filter((g): g is GroupEntry => !!g && g.iconId !== 0) ].filter((g): g is GroupEntry => !!g && g.iconId !== 0);
: [];
// "Own channel" mode keeps the own channel and the channels above it open. // "Own channel" mode keeps the own channel and the channels above it open.
const ownPath = new Set<number>(); const ownPath = new Set<number>();
@@ -1575,6 +1673,7 @@ function ChannelTree({
ownClientId={ownClientId} ownClientId={ownClientId}
talkers={talkers} talkers={talkers}
serverGroups={serverGroups} serverGroups={serverGroups}
channelGroups={channelGroups}
groupIconImages={groupIconImages} groupIconImages={groupIconImages}
selected={selected} selected={selected}
sessionKey={sessionKey} sessionKey={sessionKey}
@@ -1754,6 +1853,8 @@ function ChannelTree({
} }
inputMuted={c.inputMuted} inputMuted={c.inputMuted}
inputHardwareEnabled={c.inputHardwareEnabled} inputHardwareEnabled={c.inputHardwareEnabled}
outputMuted={c.outputMuted}
away={c.away}
commander={c.isChannelCommander} commander={c.isChannelCommander}
/> />
<span className="ts-client-status-leading"> <span className="ts-client-status-leading">
@@ -1765,7 +1866,6 @@ function ChannelTree({
className="ts-client-avatar" className="ts-client-avatar"
isSelf={c.id === ownClientId} isSelf={c.id === ownClientId}
/> />
{tree.flags && countryFlag(c.country) && <span title={c.country}>{countryFlag(c.country)}</span>}
<span className="ts-tree-label">{c.name}</span> <span className="ts-tree-label">{c.name}</span>
{tree.awayMessage && c.away && c.awayMessage && ( {tree.awayMessage && c.away && c.awayMessage && (
<span className="ts-client-away-message">({c.awayMessage})</span> <span className="ts-client-away-message">({c.awayMessage})</span>
@@ -1774,6 +1874,9 @@ function ChannelTree({
{clientGroupBadges(c).map((g) => ( {clientGroupBadges(c).map((g) => (
<GroupIcon key={g.id} group={g} images={groupIconImages} /> <GroupIcon key={g.id} group={g} images={groupIconImages} />
))} ))}
{tree.flags && countryFlag(c.country) && (
<span className="ts-flag" title={c.country}>{countryFlag(c.country)}</span>
)}
</span> </span>
</div> </div>
</li> </li>
@@ -1970,6 +2073,8 @@ function InfoPanel({
talking={false} talking={false}
inputMuted={client.inputMuted} inputMuted={client.inputMuted}
inputHardwareEnabled={client.inputHardwareEnabled} inputHardwareEnabled={client.inputHardwareEnabled}
outputMuted={client.outputMuted}
away={client.away}
/> />
<span>{client.name}</span> <span>{client.name}</span>
</div> </div>
@@ -1980,7 +2085,7 @@ function InfoPanel({
<div className="ts-info-row"> <div className="ts-info-row">
<span>{t("info.country")}</span>{" "} <span>{t("info.country")}</span>{" "}
<span> <span>
{countryFlag(client.country) ? `${countryFlag(client.country)} ` : ""} {countryFlag(client.country) && <span className="ts-flag">{countryFlag(client.country)} </span>}
{client.country} {client.country}
</span> </span>
</div> </div>
@@ -9941,10 +10046,17 @@ function AppInner() {
const connectFavoriteId = params.favoriteId; const connectFavoriteId = params.favoriteId;
const connectIdentityBlob = identities.find((i) => i.id === connectIdentityId)?.blob ?? undefined; const connectIdentityBlob = identities.find((i) => i.id === connectIdentityId)?.blob ?? undefined;
const onopen = () => { const sendConnect = (extra: Record<string, unknown> = {}) => {
logClient("info", "Connection", `Connecting to ${connectHost}…`); let turnstilePass: string | undefined;
try {
turnstilePass = localStorage.getItem(TURNSTILE_PASS_KEY) ?? undefined;
} catch {
/* storage blocked */
}
socket.send( socket.send(
JSON.stringify({ JSON.stringify({
...extra,
turnstilePass,
type: "connect", type: "connect",
host: connectHost, host: connectHost,
nickname: connectNickname, nickname: connectNickname,
@@ -9959,6 +10071,10 @@ function AppInner() {
}) })
); );
}; };
const onopen = () => {
logClient("info", "Connection", `Connecting to ${connectHost}…`);
sendConnect();
};
// Downloads arrive in pieces (see the connector's TRANSFER_CHUNK_BYTES), // Downloads arrive in pieces (see the connector's TRANSFER_CHUNK_BYTES),
// keyed by channel + path; every piece but the last is a whole number of // keyed by channel + path; every piece but the last is a whole number of
@@ -9998,6 +10114,20 @@ function AppInner() {
setTurnServers(Array.isArray(data.iceServers) ? data.iceServers : []); setTurnServers(Array.isArray(data.iceServers) ? data.iceServers : []);
return; return;
} }
if (data.type === "turnstileRequired") {
void getTurnstileToken().then((turnstileToken) => {
if (socket.readyState === WebSocket.OPEN) sendConnect({ turnstileToken });
});
return;
}
if (data.type === "turnstilePass") {
try {
localStorage.setItem(TURNSTILE_PASS_KEY, String(data.pass));
} catch {
/* storage blocked: the check just runs again next time */
}
return;
}
// Inactive tab: update parked snapshot only (no audio playback). // Inactive tab: update parked snapshot only (no audio playback).
if (sessionId !== activeSessionIdRef.current) { if (sessionId !== activeSessionIdRef.current) {
@@ -10378,7 +10508,13 @@ function AppInner() {
appendLog({ text: data.message, kind: "error" }); appendLog({ text: data.message, kind: "error" });
} else { } else {
setConnecting(false); setConnecting(false);
setConnectError(data.code === "gateway_full" ? t("connectError.gatewayFull") : data.message); setConnectError(
data.code === "gateway_full"
? t("connectError.gatewayFull")
: data.code === "turnstile_failed"
? t("connectError.botCheck")
: data.message
);
updateTabMeta(sessionId, { connecting: false, connected: false }); updateTabMeta(sessionId, { connecting: false, connected: false });
} }
break; break;
@@ -11106,6 +11242,10 @@ function AppInner() {
if (!connected || serverGroups) return; if (!connected || serverGroups) return;
socketRef.current?.send(JSON.stringify({ type: "getServerGroupList" })); socketRef.current?.send(JSON.stringify({ type: "getServerGroupList" }));
}, [connected, serverGroups]); }, [connected, serverGroups]);
useEffect(() => {
if (!connected || channelGroups) return;
socketRef.current?.send(JSON.stringify({ type: "getChannelGroupList" }));
}, [connected, channelGroups]);
// Same icon-file cache as the server icons dialog (fileDownloadData for // Same icon-file cache as the server icons dialog (fileDownloadData for
// cid 0 always lands in serverIconImages, regardless of who asked) - fetch // cid 0 always lands in serverIconImages, regardless of who asked) - fetch
@@ -11119,13 +11259,14 @@ function AppInner() {
useEffect(() => { useEffect(() => {
if (!serverGroups) return; if (!serverGroups) return;
const iconById = new Map(serverGroups.map((g) => [g.id, g.iconId])); const iconById = new Map(serverGroups.map((g) => [g.id, g.iconId]));
const channelIconById = new Map((channelGroups ?? []).map((g) => [g.id, g.iconId]));
// Plus every group listed in an open group menu, so unassigned ones show their icon too. // Plus every group listed in an open group menu, so unassigned ones show their icon too.
const menuGroups = !groupAssignTarget const menuGroups = !groupAssignTarget
? [] ? []
: ((groupAssignTarget.kind === "channel" ? channelGroups : serverGroups) ?? []); : ((groupAssignTarget.kind === "channel" ? channelGroups : serverGroups) ?? []);
const wantedIconIds = new Set( const wantedIconIds = new Set(
clients clients
.flatMap((c) => c.serverGroups.map((gid) => iconById.get(gid) ?? 0)) .flatMap((c) => [...c.serverGroups.map((gid) => iconById.get(gid) ?? 0), channelIconById.get(c.channelGroup) ?? 0])
.concat(menuGroups.map((g) => g.iconId)) .concat(menuGroups.map((g) => g.iconId))
.filter((id) => id >= CUSTOM_ICON_ID_THRESHOLD) .filter((id) => id >= CUSTOM_ICON_ID_THRESHOLD)
); );
@@ -14572,6 +14713,7 @@ function AppInner() {
ownClientId={ownClientId ?? ownClient?.id ?? null} ownClientId={ownClientId ?? ownClient?.id ?? null}
talkers={displayTalkers} talkers={displayTalkers}
serverGroups={serverGroups} serverGroups={serverGroups}
channelGroups={channelGroups}
groupIconImages={serverIconImages} groupIconImages={serverIconImages}
selected={selected} selected={selected}
sessionKey={activeSessionId ?? ""} sessionKey={activeSessionId ?? ""}
Binary file not shown.
+1
View File
@@ -718,6 +718,7 @@
"serverContext.disconnect": "Odpojit", "serverContext.disconnect": "Odpojit",
"connectError.dismiss": "Zavřít", "connectError.dismiss": "Zavřít",
"connectError.gatewayFull": "Brána je právě plná. Zkus to za pár minut znovu – nebo si WebSpeak3 hostuj sám: github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "Brána je právě plná. Zkus to za pár minut znovu – nebo si WebSpeak3 hostuj sám: github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "Kontrola proti botům selhala. Obnov stránku a zkus to znovu. Blokátory reklam nebo skriptů mohou kontrole bránit.",
"dialog.close": "Zavřít", "dialog.close": "Zavřít",
"sounds.title": "Zvuky", "sounds.title": "Zvuky",
"sounds.subtitle": "Nastavit zvuková upozornění na události", "sounds.subtitle": "Nastavit zvuková upozornění na události",
+1
View File
@@ -718,6 +718,7 @@
"serverContext.disconnect": "Verbindung trennen", "serverContext.disconnect": "Verbindung trennen",
"connectError.dismiss": "Schließen", "connectError.dismiss": "Schließen",
"connectError.gatewayFull": "Das Gateway ist gerade voll. Versuch es in ein paar Minuten nochmal – oder hoste WebSpeak3 selbst: github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "Das Gateway ist gerade voll. Versuch es in ein paar Minuten nochmal – oder hoste WebSpeak3 selbst: github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "Bot-Prüfung fehlgeschlagen. Bitte lade die Seite neu und versuch es noch mal. Werbe- oder Skriptblocker können die Prüfung stören.",
"dialog.close": "Schließen", "dialog.close": "Schließen",
"sounds.title": "Sounds", "sounds.title": "Sounds",
"sounds.subtitle": "Sound-Benachrichtigungen für Ereignisse festlegen", "sounds.subtitle": "Sound-Benachrichtigungen für Ereignisse festlegen",
+1
View File
@@ -718,6 +718,7 @@
"serverContext.disconnect": "Disconnect", "serverContext.disconnect": "Disconnect",
"connectError.dismiss": "Dismiss", "connectError.dismiss": "Dismiss",
"connectError.gatewayFull": "The gateway is full right now. Try again in a few minutes – or host WebSpeak3 yourself: github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "The gateway is full right now. Try again in a few minutes – or host WebSpeak3 yourself: github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "Bot check failed. Please reload the page and try again. Ad or script blockers can get in the way of the check.",
"dialog.close": "Close", "dialog.close": "Close",
"sounds.title": "Sounds", "sounds.title": "Sounds",
"sounds.subtitle": "Configure sound notifications for events", "sounds.subtitle": "Configure sound notifications for events",
+1
View File
@@ -717,6 +717,7 @@
"serverContext.disconnect": "قطع اتصال", "serverContext.disconnect": "قطع اتصال",
"connectError.dismiss": "رد کردن", "connectError.dismiss": "رد کردن",
"connectError.gatewayFull": "گیت‌وی در حال حاضر پر است. چند دقیقه دیگر دوباره امتحان کنید – یا WebSpeak3 را خودتان میزبانی کنید: github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "گیت‌وی در حال حاضر پر است. چند دقیقه دیگر دوباره امتحان کنید – یا WebSpeak3 را خودتان میزبانی کنید: github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "بررسی ضد ربات ناموفق بود. لطفاً صفحه را دوباره بارگذاری کنید و دوباره امتحان کنید. مسدودکننده‌های تبلیغات یا اسکریپت ممکن است مانع بررسی شوند.",
"dialog.close": "بستن", "dialog.close": "بستن",
"sounds.title": "صداها", "sounds.title": "صداها",
"sounds.subtitle": "پیکربندی اعلان‌های صوتی برای رویدادها", "sounds.subtitle": "پیکربندی اعلان‌های صوتی برای رویدادها",
+1
View File
@@ -718,6 +718,7 @@
"serverContext.disconnect": "Отключиться", "serverContext.disconnect": "Отключиться",
"connectError.dismiss": "Закрыть", "connectError.dismiss": "Закрыть",
"connectError.gatewayFull": "Шлюз сейчас переполнен. Попробуйте через несколько минут – или разверните WebSpeak3 у себя: github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "Шлюз сейчас переполнен. Попробуйте через несколько минут – или разверните WebSpeak3 у себя: github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "Проверка на бота не пройдена. Обновите страницу и попробуйте снова. Блокировщики рекламы или скриптов могут мешать проверке.",
"dialog.close": "Закрыть", "dialog.close": "Закрыть",
"sounds.title": "Звуки", "sounds.title": "Звуки",
"sounds.subtitle": "Настройка звуковых уведомлений о событиях", "sounds.subtitle": "Настройка звуковых уведомлений о событиях",
+1
View File
@@ -559,6 +559,7 @@
"serverContext.disconnect": "断开连接", "serverContext.disconnect": "断开连接",
"connectError.dismiss": "关闭", "connectError.dismiss": "关闭",
"connectError.gatewayFull": "网关当前已满。请几分钟后再试,或自行部署 WebSpeak3:github.com/WebSpeak3/webspeak3", "connectError.gatewayFull": "网关当前已满。请几分钟后再试,或自行部署 WebSpeak3:github.com/WebSpeak3/webspeak3",
"connectError.botCheck": "人机验证失败。请刷新页面后重试。广告或脚本拦截器可能会干扰验证。",
"dialog.close": "关闭", "dialog.close": "关闭",
"sounds.title": "声音", "sounds.title": "声音",
"sounds.subtitle": "配置事件提示音", "sounds.subtitle": "配置事件提示音",