TS2: registered login and Auto fallback

- Connector: --login-name/--login-password (TS_LOGIN_NAME/TS_LOGIN_PASSWORD)
  send a registered login (flag 2 + account name + password).
- Server type "auto" retries as TeamSpeak 2 when the TS3 handshake gets no
  answer, only with ENABLE_TS2=1. Default port 9987 is swapped for 8767.
- Gateway and connect dialog pass account name/password for TS2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-11-12 18:38:37 +00:00
1 parent 83877aaa76
commit bfe05a8b02
12 files changed
+107 -10

No files matched your search

+2 -2
View File
@@ -101,7 +101,7 @@ not need to be installed on the same machine, modified, or operated by you.
| 🔁 **Seamless reconnect** | Switch or add connections mid-session without tearing down unrelated tabs; dropped connections come back on their own, with the channel tree intact |
| ⌨️ **Keyboard & screen readers** | Arrow keys through the channel tree (exposed as an ARIA tree) and through menus, Enter joins, context-menu key opens the menu; focus-trapped dialogs, labelled toolbar buttons |
| 🍵 **VoySpeak support** | Connects to real VoySpeak servers (formerly GreenTeaSpeak), not just TS3/TS6/TeaSpeak |
| 📟 **TeamSpeak 2** | <sub>**EXPERIMENTAL**</sub> Voice, channels, private messages and server messages on old TS2 servers. Off by default, the gateway enables it with `ENABLE_TS2=1` |
| 📟 **TeamSpeak 2** | <sub>**EXPERIMENTAL**</sub> Voice, channels, private messages and server messages on old TS2 servers. Registered accounts work too, and the server type "Auto" detects TS2 on its own. Off by default, the gateway enables it with `ENABLE_TS2=1` |
| 🖥️ **Screen streaming to/from TS6** | <sub>**ALPHA · UNSTABLE**</sub> Share your screen to native TeamSpeak 6 clients and watch theirs. Built on TS6's undocumented Stream/Call protocol — expect it to break; see [Roadmap](ROADMAP.md) |
## 🧱 Tech Stack
@@ -249,7 +249,7 @@ All optional; add them under `environment:` in your compose override next to `PO
| `NEWS_TICKER` | on | Set to `0` to hide the news ticker at the bottom of the client. |
| `NEWS_TICKER_CENTRAL` | on | Set to `0` to drop the official WebSpeak3 news (releases, new store designs, announcements) and only show your own messages. |
| `NEWS_TICKER_MESSAGES` | – | Your own ticker messages, separated by `\|`, e.g. `Maintenance tonight at 10pm \| Welcome!` |
| `ENABLE_TS2` | off | Set to `1` to offer **TeamSpeak 2** as a server type in the connect dialog. Experimental: voice (Speex), channel list, private messages and server messages work; channel chat depends on the server's permissions; file transfer, avatars, screen streams and admin functions aren't available on TS2. The code ships in every image, it just stays unused while this is off. |
| `ENABLE_TS2` | off | Set to `1` to offer **TeamSpeak 2** as a server type in the connect dialog. Experimental: voice (Speex), channel list, private messages and server messages work; channel chat depends on the server's permissions; file transfer, avatars, screen streams and admin functions aren't available on TS2. Also lets the server type "Auto" fall back to TS2 when a server gives no TS3 answer, and adds account name and password fields for registered TS2 logins. The code ships in every image, it just stays unused while this is off. |
| `SYNC_URL` | official sync server | Account sync server your visitors use (Options → Account), e.g. `https://sync.example.com/api/sync`. Only needed if you run your own (see below). |
> **Anonymous usage ping:** when the gateway starts and then once a day, it sends a random instance ID (made up on first start, stored in `instance-id` in the working directory, used for nothing else) and its version number to `gateway.webspeak3.de`. That's the only way to tell whether anyone self-hosts WebSpeak3 at all, and how many instances still run an old version, e.g. after a security fix. Nothing else is sent: no hostnames, no TeamSpeak servers, no users, no settings. The receiving side doesn't store IP addresses. The startup log says when it's on. Turn it off with `TELEMETRY=0`.
+28 -2
View File
@@ -72,7 +72,7 @@ const MAX_ICON_BYTES: u64 = 512 << 10;
const MAX_AVATAR_BYTES: u64 = 512 << 10;
const OUT_CHANNELS: usize = 2;
#[derive(Parser, Debug)]
#[derive(Parser, Debug, Clone)]
#[command(author, about = "One-shot bridge: connects to a real TeamSpeak server and reports events as JSON lines on stdout")]
struct Args {
/// Server address, e.g. "192.168.178.108" or "192.168.178.108:9987"
@@ -107,6 +107,12 @@ struct Args {
/// Privilege key / token (`client_default_token` in clientinit).
#[arg(long, alias = "token", env = "TS_PRIVILEGE_KEY", hide_env_values = true)]
privilege_key: Option<String>,
/// TeamSpeak 2 only: account name for a registered login (anonymous when omitted).
#[arg(long, env = "TS_LOGIN_NAME", hide_env_values = true)]
login_name: Option<String>,
/// TeamSpeak 2 only: password of the registered account.
#[arg(long, env = "TS_LOGIN_PASSWORD", hide_env_values = true)]
login_password: Option<String>,
}
#[derive(Serialize)]
@@ -870,7 +876,27 @@ fn send_server_get_variables(con: &mut tsclientlib::Connection) {
#[tokio::main]
async fn main() {
let args = Args::parse();
let result = if args.server_type == "ts2" { ts2::run(args).await } else { run(args).await };
// "auto" falls back to TeamSpeak 2 when the TS3 handshake gets no answer at
// all; only if the gateway enables TS2 (ENABLE_TS2=1, inherited env).
let ts2_fallback = args.server_type == "auto" && std::env::var("ENABLE_TS2").as_deref() == Ok("1");
let result = if args.server_type == "ts2" {
ts2::run(args).await
} else if ts2_fallback {
match run(args.clone()).await {
Err(e) if e.to_string().contains("connection timed out") => {
eprintln!("no TS3 answer, trying TeamSpeak 2");
// Only the TS3 default port is swapped; an explicit other port is kept.
let mut args = args;
if let Some(host) = args.address.strip_suffix(":9987") {
args.address = host.to_string();
}
ts2::run(args).await.map_err(|_| e)
}
r => r,
}
} else {
run(args).await
};
if let Err(e) = result {
emit(&Event::Error { message: e.to_string() });
}
+16 -6
View File
@@ -732,11 +732,21 @@ async fn login(sock: &UdpSocket, args: &Args) -> Result<Vec<u8>> {
p.extend_from_slice(&[0; 4]); // CRC
p.extend_from_slice(&pstr("TeamSpeak"));
p.extend_from_slice(&pstr("Linux"));
p.extend_from_slice(&[2, 0, 0, 0, 0x20, 0, 0x3c, 0, 1, 1]);
// Anonymous login: no account name, the server password goes in the
// password field.
p.extend_from_slice(&pstr(""));
p.extend_from_slice(&pstr(args.server_password.as_deref().unwrap_or("")));
p.extend_from_slice(&[2, 0, 0, 0, 0x20, 0, 0x3c, 0, 1]);
// Registered login (2): account name + its password. Anonymous (1): no
// account name, the server password goes in the password field.
match &args.login_name {
Some(name) if !name.is_empty() => {
p.push(2);
p.extend_from_slice(&pstr(name));
p.extend_from_slice(&pstr(args.login_password.as_deref().unwrap_or("")));
}
_ => {
p.push(1);
p.extend_from_slice(&pstr(""));
p.extend_from_slice(&pstr(args.server_password.as_deref().unwrap_or("")));
}
}
p.extend_from_slice(&pstr(&args.nickname));
crc(&mut p, 16);
let mut buf = [0u8; 2048];
@@ -778,7 +788,7 @@ which this gateway does not connect to. (Self-hosting admin? Set ALLOW_PRIVATE_T
let reply = login(&sock, &args).await?;
if reply[89..92] != [0, 0, 0] {
bail!("The TeamSpeak 2 server rejected the login (wrong server password, or nickname not allowed).");
bail!("The TeamSpeak 2 server rejected the login (wrong server password, wrong account name or password, or nickname not allowed).");
}
// Unlike the 30-byte fields, the welcome message's length byte can go up to 255.
let welcome_len = reply[180] as usize;
+2
View File
@@ -774,6 +774,8 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => {
identity: msg.identity,
serverType: parseServerType(msg.serverType),
privilegeKey: parsePrivilegeKey(msg),
loginName: typeof msg.loginName === "string" ? msg.loginName.trim() || undefined : undefined,
loginPassword: typeof msg.loginPassword === "string" ? msg.loginPassword || undefined : undefined,
};
connection = new Ts3Connection(options);
liveConnections.add(connection);
+5
View File
@@ -228,6 +228,9 @@ export interface Ts3ConnectOptions {
serverType?: ServerType;
/** One-time privilege key / token to redeem on connect. */
privilegeKey?: string;
/** TeamSpeak 2 registered account (anonymous when omitted). */
loginName?: string;
loginPassword?: string;
}
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -280,6 +283,8 @@ export class Ts3Connection {
if (this.options.channelPassword) env.TS_CHANNEL_PASSWORD = this.options.channelPassword;
if (this.options.identity) env.TS_IDENTITY = this.options.identity;
if (this.options.privilegeKey) env.TS_PRIVILEGE_KEY = this.options.privilegeKey;
if (this.options.loginName) env.TS_LOGIN_NAME = this.options.loginName;
if (this.options.loginPassword) env.TS_LOGIN_PASSWORD = this.options.loginPassword;
this.child = spawn(CONNECTOR_BIN, args, { env });
// The connector can exit on its own (e.g. the TS3 server drops it) and close
+42
View File
@@ -421,6 +421,9 @@ type ConnectParams = {
channelPassword: string;
defaultChannel: string;
privilegeKey: string;
/** TeamSpeak 2 registered account (anonymous when empty). */
loginName?: string;
loginPassword?: string;
serverType: ServerType;
identityId: string | null;
favoriteId: string | null;
@@ -2106,6 +2109,8 @@ function ConnectDialog({
defaultChannel,
privilegeKey,
serverType,
loginName,
loginPassword,
expanded,
connecting,
identities,
@@ -2117,6 +2122,8 @@ function ConnectDialog({
onDefaultChannelChange,
onPrivilegeKeyChange,
onServerTypeChange,
onLoginNameChange,
onLoginPasswordChange,
onActiveIdentityChange,
onToggleExpanded,
onConnect,
@@ -2133,6 +2140,8 @@ function ConnectDialog({
defaultChannel: string;
privilegeKey: string;
serverType: ServerType;
loginName: string;
loginPassword: string;
expanded: boolean;
connecting: boolean;
identities: Identity[];
@@ -2143,6 +2152,8 @@ function ConnectDialog({
onChannelPasswordChange: (v: string) => void;
onDefaultChannelChange: (v: string) => void;
onPrivilegeKeyChange: (v: string) => void;
onLoginNameChange: (v: string) => void;
onLoginPasswordChange: (v: string) => void;
onServerTypeChange: (v: ServerType) => void;
onActiveIdentityChange: (id: string) => void;
onToggleExpanded: () => void;
@@ -2300,6 +2311,27 @@ function ConnectDialog({
)}
</select>
</label>
{serverType === "ts2" && (
<>
<label className="ts-dialog-field">
{t("connect.ts2LoginName")}
<input
value={loginName}
onChange={(e) => onLoginNameChange(e.target.value)}
autoComplete="username"
/>
</label>
<label className="ts-dialog-field">
{t("connect.ts2LoginPassword")}
<input
type="password"
value={loginPassword}
onChange={(e) => onLoginPasswordChange(e.target.value)}
autoComplete="current-password"
/>
</label>
</>
)}
<label className="ts-dialog-field">
{t("connect.hotkeyProfile")}
<select disabled defaultValue="Standard">
@@ -8824,6 +8856,8 @@ function AppInner() {
const [channelPassword, setChannelPassword] = useState("");
const [defaultChannel, setDefaultChannel] = useState("");
const [privilegeKey, setPrivilegeKey] = useState("");
const [loginName, setLoginName] = useState("");
const [loginPassword, setLoginPassword] = useState("");
const [serverType, setServerType] = useState<ServerType>(loadServerType);
// Prompt shown when switching into a password-protected channel mid-session
// (the initial-connect "default channel" password above is a separate field).
@@ -9920,6 +9954,8 @@ function AppInner() {
identity: connectIdentityBlob || undefined,
privilegeKey: connectPrivilegeKey.trim() || undefined,
serverType: connectServerType || "auto",
loginName: (connectServerType === "ts2" && params.loginName?.trim()) || undefined,
loginPassword: (connectServerType === "ts2" && params.loginPassword) || undefined,
})
);
};
@@ -10594,6 +10630,8 @@ function AppInner() {
defaultChannel: overrides?.defaultChannel ?? defaultChannel,
privilegeKey: overrides?.privilegeKey ?? privilegeKey,
serverType: overrides?.serverType ?? serverType,
loginName,
loginPassword,
identityId: activeIdentityId,
favoriteId: overrides?.favoriteId !== undefined ? overrides.favoriteId : null,
};
@@ -13499,6 +13537,8 @@ function AppInner() {
defaultChannel={defaultChannel}
privilegeKey={privilegeKey}
serverType={serverType}
loginName={loginName}
loginPassword={loginPassword}
expanded={connectDialogExpanded}
connecting={connecting}
identities={identities}
@@ -13510,6 +13550,8 @@ function AppInner() {
onDefaultChannelChange={setDefaultChannel}
onPrivilegeKeyChange={setPrivilegeKey}
onServerTypeChange={setServerType}
onLoginNameChange={setLoginName}
onLoginPasswordChange={setLoginPassword}
onActiveIdentityChange={handleActiveIdentityChange}
onToggleExpanded={() => setConnectDialogExpanded((v) => !v)}
onConnect={() => handleConnect({ host: dialogHost })}
+2
View File
@@ -126,6 +126,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2 (experimentální)",
"connect.ts2LoginName": "Název účtu TS2 (prázdné = anonymně):",
"connect.ts2LoginPassword": "Heslo účtu TS2:",
"connect.hotkeyProfile": "Profil klávesových zkratek:",
"connect.soundPack": "Balíček zvuků:",
"connect.more": "Více",
+2
View File
@@ -126,6 +126,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2 (experimentell)",
"connect.ts2LoginName": "TS2-Kontoname (leer = anonym):",
"connect.ts2LoginPassword": "TS2-Kontopasswort:",
"connect.hotkeyProfile": "Hotkeyprofil:",
"connect.soundPack": "Sound Pack:",
"connect.more": "Mehr",
+2
View File
@@ -126,6 +126,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2 (experimental)",
"connect.ts2LoginName": "TS2 account name (empty = anonymous):",
"connect.ts2LoginPassword": "TS2 account password:",
"connect.hotkeyProfile": "Hotkey profile:",
"connect.soundPack": "Sound pack:",
"connect.more": "More",
+2
View File
@@ -126,6 +126,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2 (آزمایشی)",
"connect.ts2LoginName": "نام حساب TS2 (خالی = ناشناس):",
"connect.ts2LoginPassword": "رمز حساب TS2:",
"connect.hotkeyProfile": "پروفایل کلید میانبر:",
"connect.soundPack": "بسته صوتی:",
"connect.more": "بیشتر",
+2
View File
@@ -126,6 +126,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2 (экспериментально)",
"connect.ts2LoginName": "Имя учётной записи TS2 (пусто = анонимно):",
"connect.ts2LoginPassword": "Пароль учётной записи TS2:",
"connect.hotkeyProfile": "Профиль горячих клавиш:",
"connect.soundPack": "Звуковой пакет:",
"connect.more": "Больше",
+2
View File
@@ -70,6 +70,8 @@
"connect.serverType.teamspeak": "TeamSpeak",
"connect.serverType.teaspeak": "TeaSpeak",
"connect.serverType.ts2": "TeamSpeak 2(实验性)",
"connect.ts2LoginName": "TS2 账户名(留空 = 匿名):",
"connect.ts2LoginPassword": "TS2 账户密码:",
"connect.hotkeyProfile": "快捷键配置:",
"connect.soundPack": "声音包:",
"connect.more": "更多",