ci, docs: CI workflow, cargo-deny, architecture and TS6 protocol notes

- .github/workflows/ci.yml: fmt/clippy (strict for own crates), build and
  test on ubuntu-24.04 and windows-2025, cargo-deny, TS3/TS6 smoke test
- deny.toml: permissive licenses only, advisories, sources
- README, docs/architecture.md (design + milestones),
  docs/protocol-notes/ts6-streaming.md incl. first probe results
  against 6.0.0-beta13.1 (setupstream works for guests,
  joinstreamrequest exists)
- tsctl repl: /raw command

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 13:08:34 +00:00
1 parent ebeec4c2e3
commit b72df027fa
6 files changed
+392

No files matched your search

+82
View File
@@ -0,0 +1,82 @@
name: CI
on:
push:
branches: [main, master]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "0"
jobs:
lint:
name: fmt + clippy
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install toolchain (rust-toolchain.toml)
run: rustup toolchain install
- uses: Swatinem/rust-cache@v2
# The vendored crates in crates/proto use upstream's nightly rustfmt config
# and have known clippy findings (cleanup is milestone M1), so the strict
# checks cover our own crates only.
- name: rustfmt (own crates)
run: cargo fmt -p tsctl --check
- name: clippy (own crates, deny warnings)
run: cargo clippy -p tsctl --all-targets --no-deps -- -D warnings
- name: clippy (workspace, report only)
run: cargo clippy --workspace --all-targets
test:
name: test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, windows-2025]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install toolchain (rust-toolchain.toml)
run: rustup toolchain install
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --workspace --all-targets --locked
- name: Test
run: cargo test --workspace --locked
deny:
name: cargo-deny
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
smoke:
name: integration smoke (TS3 + TS6)
runs-on: ubuntu-24.04
needs: test
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
- name: Install toolchain (rust-toolchain.toml)
run: rustup toolchain install
- uses: Swatinem/rust-cache@v2
- name: Start TeamSpeak servers
run: docker compose -f dev/docker-compose.yml up -d
- name: Smoke test
run: scripts/it-smoke.sh
- name: Server logs
if: failure()
run: docker compose -f dev/docker-compose.yml logs --no-color
+61
View File
@@ -0,0 +1,61 @@
# teamspeak_client_rs
A TeamSpeak 3 / TeamSpeak 6 compatible voice client written in Rust, for desktop
(Linux Wayland/X11, Windows, later macOS) and mobile (Android, later iOS).
It speaks the TeamSpeak client protocol itself (no official SDK). The protocol
layer is a vendored fork of [ReSpeak/tsclientlib](https://github.com/ReSpeak/tsclientlib).
> Not affiliated with or endorsed by TeamSpeak Systems GmbH. "TeamSpeak" is a
> trademark of its owner; the product name of this client is still to be decided.
## Goals
| Feature | How |
|---|---|
| Global server chat | Native `sendtextmessage targetmode=3` |
| Chat in channels without joining their voice channel | Relay through invisible ServerQuery sessions (companion gateway `tsgw`, or own query credentials). The protocol only delivers channel chat for the channel you are in. |
| Voice | Opus over the TS3 UDP protocol, echo cancellation, jitter buffer |
| See who is in voice channels without joining | Channel subscriptions when connected; invisible presence through the gateway or own query credentials |
| Watch and share screen with sound | TeamSpeak 6 servers only: WebRTC peer-to-peer streams signalled through the server |
See [docs/architecture.md](docs/architecture.md) for the design and milestones.
## Status
Milestone **M0 (foundation)**:
- `crates/proto/`: vendored tsclientlib (see [UPSTREAM.md](crates/proto/UPSTREAM.md) for the patch log)
- `tools/tsctl`: headless CLI that connects, prints the channel tree, sends and receives chat
- `dev/`: TeamSpeak 3.13 and TeamSpeak 6 (6.0.0-beta13.1) servers for local testing
- CI: build and test on Linux and Windows, `cargo-deny`, smoke test against both servers
No GUI, voice or screen sharing yet.
## Try it
```sh
# Local servers (use REGISTRY=mirror.gcr.io if Docker Hub rate-limits you)
docker compose -f dev/docker-compose.yml up -d
cargo run -p tsctl -- connect 127.0.0.1:9987 tree # TeamSpeak 3
cargo run -p tsctl -- connect 127.0.0.1:9988 tree # TeamSpeak 6
cargo run -p tsctl -- connect 127.0.0.1:9988 --nick me repl # interactive chat
scripts/it-smoke.sh # tree + server/channel chat round-trips on both servers
```
Other commands: `tsctl identity new`, `tsctl versions`, `tsctl connect <addr> listen|chat|raw`.
`tsctl --help` lists all options.
Building on Linux needs the ALSA headers (`libasound2-dev`) for the audio examples,
plus CMake and a C compiler for the bundled libopus.
## License
The vendored crates in `crates/proto/` are `MIT OR Apache-2.0` (upstream
`LICENSE-MIT` / `LICENSE-APACHE` are kept there). New crates are declared under
the same terms in `Cargo.toml`.
Third-party notices: the planned UI toolkit, Slint, is used under its
royalty-free license, which requires an attribution in the app's About page.
+36
View File
@@ -0,0 +1,36 @@
# cargo-deny configuration: https://embarkstudios.github.io/cargo-deny/
[graph]
all-features = false
[advisories]
# Unmaintained crates are reported but only fail for direct dependencies.
unmaintained = "workspace"
ignore = []
[licenses]
# Permissive licenses only. AGPL/GPL code (e.g. astrum-ts6) must never be
# linked; LGPL may be revisited for dynamically linked codecs.
allow = [
"MIT",
"Apache-2.0",
"Apache-2.0 WITH LLVM-exception",
"BSD-2-Clause",
"BSD-3-Clause",
"ISC",
"Zlib",
"Unicode-3.0",
"CDLA-Permissive-2.0",
"MPL-2.0",
"BSL-1.0",
]
confidence-threshold = 0.9
[bans]
multiple-versions = "allow"
wildcards = "deny"
allow-wildcard-paths = true
[sources]
unknown-registry = "deny"
unknown-git = "deny"
+96
View File
@@ -0,0 +1,96 @@
# Architecture
This document condenses the project plan: what the client must do, which protocol
facts constrain it, how the code is organised, and the milestone order.
## Protocol facts that shape the design
- **Channel chat** (`sendtextmessage targetmode=2`) always goes to the sender's
*current* channel, on both TeamSpeak 3 and TeamSpeak 6. There is no protocol
way to read or post in another channel.
- **Presence**: a connected client always sits in some channel and is visible
there. Only ServerQuery clients are invisible. TeamSpeak 6 has no raw query:
SSH on 10022 and HTTP WebQuery (API key) on 10080/10443.
- **Screen sharing** exists only on TeamSpeak 6: peer-to-peer WebRTC (STUN only),
with the server relaying signalling commands (`setupstream`,
`respondjoinstreamrequest`, `streamsignaling`, `notifystream*`, ...). See
[protocol-notes/ts6-streaming.md](protocol-notes/ts6-streaming.md).
- `clientinit` must carry a `client_version_sign` signed by TeamSpeak, so the
client reuses known version/signature pairs (`tsctl versions`).
- TeamSpeak 6 servers still accept the TeamSpeak 3 client protocol; verified with
`tsctl` against 6.0.0-beta13.1.
## How each feature is delivered
| Feature | Mechanism |
|---|---|
| Server chat | Voice connection: `targetmode=3`. Without one: gateway or own query session (`servernotifyregister event=textserver`) |
| Channel chat without joining | Relay pool (`tsc-observer`): invisible query sessions sit in channels and relay both ways; posts appear as `[Nick] text` |
| Voice | tsproto UDP transport, Opus (`opus2`), echo cancellation / noise suppression (sonora), own jitter buffer, cpal / AAudio |
| Invisible presence | Gateway presence stream (snapshot + deltas from query events) or direct query; `channelsubscribeall` when voice-connected |
| Screen share with sound | TS6 stream signalling (`tsc-stream`), str0m WebRTC, per-platform capture and codecs (`tsc-media`) |
## Workspace layout
Present today:
```
crates/proto/ vendored tsclientlib (tsproto, tsproto-packets, tsproto-types,
tsproto-structs + declarations, ts-bookkeeping, tsclientlib)
tools/tsctl headless CLI
dev/ docker-compose TS3 + TS6 servers
scripts/ it-smoke.sh
```
Planned crates:
| Crate | Responsibility |
|---|---|
| `tsc-model` | UI-facing domain model (servers, channels, clients, chat, capabilities), no IO |
| `tsc-query` | ServerQuery codec and transports: raw TCP, SSH (russh), HTTP WebQuery |
| `tsc-observer` | Presence tracker + chat relay pool over `tsc-query` |
| `tsc-gateway-proto`, `tsc-gateway` (`tsgw`) | Companion service for server admins: identity-challenge auth, permission-mirroring authorization, presence stream, chat relay, SQLite history, WebSocket + JSON (`tsgw.v1+json`) |
| `tsc-store` | Identities, bookmarks, settings, chat cache, secrets (keyring / Android Keystore) |
| `tsc-audio` | Capture/playback, Opus, echo cancellation, resampling, jitter buffer, mixer, VAD/push-to-talk |
| `tsc-media` | Screen and system-audio capture backends (PipeWire portal, X11, Windows Graphics Capture, Android MediaProjection), video codecs |
| `tsc-stream` | TS6 stream signalling state machine, str0m peer connections |
| `tsc-core` | Engine: runtime, per-server sessions, merge of voice/gateway/query sources, event bus, command API |
| `tsc-platform` | Global hotkeys, notifications, paths, Android JNI glue |
| `tsc-ui` | Slint UI and the desktop binary |
| `tsc-android` + `android/` | Android library + Gradle/Kotlin app (foreground services for voice and screen capture) |
## Merging sources
Each server session has up to three optional sources: **voice** (normal client
connection), **gateway**, and **query** (own credentials). Presence authority is
voice (after subscribing to all channels) > gateway > query. Channel chat uses
the native command only when voice-connected *and* in that channel, otherwise the
gateway, otherwise a local query relay. UI states: `Offline`,
`Observing (Gateway|Query)` (invisible), `Connecting`, `Connected`.
## Milestones
| | Scope | Exit criteria |
|---|---|---|
| **M0** | Vendoring, workspace, `tsctl`, dev servers, CI | Builds on Linux + Windows; smoke test passes on TS3 and TS6 |
| M1 | Protocol modernisation: edition 2024, dependency updates, puzzle rewrite (off-thread, progress, cancel), TS6 declarations (`client_is_streaming`, stream commands), fuzzing | Tests green on both servers, clippy clean |
| M2 | Identities/bookmarks store, audio v0 (Opus, jitter buffer), `tsctl voice` | Tone round-trips between two clients on both servers |
| M3 | `tsc-query` (raw/SSH/HTTP) + observer | Invisible presence and relay chat verified |
| M4 | Gateway v1 | Presence + channel chat without appearing in the client list, permission denials tested |
| M5 | `tsc-core` + Slint desktop UI (Linux) | Daily use on GNOME, KDE, X11 |
| M6 | Audio quality, global push-to-talk, Windows parity and packaging | One-hour call without drift or echo |
| M7 | TS6 stream viewer | Watch an official TS6 client's stream |
| M8 | Streamer: capture, system audio, encoders | Official TS6 client watches our 1080p30 stream with sound |
| M9 | Android app | Background voice, watch and share screen |
| M10 | Release hardening | Signing, crash reports, i18n, notices audit |
| M11+ | macOS / iOS | |
## Risks
- TeamSpeak 6 streaming is undocumented and still in beta: probe against our own
server, record findings in `docs/protocol-notes/`, pin server versions, gate
features on the server version. AGPL projects (astrum-ts6) are reference only.
- Signed client versions could be blocked: configurable, with fallbacks.
- ServerQuery flood limits: token buckets, capped relay pool, allowlist guidance.
- H.264 patents: no bundled encoder; runtime-downloaded Cisco OpenH264, VP8/VP9
preferred, OS hardware codecs.
+105
View File
@@ -0,0 +1,105 @@
# TeamSpeak 6: protocol notes
Everything here is reverse-engineered or collected from public sources. Mark each
item as **confirmed** (seen against our own server or in working code) or
**reported** (single secondary source). Update this file whenever a probe or
capture teaches something new.
## Legacy protocol on TS6 servers
- **Confirmed** (tsctl, 6.0.0-beta13.1, 2026-09-25): the TS3 client protocol
connects (`initivexpand2` license chain with the TS5-server block type),
channel tree, server chat and channel chat work. Client version: the vendored
default `Windows_3_X_X__1`.
- **Confirmed**: new fields the vendored declarations do not know yet (logged as
"Unknown argument"):
- `initserver`: `virtualserver_address`, `virtualserver_version_sign`
- `initserver` / `notifycliententerview`: `client_is_streaming`
- **Confirmed**: TS6 has no raw ServerQuery port; SSH query on 10022 and HTTP
WebQuery on 10080 (HTTPS 10443).
- **Reported**: beta13 made the Init1 puzzle difficulty adaptive to the server's
protection level.
## Screen sharing / streams
Transport (**reported**, TeamSpeak staff on community.teamspeak.com):
- WebRTC peer-to-peer between clients; the server only relays signalling. No SFU yet.
- ICE with STUN only (`turn.teamspeak.com`, `turn2.teamspeak.com`; no TURN relay).
- Media ports: UDP 49152–65535.
- Streams are channel-scoped: "public" means everyone in the streamer's channel.
- Bitrate capped at 10 Mbit/s.
Codecs (**reported**, from the ts6-manager bot's working code):
- Video: H.264 Constrained High (the only H.264 profile the TS client decodes),
VP8, VP9, AV1.
- Audio: Opus, 48 kHz stereo, payload type 111.
Commands over the normal client command channel (**reported**, ts6-manager,
which uses a TS3-signed client version over the legacy UDP transport):
| Direction | Command | Parameters |
|---|---|---|
| C→S | `setupstream` | `name type bitrate accessibility mode viewer_limit audio` (bot defaults: `type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 audio=1`) |
| C→S | `respondjoinstreamrequest` | `id clid msg offer=<SDP> decision=1\|0` |
| C→S | `streamsignaling` | `id clid json={"cmd":…,"args":{…}}` (answer, ICE candidates `candidate`/`sdpMid`/`sdpMlineIndex`, reconnect) |
| C→S | `stopstream` | `id`? |
| C→S | `removeclientfromstream` | `id clid`? |
| S→C | `notifystreamstarted`, `notifystreamstopped`, `notifystreaminfo` | |
| S→C | `notifyjoinstreamrequest`, `notifyrespondjoinstreamrequest` | |
| S→C | `notifystreamsignaling` | |
| S→C | `notifystreamclientjoined`, `notifystreamclientleft` | |
Flow: a viewer's join request arrives at the streamer as
`notifyjoinstreamrequest`; the streamer creates one peer connection per viewer and
sends its SDP offer in `respondjoinstreamrequest`; the viewer's answer and ICE
candidates come back through `streamsignaling` / `notifystreamsignaling`.
### Probe results (confirmed, 6.0.0-beta13.1, default permissions, 2026-09-25)
Sent with `tsctl connect 127.0.0.1:9988 raw '<command>'` as a plain guest:
| Command | Result |
|---|---|
| `setupstream name=probe type=3 bitrate=4608 accessibility=1 mode=1 viewer_limit=0 audio=1` | ok; a guest may start a stream by default |
| `joinstreamrequest id=<uuid>` (also with `clid=`, `msg=`) | exists, `error id=1542` missing required parameter |
| `streamsignaling id=1 clid=1 json={}` | exists (`ClientInvalidId`) |
| `stopstream id=<x>` | exists, missing parameter |
| `requestjoinstream`, `joinstream` | `CommandNotFound` |
After `setupstream` the server sends, to the streamer:
```
notifyclientupdated clid=20 client_is_streaming=1
notifystreamstarted clid=20 id=e7da957e-7ce0-46cf-bf6d-754d3446b4d4 name=probe type=3 access=1 mode=1 bitrate=4608 viewer_limit=0 audio=1 return_code=0
```
Stream ids are UUIDs. The notification carries the command's `return_code`, and
the field is named `access` there (not `accessibility`).
Errors: `setupstream` refused with error 2568 ("insufficient client
permissions") has been seen; no stream permission names are documented.
## Open questions
- [ ] Viewer side: the command is `joinstreamrequest`, but `id`, `clid` and `msg`
are not enough. Find the missing parameter(s) with
`tsctl connect ... --log-commands raw '<candidate>'` (or the REPL's `/raw`)
while another client streams.
- [ ] Meaning of `setupstream` `type`, `accessibility` and `mode` values.
- [ ] Parameters of `stopstream` (more than `id`) and `removeclientfromstream`.
- [ ] Which permission gates `setupstream` (error 2568).
- [ ] Contents of `notifystreaminfo` and `notifystreamstarted`.
- [ ] Whether stream audio can be sent without video.
- [ ] The WebRTC/protobuf transport some TS6 clients use on UDP 9987
(`client_protocol_format=proto`, reported in community reverse engineering).
Not needed while the legacy transport works.
## Sources
- clusterzx/ts6-manager: `packages/backend/src/voice/streaming/stream-signaling.ts`,
`packages/backend/src/voice/tslib/client.ts`
- community.teamspeak.com threads 56850 (how screen share works), 58890 (TS3
servers have no screen share), 62456 (port range), 62512 (bitrate limit)
- github.com/teamspeak/teamspeak6-server `CONFIG.md`, releases
+12
View File
@@ -291,6 +291,7 @@ commands:
/server <text> send to the server chat
/channel <text> send to the current channel
/msg <clid> <text> send a private message
/raw <command> send a raw, already escaped command
/tree print the channel tree
/whoami print own client and channel
/quit disconnect";
@@ -327,6 +328,7 @@ async fn repl(con: &mut Connection) -> Result<()> {
println!("error (command {}): {error}", handle.0);
}
StreamItem::MessageResult(handle, Ok(())) if Some(handle) == pending => {
println!("ok (command {})", handle.0);
pending = None;
}
_ => {}
@@ -358,6 +360,16 @@ async fn repl(con: &mut Connection) -> Result<()> {
);
continue;
}
"/raw" => {
let cmd = OutCommand::new(
Direction::C2S,
Flags::empty(),
PacketType::Command,
rest,
);
pending = Some(cmd.send_with_result(con)?);
continue;
}
"/server" => ChatTarget::Server { message: rest.into() },
"/channel" => ChatTarget::Channel { message: rest.into() },
"/msg" => {