From 5afa5a97402c63cb712df31c546d4aeb620ec807 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:28:02 +0300 Subject: [PATCH 01/18] Commit the SSH host key of git.faumaray.com for the CI and release builds Cargo reaches the private VoelinProtocol repository over SSH and, in a fresh job container or image, has no known_hosts: every cargo command failed with "unknown SSH host key" (runs 1037 and 1050). The server (Gitea's built-in SSH, SSH-2.0-Go) offers an RSA host key only; the line is committed here, after checking its fingerprint (SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A) against ssh-keyscan and Cargo's own report, so that jobs trust the reviewed key instead of fetching one while they run. The next commits use it in the checks action, the release workflow and the Dockerfiles. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/known_hosts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .gitea/known_hosts diff --git a/.gitea/known_hosts b/.gitea/known_hosts new file mode 100644 index 0000000..feaca28 --- /dev/null +++ b/.gitea/known_hosts @@ -0,0 +1,10 @@ +# SSH host key of git.faumaray.com (Gitea's built-in SSH server, which offers an +# RSA host key only). Fingerprint SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A, +# recorded on 2026-10-24 with `ssh-keyscan -t rsa git.faumaray.com`. +# +# Committed, never fetched while a job runs, so a CI or release build trusts the +# key reviewed here and not whatever answers on the network at that moment. +# Read by .gitea/actions/checks (appended to ~/.ssh/known_hosts) and COPYed by +# docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to re-check it +# and how to rotate it: docs/ci.md, "VoelinProtocol access". +git.faumaray.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw== From 8b6dcbf4423611c9bdee155b7a683f72dd170ec3 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:34:08 +0300 Subject: [PATCH 02/18] Give the Linux checks read access to the private VoelinProtocol repository The workspace depends on voelin-identity from Voelin/VoelinProtocol over SSH, and the job container had no key and no known_hosts, so the first cargo command failed with "unknown SSH host key" (runs 1037 and 1050). The checks action takes the private half of a read-only deploy key as the input protocol-deploy-key (secrets are not visible inside a composite action, so ci.yml passes ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}). Its first step fails at once, with a message that names the secret, when the input is empty or not a private key; it writes the key to ~/.ssh/voelin_protocol (0600), appends the host key line committed in .gitea/known_hosts, writes a Host block for git.faumaray.com (User gitea, IdentityFile, IdentitiesOnly, StrictHostKeyChecking yes) and sets CARGO_NET_GIT_FETCH_WITH_CLI=true and GIT_SSH_COMMAND for the rest of the job: Cargo's built-in git client cannot use an IdentityFile, the system git and ssh can. The key reaches the step through the environment only, is never echoed, and only the public fingerprint is printed. A second step, after the system packages, runs git ls-remote against VoelinProtocol, so a wrong key or a changed host key fails there and not minutes later inside a cargo command. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/actions/checks/action.yml | 107 +++++++++++++++++++++++++++++++ .gitea/workflows/ci.yml | 5 ++ 2 files changed, 112 insertions(+) diff --git a/.gitea/actions/checks/action.yml b/.gitea/actions/checks/action.yml index f22b828..a01e6c5 100644 --- a/.gitea/actions/checks/action.yml +++ b/.gitea/actions/checks/action.yml @@ -1,9 +1,116 @@ name: Linux checks description: Shared Linux validation for Gitea CI and release packaging. +inputs: + protocol-deploy-key: + description: > + Private half of the read-only deploy key registered on the private + Voelin/VoelinProtocol repository (the repository secret + VOELIN_PROTOCOL_DEPLOY_KEY, passed in by the workflow: secrets are not + visible inside a composite action). The action fails when it is empty. + required: true runs: using: composite steps: + # The workspace depends on the private VoelinProtocol repository over SSH + # (docs/ci.md, "VoelinProtocol access"). First, so that a missing key fails + # in seconds and before anything runs cargo. + - name: Install the VoelinProtocol deploy key + # The key reaches this step through the environment only: never in the + # script text, never echoed, no `set -x`. + env: + PROTOCOL_DEPLOY_KEY: ${{ inputs.protocol-deploy-key }} + run: | + set -euo pipefail + umask 077 + if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then + echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2 + exit 1 + fi + command -v ssh ssh-keygen > /dev/null || { + echo "::error::The job image needs the OpenSSH client (ssh, ssh-keygen)." >&2 + exit 1 + } + ssh_dir="$HOME/.ssh" + key_file="$ssh_dir/voelin_protocol" + mkdir -p "$ssh_dir" + chmod 700 "$ssh_dir" + + # Whatever the secret store did to the line ends and the final newline, + # OpenSSH needs LF lines, the BEGIN line first and a newline at the end. + printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file" + unset PROTOCOL_DEPLOY_KEY + chmod 600 "$key_file" + if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then + rm -f "$key_file" + echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2 + exit 1 + fi + # The fingerprint of the public half, to compare with the deploy key in + # the VoelinProtocol settings. + printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")" + + # The reviewed host key from the repository, never one fetched now. + known_hosts="$ssh_dir/known_hosts" + touch "$known_hosts" + chmod 600 "$known_hosts" + [[ -s "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" ]] || { + echo "::error::.gitea/known_hosts is missing from the checkout." >&2 + exit 1 + } + while IFS= read -r line; do + case "$line" in '' | '#'*) continue ;; esac + grep -qxF -- "$line" "$known_hosts" || printf '%s\n' "$line" >> "$known_hosts" + done < "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" + + # Use this key, and only this one, for the Gitea server; fail rather than + # ask when its host key is unknown or changed. The block goes first: ssh + # takes the first value it finds for each option. + config="$ssh_dir/config" + marker="# VoelinProtocol deploy key (.gitea/actions/checks)" + touch "$config" + if ! grep -qxF -- "$marker" "$config"; then + { + cat << EOF + $marker + Host git.faumaray.com + User gitea + IdentityFile $key_file + IdentitiesOnly yes + UserKnownHostsFile $known_hosts + StrictHostKeyChecking yes + BatchMode yes + ConnectTimeout 30 + + EOF + cat "$config" + } > "$config.new" + mv "$config.new" "$config" + fi + chmod 600 "$config" + + # Cargo's built-in git client (libgit2) cannot use IdentityFile; the + # system git runs ssh, which reads the config above. `-F` names it + # outright: ssh looks for ~/.ssh in the passwd entry's home directory, not + # in $HOME, and a job image may set the two apart. + { + echo "CARGO_NET_GIT_FETCH_WITH_CLI=true" + echo "GIT_SSH_COMMAND=ssh -F '$config'" + } >> "$GITHUB_ENV" + shell: bash - uses: ./.github/actions/system-deps + - name: Check read access to VoelinProtocol + # The first thing cargo does, with the same git and ssh configuration, so + # that a wrong key or a changed host key fails here with a clear message + # and not minutes later inside a cargo command. + run: | + set -euo pipefail + if ! GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --exit-code \ + ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then + echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2 + exit 1 + fi + echo "Voelin/VoelinProtocol is readable with the deploy key." + shell: bash - name: Install pinned Rust toolchain run: | set -euo pipefail diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 46b1534..74c4ab6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -32,3 +32,8 @@ jobs: steps: - uses: https://github.com/actions/checkout@v4 - uses: ./.gitea/actions/checks + with: + # A repository secret is not visible inside the composite action, so + # it is passed in. Pull requests from forks get no secrets: the + # action then fails at once with a message that says so. + protocol-deploy-key: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }} From 437b508047c34b6657ad75b7c979e08662eb3e2d Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:34:08 +0300 Subject: [PATCH 03/18] Start an ssh-agent with the VoelinProtocol deploy key in the release workflow The Docker builds run cargo, which has to fetch the private VoelinProtocol repository over SSH. After checkout the workflow now loads the deploy key (secret VOELIN_PROTOCOL_DEPLOY_KEY) into a new ssh-agent through stdin, so the key is never written to the runner's disk and never reaches an image layer, and exports SSH_AUTH_SOCK and SSH_AGENT_PID for the later steps. The agent is started with a nine hour key lifetime and stopped by a last step that runs even after a failure, because the release runner is a persistent host. The gateway image, which is built with a plain docker build and not through scripts/docker-build.sh, gets --ssh default; the Dockerfiles use it in the next commit. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/workflows/release.yml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index eea4818..1bf5c2a 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -32,6 +32,34 @@ jobs: docker info >/dev/null # Remove only output owned by this workflow in its checkout. rm -rf dist + # The workspace depends on the private VoelinProtocol repository over SSH + # (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with + # this agent (`docker build --ssh default`): the key lives in the agent's + # memory, never on disk and never in an image layer. Stopped by the last + # step; the lifetime below ends the key anyway if the runner dies first. + - name: Start ssh-agent with the VoelinProtocol deploy key + env: + PROTOCOL_DEPLOY_KEY: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }} + run: | + set -euo pipefail + if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then + echo "::error::The repository secret VOELIN_PROTOCOL_DEPLOY_KEY is missing or empty. It holds the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2 + exit 1 + fi + command -v ssh-agent ssh-add > /dev/null + eval "$(ssh-agent -s -t 32400)" > /dev/null + started= + trap '[[ -n "$started" ]] || ssh-agent -k > /dev/null' EXIT + # LF lines and one final newline, whatever the secret store did. + printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' | ssh-add -q - + unset PROTOCOL_DEPLOY_KEY + # The fingerprint of the public half, to compare with the deploy key. + ssh-add -l + { + echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" + echo "SSH_AGENT_PID=$SSH_AGENT_PID" + } >> "$GITHUB_ENV" + started=1 - name: Linux packages run: scripts/docker-build.sh linux --progress=plain - name: Windows packages (MinGW) @@ -77,7 +105,7 @@ jobs: set -euo pipefail version=$(sed -n 's/^version = "\(.*\)"$/\1/p' crates/voelin-gateway/Cargo.toml | head -n 1) test -n "$version" - docker build -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest . + DOCKER_BUILDKIT=1 docker build --ssh default -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest . mkdir -p dist/gateway docker save "tsgw:$version" tsgw:latest | gzip > dist/gateway/tsgw-image.tar.gz - name: Collect packages and checksums @@ -104,3 +132,9 @@ jobs: # Gitea refuses secret names starting with GITEA_ or GITHUB_. GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} run: scripts/gitea-release.sh dist/release + - name: Stop the ssh-agent + if: always() + run: | + if [[ -n "${SSH_AGENT_PID:-}" ]]; then + ssh-agent -k > /dev/null || true + fi From b89116c0f4e323a76606917ec60256b3cab1815a Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:43:12 +0300 Subject: [PATCH 04/18] Let the Docker builds fetch the private VoelinProtocol repository with an ssh-agent Every cargo command in the images (linux, windows, android and the gateway image) failed for the same reason as the CI job: Cargo resolves the whole workspace, which includes the git dependency voelin-identity on the private Voelin/VoelinProtocol repository, and the images had no SSH access to it. The crates that depend on voelin-identity are voelin-store and, through it, voelin-core, voelin-ui, voelin-ui-vm, voelin-android and voelinctl; the gateway crate does not, but `cargo build -p voelin-gateway` fails without access too (checked with an empty CARGO_HOME), so its Dockerfile needs the same. Each cargo RUN gets --mount=type=ssh,required=true: the build is handed the caller's ssh-agent (docker build --ssh default), the key stays in the agent and never reaches a layer or the build context, and a build without --ssh fails at that step with "unset ssh forward key default". The build stage copies the host key committed in .gitea/known_hosts to /etc/ssh/ssh_known_hosts and sets CARGO_NET_GIT_FETCH_WITH_CLI=true, so that Cargo uses the system git and ssh. The toolchain stages install git and openssh-client where they were missing; the gateway Dockerfile gets the syntax directive the others already have. scripts/docker-build.sh passes --ssh default and stops early, with a message, when ssh-add -l shows no agent or no key. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-gateway/Dockerfile | 21 ++++++++++++++++++--- docker/android.Dockerfile | 28 ++++++++++++++++++++-------- docker/linux.Dockerfile | 22 +++++++++++++++++----- docker/windows.Dockerfile | 27 ++++++++++++++++++++------- scripts/docker-build.sh | 19 ++++++++++++++++++- 5 files changed, 93 insertions(+), 24 deletions(-) diff --git a/crates/voelin-gateway/Dockerfile b/crates/voelin-gateway/Dockerfile index d4bb4d0..e6ad157 100644 --- a/crates/voelin-gateway/Dockerfile +++ b/crates/voelin-gateway/Dockerfile @@ -1,4 +1,9 @@ -# Build: docker build -f crates/voelin-gateway/Dockerfile -t tsgw . +# syntax=docker/dockerfile:1 +# Build: docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw . +# (--ssh default hands the build your ssh-agent, which must hold a key that +# can read the private VoelinProtocol repository: docs/building.md, +# "Depending on VoelinProtocol". The gateway itself does not use it, but +# Cargo resolves the whole workspace, which includes voelin-identity.) # Run: docker run -d --name tsgw --init --restart unless-stopped \ # -v ./tsgw.toml:/etc/tsgw/tsgw.toml:ro -v tsgw-data:/var/lib/tsgw \ # -e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw @@ -6,9 +11,19 @@ # the volume: -e TSGW_LOG_FILE=logs/tsgw.log). See docs/gateway-admin.md. FROM rust:1.94-bookworm AS build WORKDIR /src -RUN apt-get update && apt-get install -y --no-install-recommends cmake libasound2-dev && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends cmake git libasound2-dev openssh-client && rm -rf /var/lib/apt/lists/* +# voelin-identity comes from the private VoelinProtocol repository, fetched +# over SSH by Cargo through the system git, with the agent that +# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): +# the key stays in the agent and never reaches a layer. The host key is the +# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so +# every cargo command needs this, although this crate does not use +# voelin-identity. +COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true COPY . . -RUN cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data +RUN --mount=type=ssh,required=true \ + cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data FROM gcr.io/distroless/cc-debian12:nonroot COPY --from=build /tsgw /usr/local/bin/tsgw diff --git a/docker/android.Dockerfile b/docker/android.Dockerfile index e3079cb..e5b1db4 100644 --- a/docker/android.Dockerfile +++ b/docker/android.Dockerfile @@ -3,13 +3,15 @@ # Android APKs (docs/building.md, docs/android.md): a debug APK, installable # as is, for arm64-v8a and x86_64 (emulators). # -# docker build -f docker/android.Dockerfile -o dist/android . -# docker build -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android . +# docker build --ssh default -f docker/android.Dockerfile -o dist/android . +# docker build --ssh default -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android . # -# or scripts/docker-build.sh android. A signed release APK needs your keystore -# (docs/release.md), passed as build secrets: +# or scripts/docker-build.sh android. --ssh default hands the build your +# ssh-agent, which must hold a key that can read the private VoelinProtocol +# repository (docs/building.md, "Depending on VoelinProtocol"). A signed +# release APK needs your keystore (docs/release.md), passed as build secrets: # -# docker build -f docker/android.Dockerfile --build-arg APK=release \ +# docker build --ssh default -f docker/android.Dockerfile --build-arg APK=release \ # --secret id=keystore,src=release.jks --secret id=signing,src=signing.env \ # -o dist/android . # @@ -21,8 +23,8 @@ FROM ubuntu:24.04 AS toolchain ARG DEBIAN_FRONTEND=noninteractive # JDK 17 (Gradle, the Android Gradle plugin), CMake + Ninja (the bundled libopus). RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential ca-certificates cmake curl ninja-build openjdk-17-jdk-headless \ - pkg-config python3 unzip \ + build-essential ca-certificates cmake curl git ninja-build openjdk-17-jdk-headless \ + openssh-client pkg-config python3 unzip \ && rm -rf /var/lib/apt/lists/* # Extra CA certificates (PEM, one or more), for building behind a @@ -83,8 +85,18 @@ ARG APK=debug # supplies a fresh non-secret nonce so a rotated key cannot reuse an old APK. ARG SIGNING_CACHE_BUST=unsigned WORKDIR /src +# voelin-identity comes from the private VoelinProtocol repository, fetched +# over SSH by Cargo through the system git, with the agent that +# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): +# the key stays in the agent and never reaches a layer. The host key is the +# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so +# every cargo command needs this (Gradle's cargo-ndk inherits the agent and the +# variable below). +COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true COPY . . -RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ +RUN --mount=type=ssh,required=true \ + --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-target-android,target=/src/target \ --mount=type=cache,id=voelin-gradle,target=/root/.gradle \ --mount=type=secret,id=keystore,required=false \ diff --git a/docker/linux.Dockerfile b/docker/linux.Dockerfile index 3f31168..0b7a641 100644 --- a/docker/linux.Dockerfile +++ b/docker/linux.Dockerfile @@ -5,17 +5,20 @@ # gateway (servers) as tsgw--linux-x86_64.tar.gz and # tsgw__amd64.deb. # -# docker build -f docker/linux.Dockerfile -o dist/linux . +# docker build --ssh default -f docker/linux.Dockerfile -o dist/linux . # -# or scripts/docker-build.sh linux. The cargo registry and target directory -# live in cache mounts, so rebuilds are incremental. +# or scripts/docker-build.sh linux. --ssh default hands the build your +# ssh-agent, which must hold a key that can read the private VoelinProtocol +# repository (docs/building.md, "Depending on VoelinProtocol"). The cargo +# registry and target directory live in cache mounts, so rebuilds are +# incremental. FROM ubuntu:24.04 AS toolchain ARG DEBIAN_FRONTEND=noninteractive # The same libraries as CI (.github/actions/system-deps), plus dpkg-dev for # the .deb's dependencies and patchelf for the .tar.gz's bundled libraries. RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential ca-certificates cmake curl dpkg-dev patchelf pkg-config \ + build-essential ca-certificates cmake curl dpkg-dev git openssh-client patchelf pkg-config \ libasound2-dev libfontconfig1-dev libxkbcommon-dev \ libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \ && rm -rf /var/lib/apt/lists/* @@ -37,8 +40,17 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ FROM toolchain AS build WORKDIR /src +# voelin-identity comes from the private VoelinProtocol repository, fetched +# over SSH by Cargo through the system git, with the agent that +# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): +# the key stays in the agent and never reaches a layer. The host key is the +# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so +# every cargo command needs this. +COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true COPY . . -RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ +RUN --mount=type=ssh,required=true \ + --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-target-linux,target=/src/target \ cargo build --release --locked -p voelin-ui -p voelin-gateway \ && scripts/package.sh linux /out diff --git a/docker/windows.Dockerfile b/docker/windows.Dockerfile index 8aafc86..7f3a3e3 100644 --- a/docker/windows.Dockerfile +++ b/docker/windows.Dockerfile @@ -4,11 +4,15 @@ # voelin--windows-x86_64.zip with voelin.exe, and the NSIS installer # voelin--setup.exe. # -# docker build -f docker/windows.Dockerfile -o dist/windows . +# docker build --ssh default -f docker/windows.Dockerfile -o dist/windows . # -# or scripts/docker-build.sh windows. This builds for x86_64-pc-windows-gnu -# with mingw-w64; CI's Windows jobs build the MSVC target on Windows. Both run -# on Windows 10 and 11. Unsigned, like CI's (signing: docs/release.md). +# or scripts/docker-build.sh windows. --ssh default hands the build your +# ssh-agent, which must hold a key that can read the private VoelinProtocol +# repository (docs/building.md, "Depending on VoelinProtocol"). +# +# This builds for x86_64-pc-windows-gnu with mingw-w64; CI's Windows jobs build +# the MSVC target on Windows. Both run on Windows 10 and 11. Unsigned, like +# CI's (signing: docs/release.md). FROM ubuntu:24.04 AS toolchain ARG DEBIAN_FRONTEND=noninteractive @@ -16,8 +20,8 @@ ARG DEBIAN_FRONTEND=noninteractive # assembly), CMake (the bundled libopus, aws-lc), Meson and Ninja (dav1d), # NSIS (the installer), zip and unzip. RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis perl \ - pkg-config unzip zip \ + build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis \ + openssh-client perl pkg-config unzip zip \ && rm -rf /var/lib/apt/lists/* \ && update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \ && update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix @@ -89,9 +93,18 @@ ENV VPX_LIB_DIR=/opt/libvpx/lib VPX_INCLUDE_DIR=/opt/libvpx/include \ SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG=1 SYSTEM_DEPS_DAV1D_SEARCH_NATIVE=/opt/dav1d/lib \ SYSTEM_DEPS_DAV1D_LIB=dav1d SYSTEM_DEPS_DAV1D_LINK=static WORKDIR /src +# voelin-identity comes from the private VoelinProtocol repository, fetched +# over SSH by Cargo through the system git, with the agent that +# `docker build --ssh default` forwards (scripts/docker-build.sh passes it): +# the key stays in the agent and never reaches a layer. The host key is the +# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so +# every cargo command needs this. +COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true COPY . . # FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh). -RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ +RUN --mount=type=ssh,required=true \ + --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-target-windows,target=/src/target \ cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \ && scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \ diff --git a/scripts/docker-build.sh b/scripts/docker-build.sh index c1dc76b..0d4c298 100755 --- a/scripts/docker-build.sh +++ b/scripts/docker-build.sh @@ -7,6 +7,11 @@ # docker buildx). Extra arguments go to `docker build`, e.g. # scripts/docker-build.sh android --build-arg ABIS=arm64-v8a # +# The workspace depends on the private VoelinProtocol repository, which the +# build fetches over SSH with your ssh-agent (`docker build --ssh default`): +# the agent must hold a key that can read it (docs/building.md, "Depending on +# VoelinProtocol"). The key stays in the agent, never in the image. +# # Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the # build; a proxy on this machine's loopback is reached with host networking. # If the proxy inspects TLS, point BUILD_CA_CERT at its CA certificate (PEM): @@ -23,7 +28,19 @@ case "$platform" in *) echo "usage: $0 [linux|windows|android|all] [docker build args…]" >&2; exit 2 ;; esac -args=() +# The build's cargo needs VoelinProtocol; fail here, not after the toolchain +# stage, when the agent is missing or empty. +if ! ssh-add -l > /dev/null 2>&1; then + cat >&2 <<'MSG' +docker-build.sh: no ssh-agent with a key that can read Voelin/VoelinProtocol. +Start one and add the key, then run this again: + eval "$(ssh-agent -s)" && ssh-add ~/.ssh/ +docs/building.md ("Depending on VoelinProtocol") has the details. +MSG + exit 1 +fi + +args=(--ssh default) for var in HTTPS_PROXY https_proxy HTTP_PROXY http_proxy NO_PROXY no_proxy; do if [[ -n ${!var:-} ]]; then args+=(--build-arg "$var=${!var}") From 6e774873bfb1c8aee08694ddcef6c8b1952e0558 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:44:44 +0300 Subject: [PATCH 05/18] Document how CI and the release builds read the private VoelinProtocol repository docs/ci.md gets a "VoelinProtocol access" section: why every cargo command needs the access (Cargo resolves the whole workspace, so the gateway image needs it too), the deploy key and the repository secret VOELIN_PROTOCOL_DEPLOY_KEY, what the checks action, the release workflow and the Dockerfiles do with it, why Cargo is told to use the system git, the committed host key line with its fingerprint and the two commands that re-check it, the effect on fork pull requests, and what each failure message means. The runner setup no longer says that a fresh checkout does not build there. docs/building.md says that the Docker builds need an ssh-agent with a key that can read VoelinProtocol (--ssh default) and summarises the CI setup; the plain docker build commands in it and in docs/gateway-admin.md gain --ssh default, without which they would now stop at the cargo step. Co-Authored-By: Claude Sonnet 5.5 --- docs/building.md | 34 ++++++++++--- docs/ci.md | 113 ++++++++++++++++++++++++++++++++++++++---- docs/gateway-admin.md | 2 +- 3 files changed, 129 insertions(+), 20 deletions(-) diff --git a/docs/building.md b/docs/building.md index 9810b5c..c2d6707 100644 --- a/docs/building.md +++ b/docs/building.md @@ -28,7 +28,8 @@ yet: Windows SmartScreen warns about the installer, and the debug APK is signed with a debug key (fine for testing, not for the Play Store). The gateway's image can also be built directly: -`docker build -f crates/voelin-gateway/Dockerfile -t tsgw .`. +`docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw .` +(`--ssh default`: see [Locally with Docker](#locally-with-docker)). Gitea at [git.faumaray.ru](https://git.faumaray.ru) builds the same package types through `.gitea/workflows/release.yml`: manual runs produce one @@ -80,7 +81,15 @@ scripts/docker-build.sh android # → dist/android/ scripts/docker-build.sh # all three ``` -The same with plain Docker, e.g. `docker build -f docker/linux.Dockerfile -o dist/linux .` +The same with plain Docker, e.g. `docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .` +**The builds need an ssh-agent that holds a key able to read the private +VoelinProtocol repository** ([below](#depending-on-voelinprotocol)): Cargo +fetches it inside the image, through the agent that `--ssh default` hands to the +build. The key stays in the agent; it is not copied into the image or the build +cache. `scripts/docker-build.sh` passes `--ssh default` itself and stops with a +message when `ssh-add -l` shows no agent or no key (`eval "$(ssh-agent -s)"`, +then `ssh-add` your key). The server's host key comes from +`.gitea/known_hosts` ([ci.md](ci.md#voelinprotocol-access)). Rebuilds are incremental: the cargo registry, `target/` and Gradle live in BuildKit cache mounts (`docker builder prune` frees them). @@ -148,13 +157,22 @@ set `net.git-fetch-with-cli = true` in `~/.cargo/config.toml`. compiler (gcc or clang) and cmake. `deny.toml` allows this one git source. -**CI and the Docker builds need read access to that repository too**: an SSH -deploy key (a repository secret written to `~/.ssh`, with the server's host key -in `known_hosts`) or an access token (rewrite the SSH URL to HTTPS with +**CI and the Docker builds read it with a read-only SSH deploy key.** The key +is registered on VoelinProtocol and stored as the repository secret +`VOELIN_PROTOCOL_DEPLOY_KEY`; the Gitea workflows write it to `~/.ssh` (CI) or +load it into an ssh-agent (release builds), the server's host key comes from the +committed `.gitea/known_hosts`, and Cargo is told to fetch with the system git +(`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because its built-in git client ignores +`~/.ssh/config`. The Docker builds use the same key through +`docker build --ssh default` (see above). What was set up, how to re-check the +host key's fingerprint and what each failure means: +[ci.md](ci.md#voelinprotocol-access). A runner of your own gets the same setup +from the workflows; the alternative to a deploy key is an access token (rewrite +the SSH URL to HTTPS with `git config --global url."https://@git.faumaray.com/".insteadOf ssh://gitea@git.faumaray.com/` -and set `CARGO_NET_GIT_FETCH_WITH_CLI=true`). Without it `cargo` cannot fetch -the dependency and a fresh checkout does not build; the details are in -VoelinProtocol's `docs/development.md` ("Depending on VoelinProtocol"). +and set `CARGO_NET_GIT_FETCH_WITH_CLI=true`), which these workflows do not +use. More in VoelinProtocol's `docs/development.md` ("Depending on +VoelinProtocol"). ### Working with a sibling VoelinProtocol checkout diff --git a/docs/ci.md b/docs/ci.md index 64678b7..ad35dca 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -51,16 +51,17 @@ the separate `release.yml` workflow below. Configure this in the runner's labels when registering/configuring it; an `ubuntu-latest` label alone does not match. The job image must provide - Bash, Git, Node.js for checkout v4, and root or passwordless sudo for apt. + Bash, Git, the OpenSSH client, Node.js for checkout v4, and root or + passwordless sudo for apt. 3. Allow network access from the runner and job container to the Gitea instance, GitHub (checkout action, dependencies and RustSec advisories), GHCR (runner image), Ubuntu apt mirrors, rustup distribution servers, crates.io and dependency/license sources used by cargo-about. The workspace also depends on the **private** VoelinProtocol repository - (`voelin-identity`, over SSH), so the job needs read access to it: an SSH - deploy key or an access token, set up as in - [building.md](building.md#depending-on-voelinprotocol). Until a runner has - it, a fresh checkout does not build there. + (`voelin-identity`, over SSH), so the job needs read access to it and the + server's SSH port. The workflows set that up themselves from a repository + secret: [VoelinProtocol access](#voelinprotocol-access). A runner needs + nothing for it beyond the network access and the image tools above. 4. Provision enough RAM, swap and free disk for a full Slint workspace build plus cargo-deny/cargo-about compilation. These are large builds; monitor the first run and size the runner accordingly. The workflow limits Cargo @@ -93,14 +94,103 @@ No GitHub cache/artifact service or reusable-workflow support is required. The job does not need a Docker socket mounted inside its container; the runner itself still needs Docker access to start that container. Keep this runner isolated from production services and credentials, particularly when -accepting untrusted pull requests. No release signing or publishing secrets -are needed. +accepting untrusted pull requests. CI needs one secret, the VoelinProtocol +deploy key below; it needs no release signing or publishing secrets. After registering the runner, dispatch **CI** in Gitea Actions and inspect all step results. Local YAML/shell checks do not prove that a particular Gitea instance, runner registration, network policy or resource allocation can complete this job. +### VoelinProtocol access + +The workspace depends on `voelin-identity` from the **private** repository +`Voelin/VoelinProtocol`, as a git dependency over SSH +([building.md](building.md#depending-on-voelinprotocol)). Cargo resolves the +whole workspace before it builds anything, so *every* cargo command needs +that access: all of CI, all three package images and the gateway image (whose +crate does not use `voelin-identity` itself). Without it the first cargo +command fails with `unknown SSH host key` (runs 1037 and 1050 did). + +What is set up: + +- **The deploy key.** A read-only SSH deploy key is registered on + `Voelin/VoelinProtocol` (Settings → Deploy Keys, write access off). It has + no other use and no access to any other repository. Its private half is the + repository secret **`VOELIN_PROTOCOL_DEPLOY_KEY`** of `Voelin/VoelinClient` + (Settings → Actions → Secrets): the whole OpenSSH private key file, BEGIN + and END lines included, without a passphrase. To rotate it, make a new pair + (`ssh-keygen -t ed25519 -N '' -C voelin-client-ci -f key`), register + `key.pub` on VoelinProtocol, replace the secret with the contents of + `key`, run CI, then delete the old deploy key and `key`. +- **CI** (`ci.yml`). The workflow hands the secret to the checks action as its + input `protocol-deploy-key` (a repository secret is not visible inside a + composite action). The action's first step fails at once, naming the secret, + if the input is empty or is not a private key. Otherwise it writes the key to + `~/.ssh/voelin_protocol` (mode 0600, `~/.ssh` 0700), appends the host key + line to `~/.ssh/known_hosts`, writes a `Host git.faumaray.com` block to + `~/.ssh/config` (`User gitea`, that `IdentityFile`, `IdentitiesOnly yes`, + `StrictHostKeyChecking yes`) and exports `CARGO_NET_GIT_FETCH_WITH_CLI=true` + and `GIT_SSH_COMMAND` for the rest of the job. It prints only the key's + public fingerprint; the key is never echoed. After the system packages a + second step runs `git ls-remote` on VoelinProtocol, so a wrong key or host + key fails there, with the reason, and not inside a cargo command. The key + lives in the job container and goes with it. +- **Release** (`release.yml`). A step after checkout starts an `ssh-agent` on + the release host, loads the key into it from stdin (it is never written to + disk) and exports `SSH_AUTH_SOCK`; the agent forgets the key after nine + hours, and a last step, which also runs after a failure, stops it. The + builds pass the agent on with `docker build --ssh default` + (`scripts/docker-build.sh` does it for the three packages; the gateway image + step does it itself). +- **The images.** Each cargo `RUN` of `docker/*.Dockerfile` and + `crates/voelin-gateway/Dockerfile` has `--mount=type=ssh,required=true`, so + the key exists only inside that step, through the agent socket, and never + reaches a layer, a build argument or the cache; a build without `--ssh` + stops there with `unset ssh forward key default`. The build stage copies + `.gitea/known_hosts` to `/etc/ssh/ssh_known_hosts` and sets the same + `CARGO_NET_GIT_FETCH_WITH_CLI=true`; the toolchain stages install `git` and + `openssh-client`. +- **Cargo uses the system git** (`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because + Cargo's built-in git client does not read `~/.ssh/config` (so it cannot use + an `IdentityFile`), authenticates with an ssh-agent and checks the host + against `~/.ssh/known_hosts` and its own `net.ssh.known-hosts` setting. The + system git runs `ssh`, which reads the config above (and + `/etc/ssh/ssh_known_hosts` in the images), so the same files serve a plain + `git` call, Cargo and the access check. +- **The host key** is committed in [`.gitea/known_hosts`](../.gitea/known_hosts), + never fetched while a job runs. Gitea's built-in SSH server (`SSH-2.0-Go`) + offers an RSA host key only (`ssh-keyscan -t ed25519 git.faumaray.com` + prints nothing), so the line is `ssh-rsa`; its fingerprint is + `SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A`. Re-check it: + + ```sh + ssh-keygen -lf .gitea/known_hosts # the committed line + ssh-keyscan -t rsa git.faumaray.com | ssh-keygen -lf - # what the server offers now + ``` + + Both print the fingerprint above. If the server's key is ever replaced on + purpose, confirm the new fingerprint with the server's administrator, put the + new `ssh-keyscan -t rsa` line and the date in `.gitea/known_hosts` and the + fingerprint here, and commit all of it in one change. Until then a changed key + makes every job stop with `Host key verification failed`, which is the point. + +Pull requests from forks get no secrets: their CI run stops at the first step +with the message about the empty deploy key. Anyone who can change a workflow of +this repository, or run code in one of its jobs, can read the key; it can only +read VoelinProtocol, and it is replaced as above. That is one more reason to +keep the CI runner isolated, as said above. + +If a run fails here: + +| Message | Cause | +|---|---| +| `The VoelinProtocol deploy key is empty` | the secret is missing, empty or not visible (a fork's pull request) | +| `… is not an unencrypted OpenSSH or PEM private key` | the secret holds something else, or a key with a passphrase | +| `Permission denied (publickey)` in "Check read access to VoelinProtocol" | the key is valid but is not a deploy key of VoelinProtocol: compare the fingerprint "Deploy key installed" printed with the one in VoelinProtocol's deploy key settings | +| `Host key verification failed` | `.gitea/known_hosts` does not match the server: check as above before changing anything | +| `unset ssh forward key default` | a Docker build ran without `--ssh default`: a plain `docker build` (`scripts/docker-build.sh` passes it itself and stops earlier when the agent has no key) | + ### Gitea release runner The instance at `https://git.faumaray.ru` reported Gitea **1.25.4** on @@ -114,8 +204,8 @@ host** runner with the label: voelin-release:host ``` -Provision Bash, Git, Node.js 20+, Python 3.11+, curl, tar, gzip and rootful -Docker 23+ with BuildKit. Use **act_runner 0.2.7 or newer** (prefer the latest +Provision Bash, Git, the OpenSSH client (`ssh-agent` and `ssh-add`), Node.js +20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use **act_runner 0.2.7 or newer** (prefer the latest maintained release), or gitea-runner 2+. Older act_runner does not provide `ACTIONS_RESULTS_URL`, which the pinned artifact action needs. Register the runner against `https://git.faumaray.ru`, reachable from both the host and @@ -158,8 +248,9 @@ ENDLESS_TASK_TIMEOUT = 9h Keep sufficient RAM/swap and free disk for all package builds and their Docker caches. The package builds run one after another, each with as many Cargo jobs as the host has CPUs. The workflow never prunes shared Docker -state or creates host swap. The token and optional Android signing secrets -are documented in +state or creates host swap. The secrets are the VoelinProtocol deploy key +([below](#voelinprotocol-access)), `RELEASE_TOKEN` and the optional Android +signing secrets, both documented in [Gitea releases](release.md#gitea-releases). The Gitea release job builds packages only: it runs no formatting, Clippy, diff --git a/docs/gateway-admin.md b/docs/gateway-admin.md index e1ade7f..e887ab1 100644 --- a/docs/gateway-admin.md +++ b/docs/gateway-admin.md @@ -240,7 +240,7 @@ the unit to `/etc/systemd/system/`. **Container** (`tsgw-image.tar.gz`, or build it): ```sh -docker load -i tsgw-image.tar.gz # or: docker build -f crates/voelin-gateway/Dockerfile -t tsgw . +docker load -i tsgw-image.tar.gz # or: docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw . docker run -d --name tsgw --init --restart unless-stopped \ -v $PWD/tsgw.toml:/etc/tsgw/tsgw.toml:ro -v tsgw-data:/var/lib/tsgw \ -e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw From e5956e40e9bbbb42ac0bdb149a44bccae28eacae Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 13:45:56 +0300 Subject: [PATCH 06/18] Set CARGO_NET_GIT_FETCH_WITH_CLI in the CI workflow's own env as well The checks action exports it through GITHUB_ENV, which depends on the runner handing a composite action's environment file on to the later steps of the job. If a runner did not, Cargo would silently go back to its built-in git client, which cannot use the deploy key's IdentityFile, and fail with a confusing authentication error in the first cargo command. The workflow-level env does not depend on that, so both are set; the access check step still exercises the key, the host key and the ssh configuration through git. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/workflows/ci.yml | 5 +++++ docs/ci.md | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 74c4ab6..df30ffa 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -20,6 +20,11 @@ on: env: CARGO_TERM_COLOR: always + # Cargo fetches the private VoelinProtocol dependency with the system git and + # ssh (docs/ci.md, "VoelinProtocol access"). The checks action exports this + # too; set here as well, it does not depend on the runner handing a composite + # action's GITHUB_ENV on to the later steps. + CARGO_NET_GIT_FETCH_WITH_CLI: "true" jobs: linux: diff --git a/docs/ci.md b/docs/ci.md index ad35dca..248e525 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -131,7 +131,8 @@ What is set up: line to `~/.ssh/known_hosts`, writes a `Host git.faumaray.com` block to `~/.ssh/config` (`User gitea`, that `IdentityFile`, `IdentitiesOnly yes`, `StrictHostKeyChecking yes`) and exports `CARGO_NET_GIT_FETCH_WITH_CLI=true` - and `GIT_SSH_COMMAND` for the rest of the job. It prints only the key's + and `GIT_SSH_COMMAND` for the rest of the job (`ci.yml` sets the first one + in its own `env` as well). It prints only the key's public fingerprint; the key is never echoed. After the system packages a second step runs `git ls-remote` on VoelinProtocol, so a wrong key or host key fails there, with the reason, and not inside a cargo command. The key From a856f90c6bec7b94dfe1ebb83def315cbc942c52 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:16:06 +0300 Subject: [PATCH 07/18] Refuse an unreadable TeamSpeak identity without its key in the text The Opus gate of the merge found that ts_session::inner_options put the raw serde_json error into the refusal of an identity it cannot read, and tsproto's key visitor reports a key that does not import as invalid_value(Unexpected::Str( key), ..), so the private key string reached LinkEvent::Disconnected(Some(text)), Event::Error and the UI status line. The classification ts::identity::from_blob already had (malformed, cut short, not an identity, unreadable, with line and column, never the value) is now ts::identity::from_json, which takes the JSON text; from_blob and inner_options both use it, so the refusal is worded in one place. A credential that is not UTF-8 is refused as "it is not text". Tests: identity::tests (a key that lost its last two characters: the JSON reader's own message quotes it, from_json and from_blob do not; no 8-character piece of the key), ts_session::tests (inner_options), link::tests (the LinkEvent::Disconnected text through SessionLink with the real connector) and session_fake (ConnectVoice through the engine: the Disconnected state, the Error event and every event after it). All three connector-side tests fail with the serde_json text put back. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/link/tests.rs | 26 +++++++++ crates/voelin-core/src/ts/identity.rs | 58 ++++++++++++++++++++- crates/voelin-core/src/ts/ts_session/mod.rs | 40 ++++++++++++-- crates/voelin-core/tests/session_fake.rs | 53 ++++++++++++++++++- 4 files changed, 170 insertions(+), 7 deletions(-) diff --git a/crates/voelin-core/src/link/tests.rs b/crates/voelin-core/src/link/tests.rs index 90f8c77..cf41183 100644 --- a/crates/voelin-core/src/link/tests.rs +++ b/crates/voelin-core/src/link/tests.rs @@ -981,6 +981,32 @@ async fn a_connect_that_fails_is_a_disconnect_with_the_reason() { ); } +/// An identity that cannot be read ends the connect with a disconnect whose +/// text says where it is wrong and holds none of the key: the JSON reader's +/// own message quotes a key that does not import, and the engine shows this +/// text as the error of the connection. +#[tokio::test(flavor = "multi_thread")] +async fn an_identity_that_cannot_be_read_is_a_disconnect_without_the_key() { + let (json, cut) = crate::ts::identity::json_with_a_cut_key(); + let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester"); + options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json)); + let link = SessionLink::new(Backends::default()); + let (_cmd_tx, cmd_rx) = mpsc::unbounded_channel(); + let (event_tx, mut events) = mpsc::unbounded_channel(); + link.spawn(options, LocalCtx::standalone().link, cmd_rx, event_tx); + let event = within("the end", events.recv()).await; + let LinkEvent::Disconnected(Some(text)) = event else { + panic!("a disconnect with the reason of the refusal") + }; + assert!( + text.starts_with( + "the TeamSpeak identity cannot be read: not an identity at line 1, column " + ), + "{text}" + ); + crate::ts::identity::assert_holds_no_piece_of(&text, &cut); +} + // ---- the TeamSpeak side alone --------------------------------------------------- /// A `LinkSession` over a recorder, made the way a connector makes it. diff --git a/crates/voelin-core/src/ts/identity.rs b/crates/voelin-core/src/ts/identity.rs index 83cbdc5..b517a1b 100644 --- a/crates/voelin-core/src/ts/identity.rs +++ b/crates/voelin-core/src/ts/identity.rs @@ -255,8 +255,20 @@ pub fn from_blob(blob: &IdentityBlob) -> Result { blob.kind ))); } - serde_json::from_str(&blob.json).map_err(|e| { - // Where the JSON is wrong, not what it says: it holds a private key. + from_json(&blob.json) +} + +/// The TeamSpeak identity in `json`, the text [`to_blob`] writes and the key +/// store keeps; every reader of that text refuses it through here. +/// +/// What does not read is refused in words that say how it is wrong +/// (malformed, cut short, not an identity, unreadable) and where (line and +/// column), and never what it holds: the text holds a private key, and the +/// message of the JSON reader quotes a value it refuses (`tsproto` reports a +/// key that does not import as an invalid value, the key string and all), so +/// that message is never shown, not in an error, an event or a log. +pub(crate) fn from_json(json: &str) -> Result { + serde_json::from_str(json).map_err(|e| { let what = match e.classify() { serde_json::error::Category::Syntax => "malformed", serde_json::error::Category::Eof => "cut short", @@ -271,6 +283,27 @@ pub fn from_blob(blob: &IdentityBlob) -> Result { }) } +/// The JSON of a fresh identity whose key lost its last two characters (a key +/// that does not import), and that cut key. +#[cfg(test)] +pub(crate) fn json_with_a_cut_key() -> (String, String) { + let mut json = serde_json::to_value(Identity::create()).unwrap(); + let key = json["key"].as_str().unwrap().to_owned(); + let cut = key[..key.len() - 2].to_owned(); + json["key"] = cut.clone().into(); + (json.to_string(), cut) +} + +/// Fail if `text` holds any 8 characters in a row of `secret`. +#[cfg(test)] +pub(crate) fn assert_holds_no_piece_of(text: &str, secret: &str) { + assert!(secret.len() >= 8 && secret.is_ascii()); + for piece in secret.as_bytes().windows(8) { + let piece = std::str::from_utf8(piece).unwrap(); + assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key"); + } +} + /// The TeamSpeak 3 `.ini` export of an identity, which the official client /// and every other tool reads. pub fn export(nickname: &str, identity: &Identity) -> String { @@ -615,6 +648,27 @@ mod tests { } } + /// The JSON reader's own message quotes a key that does not import, so the + /// refusal is worded by `from_json` and holds none of the key. + #[test] + fn a_key_that_does_not_import_is_refused_without_quoting_it() { + let (json, cut) = json_with_a_cut_key(); + let raw = serde_json::from_str::(&json).unwrap_err().to_string(); + assert!(raw.contains(&cut), "the reader's own message quotes the key: {raw}"); + for error in [ + from_json(&json).unwrap_err().to_string(), + from_blob(&IdentityBlob::teamspeak("x", 8, json.clone())).unwrap_err().to_string(), + ] { + assert!( + error.starts_with( + "the TeamSpeak identity cannot be read: not an identity at line 1, column " + ), + "{error}" + ); + assert_holds_no_piece_of(&error, &cut); + } + } + #[test] fn improve_level_keeps_the_key() { let identity = synthetic(); diff --git a/crates/voelin-core/src/ts/ts_session/mod.rs b/crates/voelin-core/src/ts/ts_session/mod.rs index b586d00..38a6df1 100644 --- a/crates/voelin-core/src/ts/ts_session/mod.rs +++ b/crates/voelin-core/src/ts/ts_session/mod.rs @@ -43,7 +43,7 @@ use voelin_proto::link::{ use voelin_proto::v1::{self, response::Result as Answer}; use self::driver::{Cmd, Config, Driver, Parts, rejected}; -use super::{ConnectOptions, ServerLink, TsLink, versions}; +use super::{ConnectOptions, ServerLink, TsLink, identity, versions}; use crate::BackendInfo; use crate::link::{ BoxDuplex, LinkCmd, LinkCtx, LinkEvent, LocalConnected, LocalConnector, LocalCtx, StreamPort, @@ -82,9 +82,14 @@ fn inner_options(params: &ConnectParams, ctx: &LocalCtx) -> Result None, Credential::Foreign { kind: IDENTITY_KIND, blob } => { - Some(serde_json::from_slice(blob).map_err(|e| { - SessionError::Protocol(format!("the TeamSpeak identity cannot be read: {e}")) - })?) + // The refusal never quotes the JSON: it holds the private key, and the + // JSON reader's own message would show a key that does not import. + let json = std::str::from_utf8(blob).map_err(|_| { + SessionError::Protocol( + "the TeamSpeak identity cannot be read: it is not text".into(), + ) + })?; + Some(identity::from_json(json).map_err(|e| SessionError::Protocol(e.to_string()))?) } _ => { return Err(SessionError::Protocol( @@ -754,6 +759,33 @@ mod tests { assert!(!futures::executor::block_on(confirm)); } + /// An identity that cannot be read ends the connect with words that say + /// where it is wrong and hold none of the key: the JSON reader's own + /// message quotes a key that does not import, and this text reaches the + /// event bus and the status line. + #[test] + fn an_identity_that_cannot_be_read_is_refused_without_the_key() { + let (json, cut) = identity::json_with_a_cut_key(); + let mut sent = params(&VoiceOptions::new("ts.example.com", "nick")); + sent.credential = Credential::Foreign { kind: "teamspeak", blob: Bytes::from(json) }; + let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err(); + let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") }; + assert!( + text.starts_with( + "the TeamSpeak identity cannot be read: not an identity at line 1, column " + ), + "{text}" + ); + identity::assert_holds_no_piece_of(&text, &cut); + + // Not even text. + sent.credential = + Credential::Foreign { kind: "teamspeak", blob: Bytes::from_static(&[b'{', 0xff]) }; + let error = inner_options(&sent, &LocalCtx::standalone()).unwrap_err(); + let SessionError::Protocol(text) = error else { panic!("a protocol error: {error:?}") }; + assert_eq!(text, "the TeamSpeak identity cannot be read: it is not text"); + } + #[test] fn the_params_carry_what_the_session_needs_and_no_account_yet() { let sent = params(&VoiceOptions::new("ts.example.com", "nick")); diff --git a/crates/voelin-core/tests/session_fake.rs b/crates/voelin-core/tests/session_fake.rs index e7fe65c..fa974ba 100644 --- a/crates/voelin-core/tests/session_fake.rs +++ b/crates/voelin-core/tests/session_fake.rs @@ -10,7 +10,9 @@ //! dedup of a message that comes twice, history, transfers, offline messages, //! the features of a host, a reconnect and the media of a session are the //! engine's own behaviour; nothing here needs a TeamSpeak server or a -//! TeamSpeak type. +//! TeamSpeak type, except `a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key`, +//! which runs the engine's own TeamSpeak connector up to its refusal of an +//! identity. use std::path::PathBuf; use std::sync::Arc; @@ -163,6 +165,12 @@ impl Harness { fn on(connector: FakeConnector) -> Self { let mut backends = Backends::empty(); backends.register(Arc::new(connector.clone())); + Self::with_backends(backends, connector) + } + + /// The engine on `backends`; `connector` is the fake host the test may + /// have registered in them (a test that registers none leaves it unused). + fn with_backends(backends: Backends, connector: FakeConnector) -> Self { let engine = Engine::start_with_backends(Settings::in_memory(), History::in_memory(), backends); let events = engine.subscribe(); @@ -1502,3 +1510,46 @@ async fn a_teamspeak_identity_without_json_is_refused_and_no_session_is_made() { assert!(handle.close_reason().is_none()); assert_eq!(h.connector.connects().len(), 1); } + +/// A TeamSpeak identity whose key does not import ends the connect with words +/// that say where the JSON is wrong and never show the key: the JSON reader's +/// own message quotes it, and the text is the reason of the disconnect, the +/// `Error` event and the status line the UI makes of it. This is the one test +/// of the file that runs the engine's own TeamSpeak connector +/// (`Backends::default()`): the refusal is that connector's and comes before +/// any network. +#[tokio::test(flavor = "multi_thread")] +async fn a_teamspeak_identity_that_cannot_be_read_is_refused_without_the_key() { + let mut json = serde_json::to_value(tsclientlib::Identity::create()).unwrap(); + let key = json["key"].as_str().unwrap().to_owned(); + // The key lost its last two characters. + let cut = key[..key.len() - 2].to_owned(); + json["key"] = cut.clone().into(); + let mut options = VoiceOptions::new("ts3server://127.0.0.1:9", "tester"); + options.identity = Some(IdentityBlob::teamspeak("uid=", 8, json.to_string())); + + let mut h = Harness::with_backends(Backends::default(), FakeConnector::new()); + h.engine.send(Command::ConnectVoice { session: SESSION, options: Box::new(options) }); + let state = h.state(|s| s.voice == VoiceState::Disconnected).await; + assert_eq!((state.own_channel, state.own_client), (None, None)); + let error = h.error().await; + assert!( + error.starts_with( + "voice: the TeamSpeak identity cannot be read: not an identity at line 1, column " + ), + "{error}" + ); + // Nothing the engine reported afterwards holds a piece of the key either. + let mut shown = vec![error]; + while let Ok(Ok(event)) = + tokio::time::timeout(Duration::from_millis(300), h.events.recv()).await + { + shown.push(format!("{event:?}")); + } + for text in &shown { + for piece in cut.as_bytes().windows(8) { + let piece = std::str::from_utf8(piece).unwrap(); + assert!(!text.contains(piece), "{text:?} holds {piece:?} of the key"); + } + } +} From 563482db729afbd6ea242b2c01e9c508c6f2a265 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:17:16 +0300 Subject: [PATCH 08/18] Document VoiceOptions.nickname and server_password; correct Backends::set_account Both fields were carried over from ConnectOptions without a doc: what the nickname is on each kind of server and that an empty one falls back to the link's nickname parameter; that the server password is Hello.password, falls back to the link's password parameter and is not the channel's. Backends::set_account said the connectors use the account (the QUIC connector's certificate, the TeamSpeak connector's myTS ID proof). No connector reads ConnectParams.account yet: the TeamSpeak one is given the myTeamSpeak account through TsConnector's setters, and the QUIC connector does not exist. The doc says so and names H4 as the step that moves the proof to this hook. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/link/backends.rs | 10 +++++++--- crates/voelin-core/src/link/mod.rs | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/voelin-core/src/link/backends.rs b/crates/voelin-core/src/link/backends.rs index afabc1d..951a697 100644 --- a/crates/voelin-core/src/link/backends.rs +++ b/crates/voelin-core/src/link/backends.rs @@ -166,9 +166,13 @@ impl Backends { self.register_local(Arc::new(connector)); } - /// The device's Voelin account, for the connectors that use it (the QUIC - /// connector's certificate, the TeamSpeak connector's myTS ID proof). - /// None is the default: nothing uses an account yet. + /// The device's Voelin account, which every connect hands the connector as + /// `ConnectParams::account`. No connector reads it yet: the TeamSpeak + /// connector takes the myTeamSpeak account it presents from its own setters + /// ([`TsConnector::set_myts_identity`], [`TsConnector::set_myts_data`]), and a + /// Voelin host's connector (the QUIC one, for its certificate) does not exist + /// yet. Follow-up H4 of `docs/session-seam.md` (11.2) moves the myTeamSpeak + /// proof from those setters to this hook. None is the default. pub fn set_account(&mut self, agent: Option>) { self.account = agent; } diff --git a/crates/voelin-core/src/link/mod.rs b/crates/voelin-core/src/link/mod.rs index 0010497..e83203b 100644 --- a/crates/voelin-core/src/link/mod.rs +++ b/crates/voelin-core/src/link/mod.rs @@ -64,6 +64,10 @@ pub struct VoiceOptions { /// scheme (`ts3server://`, `teamspeak://`, a Voelin host's `voelin://`) /// that picks the connector ([`Backends`]). pub address: String, + /// The name shown on the server: `Hello.nickname` to a Voelin host, the + /// client name on a TeamSpeak server (which may refuse or change it). When + /// it is empty, the `nickname` parameter of an `address` that is a + /// TeamSpeak link applies. pub nickname: String, /// The identity to connect with: a TeamSpeak identity /// ([`crate::ts::identity::to_blob`]) for a TeamSpeak server, a Voelin key @@ -76,6 +80,10 @@ pub struct VoiceOptions { /// `@`); `None` is the native platform's. A spec that is /// none ends the connect with the reason. Other backends ignore it. pub client_version: Option, + /// The password of the server (`Hello.password`), for one that has a + /// password. When it is `None` or empty, the `password` parameter of an + /// `address` that is a TeamSpeak link applies. Not the password of + /// `channel` (that is `channel_password`). pub server_password: Option, /// Channel path to join, e.g. `Lobby/Sub`, or `/`. pub channel: Option, From 96ff0e0028923919a2e36de29a64845f410daf89 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:20:02 +0300 Subject: [PATCH 09/18] Write down the complete edge list between the engine and src/ts for H9 17.6 of docs/session-seam.md named two engine-to-ts edges; the Opus gate of the merge found the rest. Each line was checked with rg and cargo tree: - the engine into src/ts: Backends::default and register_teamspeak, the uid and id rule of the projection, gateway.rs from_blob/to_blob (H5), the public voelin_core::ts paths and their users in voelinctl and the UI crates, the API docs that link into ts, and the test-only edges; - what a TeamSpeak connector in another crate cannot do with Backends::register (no LocalCtx, no StreamPort): streams across the crate boundary need H2 or a public extension trait; - src/ts into engine-private items (link, stream, files, offline, the crate root, settings), with the conclusion that the "by git tag" step needs H1 and H2 or a shared vocabulary crate, else voelin-core and voelin-gateway-ts form a cycle; - what else keeps tsclientlib and tsproto in voelin-core's tree, so that the exit check needs H5 too, and voelin-store, voelin-stream and voelin-gateway-proto lose the dependency; - the split of stream.rs; - the same key-quoting leak in voelin-store's Store::identity, not closed. The H9 row of 11.2 points to the list and no longer says the exit check holds after H1-H3 alone. Co-Authored-By: Claude Sonnet 5.5 --- docs/session-seam.md | 111 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) diff --git a/docs/session-seam.md b/docs/session-seam.md index 169d023..7f11c9c 100644 --- a/docs/session-seam.md +++ b/docs/session-seam.md @@ -929,7 +929,7 @@ Nothing here blocks this half: each has a workaround above. | H6 | Avatars and icons as attachments (`Image.attachment_id`, content-addressed cache) instead of channel-0 paths. | | H7 | The UI on the replica (Phase 5): the old-model projection and F1-F10 go; `u16` client ids widen to `u32` participants. | | H8 | Reconnect with backoff, resume tokens and persisted cursors move to `voelin-sdk` once it exists; the engine consumes the SDK. | -| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3 and this. Two edges run from the engine into `src/ts/` and have to be cut first: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). | +| H9 | Move `src/ts/` (with its live tests) to `voelin-gateway-ts` (features `basic`, `streams`), first behind a `ts` feature of `voelin-core`, then by git tag; the exit check of plan step 6, `cargo tree -p voelin-core -e normal \| grep -E 'tsclientlib\|tsproto'` empty, holds after H1-H3, H5 and this (17.6 has the complete list of the edges between the engine and `src/ts/`, the stream split and the other crates that carry `tsclientlib`). The first two to cut run from the engine into `src/ts/`: `Backends::default` registers `ts::TsConnector` (the `ts` feature makes it optional), and `link/project.rs` and `link/session_link.rs` import `ts::ts_session::{entities::user_uid, ids}`, the id and uid rule that the projection undoes the synthetic ids with (it moves to the engine side, or into `voelin-model`'s replica conversion, which already has `uid_text`). | ### 11.3 Coordination @@ -1634,9 +1634,112 @@ were fresh compose projects (`down -v`, `up -d`) for each smoke run. ### 17.6 Follow-ups -- **H9 gains two edges to cut** (11.2): `Backends::default` and the use of - `ts::ts_session::{entities::user_uid, ids}` in `link/project.rs` and - `link/session_link.rs`. +- **H9 starts from the complete edge list below.** The Opus gate of the merge + (2026-10-24) found that 11.2 names two edges and the tree has more. Each + line was checked with `rg` and `cargo tree` on the tree of the follow-up + round (`phase4/seam-followups`); file lines are given where the file did not + change in the round, items by name where it did. + + 1. **From the engine into `src/ts/`**: what has to be cut or moved before + `ts` can leave the crate. + + | Where | What | Goes with | + |---|---|---| + | `link/backends.rs` | `use crate::ts::TsConnector`; `Backends::default` registers `TsConnector::new()`; `Backends::register_teamspeak(TsConnector)` is the only public way to register an in-process connector and goes through the crate-private `register_local(Arc)` | H9: the `ts` feature makes `default` optional | + | `link/project.rs:20-21`, `link/session_link.rs:565, 973, 1328` | `ts::ts_session::entities::user_uid` and `ts::ts_session::ids::{self, FOREIGN_SYSTEM}`: the id and uid rule the projection undoes the synthetic ids with | H9: to the engine side, or into `voelin-model`'s replica conversion (`uid_text`) | + | `gateway.rs:98, 1209` | `ts::identity::{from_blob, to_blob}`: 98 is `login_identity` (the blob to the `tsclientlib::Identity` the gateway login is made of), 1209 is a test | H5: the gateway becomes a `Session` and takes the blob as a credential | + | `lib.rs:69` | `pub mod ts`: the public paths `voelin_core::ts::{identity, versions, TsConnector}` | H9: they move or are re-exported | + | outside the crate: `tools/voelinctl/src/{engine,identity,versions,client}.rs`, `crates/voelin-ui/src/{app,servers}.rs` and `settings_pages/bind.rs`, `crates/voelin-ui-vm/src/settings_pages/logic.rs`, `crates/voelin-core/tests/gateway.rs` | users of `voelin_core::ts::identity::*` and `ts::versions::*` (`to_blob`, `Found`, `import`, `import_new`, `discover`, `read`, `write_export`, `improve_level`, `LaunchImport`, `DEFAULT_NICKNAME`, `resolve`, `native_version`, `known_versions`, `client_metadata`) | H9: re-point to the new crate (`crates/voelin-ui*` belong to `phase5/ui-vm-2`) | + | docs: `lib.rs:8` (`ts::TsConnector`), `lib.rs:129` (`Command::ObserveGateway`: `ts::identity::to_blob`), `gateway.rs:103` (`to_blob`), `settings.rs:1138` (`import_new`); in `link/mod.rs` the module doc (`TsConnector`), `VoiceOptions::identity` (`to_blob`) and `VoiceOptions::client_version` (`ts::versions::resolve`) | intra-doc links into `ts`, which `cargo doc` with `-D warnings` resolves only while `ts` is in the crate | H9: reworded, or pointed at the new crate's docs | + + A TeamSpeak connector in another crate has only + `Backends::register(Arc)`: `register_teamspeak` takes the + crate's own `TsConnector`, and `LocalConnector`, `LocalCtx`, + `LocalConnected` and `StreamPort` are crate-private. A plain `Connector` + is handed neither the `LocalCtx` (the event bus, `audio`, `stream_peer`) + nor a `StreamPort` (`Backends::connect` makes its `LocalConnected` with + `streams: None`), so its sessions have no TeamSpeak 6 streams. Streams + across the crate boundary need H2 first, or a public extension trait that + takes the place of `LocalConnector`. + + *Test-only* edges, which move with the tests of each side: + `link/tests.rs` and `link/fake_link_tests.rs` (lines 30-31 of both) use + `ts::ts_session::LinkConnector` and `ts::{ConnectOptions, ServerLink}`; + the tests of `link/session_link.rs` use `ts_session::{backend_to_v1, + features_of}`; `link/tests.rs` uses the helpers + `ts::identity::{json_with_a_cut_key, assert_holds_no_piece_of}` and + `tests/session_fake.rs` builds a `tsclientlib::Identity` and runs + `Backends::default()` in one test (both from this round, with the gate's + minor). + + 2. **From `src/ts/` into engine-private items**: the reverse edges. + + | Module of the engine | Items `src/ts/` uses | + |---|---| + | `crate::link` | `LinkCmd`, `LinkEvent`, `LinkCtx` (its `session`, `events`, `frames`, `settings`, `emit`, `done`), `Remote`, `BoxRead`, `BoxDuplex` (`ts/voice.rs`, `ts/ts_link.rs`, `ts/ts_session/driver.rs`); `LocalConnector`, `LocalCtx`, `LocalConnected`, `StreamPort`, `VERSION_PARAM`, `without_query` (`ts/ts_session/mod.rs`); `StreamEvent` (`driver.rs`) | + | `crate::stream` | `StreamCmd` (`voice.rs`, `driver.rs`), `StreamHandle`, `StreamInput` (`voice.rs`) | + | `crate::files` | `FileEntry`, `RequestId`, `TransferState`, and the functions `normalize_dir` and `join_path` (`voice.rs`, `driver.rs`) | + | `crate::offline` | `OfflineMessage`, `OfflineMessageInfo` (`voice.rs`, `driver.rs`) | + | the crate root | `Event`, `JoinFailure`, `BackendInfo`, `POKE_MESSAGE_MAX` | + | `crate::settings` | `SharedSettings`, through `LinkCtx.settings`, which `voice.rs` hands to the stream task | + | tests only | `crate::link::{Backends, VoiceOptions, connect_params}` (`ts_session/mod.rs`, `live_tests.rs`), `crate::link::media::TalkTracker` and `crate::link::project::{View, presence}` (`ts/book.rs`), `crate::settings::{SharedSettings, Settings}` and `crate::files::{Report, Sink}` (`ts/voice.rs`) | + + Together with the first list this is a cycle: `voelin-core` would need + `voelin-gateway-ts` for `TsConnector` and the uid rule, and + `voelin-gateway-ts` needs `voelin-core` for every item above. So the "by + git tag" step of H9 needs **H1 and H2** (the TeamSpeak side speaks v1 + through `Session`, which takes the place of `LinkCmd`, `LinkEvent`, + `LinkCtx`, `StreamPort` and the stream task's input) **or a shared + vocabulary crate** that holds the items above for both sides. Without + one of the two, only the first step, the `ts` feature of `voelin-core`, + is possible. + + 3. **What else keeps `tsclientlib` and `tsproto` in the tree.** The exit + check (`cargo tree -p voelin-core -e normal | grep -E 'tsclientlib|tsproto'` + empty) is not met by moving `src/ts/` alone: + - `voelin-core` itself: its four direct dependencies (`tsclientlib`, + `tsproto`, `tsproto-packets`, `tsproto-types`) leave with `src/ts/`, + but `gateway.rs` uses `tsclientlib::Identity` (`login_identity`, + `connect_watched`, `attempt`: H5) and `stream.rs` uses + `tsclientlib::ClientId` (item 4). + - Three more crates of `voelin-core`'s tree carry the dependency: + `voelin-store` (`store.rs` and `keystore.rs` take, read and check a + `tsclientlib::Identity`), `voelin-stream` (`proto.rs`, `session.rs`, + `discovery.rs`: `tsclientlib::{ClientId, InMessage, messages::c2s}` and + `tsproto_packets::packets::OutCommand`; H3 splits it) and + `voelin-gateway-proto` (`auth.rs`, `client.rs`: + `tsproto_types::crypto::EccKeyPrivP256`, the key of the gateway login; + H5). `cargo tree -p -e normal` shows it for each of the three. + - `voelin-query` and `voelin-observer` have none, so `query.rs` using + `voelin_query` is not an edge of the exit check; it goes with H5 + because the query observer becomes a `Session` of a gateway daemon. + - So the exit check needs H1-H3, **H5**, a way for `voelin-store` to + handle a TeamSpeak identity without `tsclientlib`'s type, and H9. + + 4. **`stream.rs` must be split.** Stays with the engine: `StreamState`, + `WatchState`, `StreamFrame`, `StreamSink` and `LayerFormat` (public API), + `StreamCmd`, `OwnStreamEvent`, `kind_name`, `parse_kind` and + `parse_srtp_profiles` (`session.rs`), `media_codec` (`media.rs`) and the + re-exports of `stream_types` (`StreamInfo`, `StreamKind`, `StreamSetup`, + `ViewerInfo`, ...). Goes with the TeamSpeak 6 task: `StreamHandle`, + `StreamTask` and its helpers, `StreamInput`, the `StreamLookup` over the + gateway directory, and every use of `tsclientlib::ClientId` (the engine's + own ids are `u16`; `stream.rs` wraps them for `voelin-stream`). + + 5. **The engine API docs that link into `ts` move with it** (the last row of + the table of item 1): `VoiceOptions::identity` and + `Command::ObserveGateway` link `ts::identity::to_blob`, + `VoiceOptions::client_version` links `ts::versions::resolve`. + +- **The same leak in `voelin-store`, not closed.** `Store::identity` and + `Store::identities` read the stored JSON of a TeamSpeak identity with `?`, so + an `Error::Json` whose text is the `serde_json` message, which quotes a key + that does not import, as the gate's minor did in the connector. The rows are + written from a `tsclientlib::Identity` (`add_identity`), so a damaged + database is the only way to such a row; the key store (`keystore.rs`) drops + the parse error for the same reason. `ts::identity::from_json` cannot be + used there (`voelin-core` depends on `voelin-store`); the fix is the same + classification in `voelin-store`, or `from_json` moved down. - The bookmark tests of `link/connect.rs` that still sit in `ts/ts_session/mod.rs` (17.2) belong next to it. - `QueryLogin.allowlisted` goes with the query observer (H5), which becomes a From 9254e08daa33b81caddbf219190bc0d8797888dd Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:21:22 +0300 Subject: [PATCH 10/18] Ask improve_level for more than the test identity already has ts::identity::tests::improve_level_keeps_the_key made its identity with Identity::create(), which stops at the first counter whose level is 8 or more, and asked improve_level for 13. About one identity in 32 has 13 or more already, and improve_level then returns it as it is, so the assertion that the counter grew failed: 8 failures in 300 runs of the single test before this change, 0 in 300 after. The target is now three levels above what the identity has, so the search always runs. The assertions on the level, the callbacks and the counter use that target. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/ts/identity.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/voelin-core/src/ts/identity.rs b/crates/voelin-core/src/ts/identity.rs index b517a1b..8adbd9f 100644 --- a/crates/voelin-core/src/ts/identity.rs +++ b/crates/voelin-core/src/ts/identity.rs @@ -672,15 +672,19 @@ mod tests { #[test] fn improve_level_keeps_the_key() { let identity = synthetic(); + // A fresh identity stops at the first counter whose level is 8 or more, + // and about one in 32 has 13 or more already, which `improve_level` + // returns as it is: ask for more than this one has, whatever it has. + let target = identity.level() + 3; let levels = std::sync::Mutex::new(Vec::new()); - let better = improve_level(&identity, 13, &AtomicBool::new(false), |l| { + let better = improve_level(&identity, target, &AtomicBool::new(false), |l| { levels.lock().unwrap().push(l); }) .unwrap(); - assert!(better.level() >= 13); + assert!(better.level() >= target); assert_eq!(better.key().to_pub().get_uid(), identity.key().to_pub().get_uid()); assert!(better.counter() > identity.counter()); - assert!(levels.into_inner().unwrap().iter().any(|l| *l >= 13)); + assert!(levels.into_inner().unwrap().iter().any(|l| *l >= target)); // Cancelled: nothing. assert!(improve_level(&identity, 60, &AtomicBool::new(true), |_| {}).is_none()); // Already there: the same identity. From b8ba43f0c98a83ba4e31bef100e632f4224d92ad Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:24:19 +0300 Subject: [PATCH 11/18] Check each OpenSSH tool on its own and stop only an agent this job started command -v with two names returns 0 when one resolves, so the guards were weaker than they read. The release workflow's final step killed whatever agent SSH_AGENT_PID named; it now needs the marker the start step writes after it succeeded. Two documentation lines re-wrapped (the review's three minors). Co-Authored-By: Claude Fable 5.1 --- .gitea/actions/checks/action.yml | 10 ++++++---- .gitea/workflows/release.yml | 8 ++++++-- docs/building.md | 3 ++- docs/ci.md | 5 +++-- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.gitea/actions/checks/action.yml b/.gitea/actions/checks/action.yml index a01e6c5..92a8b82 100644 --- a/.gitea/actions/checks/action.yml +++ b/.gitea/actions/checks/action.yml @@ -26,10 +26,12 @@ runs: echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2 exit 1 fi - command -v ssh ssh-keygen > /dev/null || { - echo "::error::The job image needs the OpenSSH client (ssh, ssh-keygen)." >&2 - exit 1 - } + for tool in ssh ssh-keygen; do + command -v "$tool" > /dev/null || { + echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2 + exit 1 + } + done ssh_dir="$HOME/.ssh" key_file="$ssh_dir/voelin_protocol" mkdir -p "$ssh_dir" diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 1bf5c2a..928f3ab 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -46,7 +46,9 @@ jobs: echo "::error::The repository secret VOELIN_PROTOCOL_DEPLOY_KEY is missing or empty. It holds the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2 exit 1 fi - command -v ssh-agent ssh-add > /dev/null + for tool in ssh-agent ssh-add; do + command -v "$tool" > /dev/null || { echo "::error::The runner needs the OpenSSH client: $tool is missing." >&2; exit 1; } + done eval "$(ssh-agent -s -t 32400)" > /dev/null started= trap '[[ -n "$started" ]] || ssh-agent -k > /dev/null' EXIT @@ -58,6 +60,8 @@ jobs: { echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" echo "SSH_AGENT_PID=$SSH_AGENT_PID" + # Only an agent this job started is stopped at the end. + echo "VOELIN_AGENT_STARTED=1" } >> "$GITHUB_ENV" started=1 - name: Linux packages @@ -135,6 +139,6 @@ jobs: - name: Stop the ssh-agent if: always() run: | - if [[ -n "${SSH_AGENT_PID:-}" ]]; then + if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then ssh-agent -k > /dev/null || true fi diff --git a/docs/building.md b/docs/building.md index c2d6707..8c3cdb0 100644 --- a/docs/building.md +++ b/docs/building.md @@ -81,7 +81,8 @@ scripts/docker-build.sh android # → dist/android/ scripts/docker-build.sh # all three ``` -The same with plain Docker, e.g. `docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .` +The same with plain Docker, e.g. `docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .`. + **The builds need an ssh-agent that holds a key able to read the private VoelinProtocol repository** ([below](#depending-on-voelinprotocol)): Cargo fetches it inside the image, through the agent that `--ssh default` hands to the diff --git a/docs/ci.md b/docs/ci.md index 248e525..61871e7 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -206,8 +206,9 @@ voelin-release:host ``` Provision Bash, Git, the OpenSSH client (`ssh-agent` and `ssh-add`), Node.js -20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use **act_runner 0.2.7 or newer** (prefer the latest -maintained release), or gitea-runner 2+. Older act_runner does not provide +20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use +**act_runner 0.2.7 or newer** (prefer the latest maintained release), or +gitea-runner 2+. Older act_runner does not provide `ACTIONS_RESULTS_URL`, which the pinned artifact action needs. Register the runner against `https://git.faumaray.ru`, reachable from both the host and build containers. Gitea 1.25.4 provides the required artifact-v4 API. From 0d67dd7433211d89019bc4710821728d38e16bf9 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:24:30 +0300 Subject: [PATCH 12/18] Reopen the contacts database after the first engine has closed it voice_features::contacts_are_kept_in_the_database dropped its engine and opened the same database again at once. Dropping an Engine does not close the history database: the engine task ends later, the history writer is joined there, and closing the connection checkpoints the write-ahead log under an exclusive lock with fsyncs. The second History::open waits for that lock only for the 5 s busy timeout, and fails with DatabaseBusy when a loaded disk makes the close take longer (seen as 3 failures in 8 runs, 10 in 24 with eight runs at a time). The test now waits until the -wal file is gone, which SQLite does when the last connection closes, before it reopens: the restart of a process, as the test means it. With every fsync of the test process delayed by 6 s (strace -e inject=fsync,fdatasync:delay_enter=6000000) the old test failed every time at the reopen with DatabaseBusy, and the new one passes. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/tests/voice_features.rs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/voelin-core/tests/voice_features.rs b/crates/voelin-core/tests/voice_features.rs index 6b4cfb8..69f7d99 100644 --- a/crates/voelin-core/tests/voice_features.rs +++ b/crates/voelin-core/tests/voice_features.rs @@ -3,6 +3,7 @@ //! in the client database). The round trips against real servers are in //! `scripts/it-smoke.sh` (`voelinctl engine`). +use std::path::{Path, PathBuf}; use std::time::Duration; use tokio::sync::broadcast; @@ -22,6 +23,29 @@ async fn next(rx: &mut broadcast::Receiver, mut f: impl FnMut(Event) - .expect("event in time") } +/// Wait until nothing has the SQLite database at `path` open any more, as when +/// the process that had it has ended: SQLite deletes the write-ahead log +/// (`-wal`) when the last connection closes. +/// +/// A dropped `Engine` is not that yet. Its task ends later, the history writer +/// is joined there, and closing the connection checkpoints the log under an +/// exclusive lock, with fsyncs. A connection opened meanwhile waits for the +/// lock only as long as the busy timeout (5 s) and then fails with +/// `DatabaseBusy`, which a loaded disk makes happen (with every fsync taking +/// 6 s it happens every time). +async fn closed(path: &Path) { + let mut wal = path.as_os_str().to_owned(); + wal.push("-wal"); + let wal = PathBuf::from(wal); + tokio::time::timeout(Duration::from_secs(120), async { + while wal.exists() { + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("the engine's database connection closed"); +} + #[tokio::test(flavor = "multi_thread")] async fn requests_without_voice_fail_with_their_ids() { let engine = Engine::start(); @@ -165,6 +189,7 @@ async fn contacts_are_kept_in_the_database() { engine.history().flush(); } // A new engine attaches the database later: the contacts come back. + closed(&path).await; let engine = Engine::start(); let mut rx = engine.subscribe(); engine.send(Command::AttachHistory(History::open(&path).unwrap())); From 4be37e1fd117da14e4c4223e8076b77c57db6d9e Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:28:07 +0300 Subject: [PATCH 13/18] Record log lines in the tests through one subscriber for the whole process web::tests::info_lines read the lines a closure logs with tracing::subscriber::with_default. While that scoped subscriber is the only one alive, tracing-core registers a callsite that another thread meets first against that thread's own default, which is none, and the callsite stays disabled for every thread. session::banner_tests:: a_failing_banner_is_logged_once_with_its_address flaked this way (lines == [], once in a full run of slice 3); several other tests reach the same "banner not downloaded" callsite through image_finished while it runs. The old helper failed 1 of 300 runs of banner_tests, and always on a single thread that meets the callsite first (the new test below). info_lines now installs a recording subscriber as the global default the first time it is called, and each call records into a buffer of its own thread, so every callsite is registered against the same subscriber and no scoped dispatcher is created or dropped while tests run. The result is the same: the lines `f` logged at info and above on its thread. The new test info_lines_see_a_callsite_another_thread_met_first fails with the old helper (lines == []) and passes with the new one; the new helper failed 0 of 600 runs of the same tests. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/web.rs | 71 +++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 8 deletions(-) diff --git a/crates/voelin-core/src/web.rs b/crates/voelin-core/src/web.rs index a806ab3..e464aba 100644 --- a/crates/voelin-core/src/web.rs +++ b/crates/voelin-core/src/web.rs @@ -960,11 +960,27 @@ pub(crate) mod tests { /// What `f` logs at info (and above) on this thread: each line its /// message, then its fields (` name=value`). + /// + /// One recording subscriber is installed for the whole test process, the + /// first time this is called, and each call records into a buffer of its + /// own thread. A scoped one (`tracing::subscriber::with_default`) loses + /// lines: while it is the only subscriber alive, a callsite that another + /// test's thread meets first is registered against that thread's own + /// default, which is none, and stays disabled for every thread, so the + /// lines of the test that reads them are gone + /// (`session::banner_tests::a_failing_banner_is_logged_once_with_its_address` + /// failed with no lines at all, once in about thirty runs of the suite). pub(crate) fn info_lines(f: impl FnOnce() -> T) -> (T, Vec) { + use std::cell::RefCell; + use std::sync::Once; use tracing::field::{Field, Visit}; use tracing::span; - struct Lines(Arc>>); + thread_local! { + /// The lines of the `info_lines` running on this thread, if any. + static LINES: RefCell>> = const { RefCell::new(None) }; + } + #[derive(Default)] struct Line(String, String); impl Visit for Line { @@ -975,7 +991,8 @@ pub(crate) mod tests { } } } - impl tracing::Subscriber for Lines { + struct Recorder; + impl tracing::Subscriber for Recorder { fn enabled(&self, metadata: &tracing::Metadata<'_>) -> bool { *metadata.level() <= tracing::Level::INFO } @@ -985,19 +1002,57 @@ pub(crate) mod tests { fn record(&self, _: &span::Id, _: &span::Record<'_>) {} fn record_follows_from(&self, _: &span::Id, _: &span::Id) {} fn event(&self, event: &tracing::Event<'_>) { - let mut line = Line::default(); - event.record(&mut line); - self.0.lock().unwrap().push(line.0 + &line.1); + LINES.with(|lines| { + if let Some(lines) = lines.borrow_mut().as_mut() { + let mut line = Line::default(); + event.record(&mut line); + lines.push(line.0 + &line.1); + } + }); } fn enter(&self, _: &span::Id) {} fn exit(&self, _: &span::Id) {} } - let lines = Arc::new(Mutex::new(Vec::new())); - let result = tracing::subscriber::with_default(Lines(lines.clone()), f); - let lines = lines.lock().unwrap().clone(); + /// Ends the recording of this thread, also when `f` panics. + struct Recording; + impl Drop for Recording { + fn drop(&mut self) { + LINES.with(|lines| lines.borrow_mut().take()); + } + } + + static INSTALL: Once = Once::new(); + INSTALL.call_once(|| { + tracing::subscriber::set_global_default(Recorder) + .expect("no other global tracing subscriber in the tests"); + // Makes every callsite decide again with the subscriber in place, also + // one that a thread was registering while it was being installed + // (creating a `Dispatch` rebuilds the cached interest of all of them). + drop(tracing::Dispatch::new(Recorder)); + }); + + LINES.with(|lines| *lines.borrow_mut() = Some(Vec::new())); + let _recording = Recording; + let result = f(); + let lines = LINES.with(|lines| lines.borrow_mut().take().unwrap_or_default()); (result, lines) } + /// The lines of `info_lines` do not depend on which thread met a callsite + /// first: this one is met on another thread, which records nothing, before + /// the thread that reads the lines meets it. + #[test] + fn info_lines_see_a_callsite_another_thread_met_first() { + fn log() { + tracing::info!("met"); + } + let ((), lines) = info_lines(|| { + std::thread::spawn(log).join().unwrap(); + log(); + }); + assert_eq!(lines, ["met"]); + } + fn temp_dir(tag: &str) -> std::path::PathBuf { let dir = std::env::temp_dir().join(format!("voelin-web-{tag}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); From e614a1c3f1ca825c6f5c67c2a408a483b9157136 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:29:29 +0300 Subject: [PATCH 14/18] Probe localhost at the IPv4 loopback in the discovery test discover::tests::without_records_the_gateway_itself_is_asked starts a server on 127.0.0.1 and has the discovery ask the gateway at "127.0.0.1", "127.0.0.1:9987" and "localhost". The probe connected to the name through the system's resolver, and on a machine that resolves localhost to ::1 only (this one) nothing listens there: the third address found no gateway. The test helper that makes the probe, probing, connects to localhost at 127.0.0.1 instead. What the test checks is that the gateway is asked at the name localhost, not what the resolver makes of it, so it no longer depends on the resolver. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/discover.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/voelin-core/src/discover.rs b/crates/voelin-core/src/discover.rs index e1da0cb..170f4f7 100644 --- a/crates/voelin-core/src/discover.rs +++ b/crates/voelin-core/src/discover.rs @@ -453,10 +453,15 @@ mod tests { lookups } - /// `lookups` asking the real `/.well-known/tsgw` at `port`. + /// `lookups` asking the real `/.well-known/tsgw` at `port`. A name is + /// connected to through the system's resolver, except `localhost`: the + /// servers of the tests listen on 127.0.0.1, and some machines resolve + /// `localhost` to `::1` only. (The test cares that the gateway is asked at + /// the name `localhost`, not what the resolver makes of it.) fn probing(mut lookups: Lookups, port: u16) -> Lookups { lookups.probe = Arc::new(move |name| { - async move { timeout(PROBE_TIMEOUT, well_known(&name, port)).await.ok()?.ok() }.boxed() + let host = if name == "localhost" { "127.0.0.1".to_owned() } else { name }; + async move { timeout(PROBE_TIMEOUT, well_known(&host, port)).await.ok()?.ok() }.boxed() }); lookups } From a90bb70ee65421e44461a0ad2f3087007c10ca13 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:29:29 +0300 Subject: [PATCH 15/18] Let the test SOCKS proxy dial localhost at the IPv4 loopback web::tests::pictures_go_through_the_proxy_named_for_each_hop downloads http://localhost:/banner through a SOCKS5h proxy of its own and asserts that the proxy was given the name "localhost:". The test proxy then connected to that name through the system's resolver, and on a machine that resolves localhost to ::1 only (this one) the server, which listens on 127.0.0.1, was not reachable: the download timed out after 20 s. The proxy still reports the name it was given, as SOCKS5h says, and dials localhost at 127.0.0.1 like the server it stands in front of. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/web.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/voelin-core/src/web.rs b/crates/voelin-core/src/web.rs index e464aba..c272023 100644 --- a/crates/voelin-core/src/web.rs +++ b/crates/voelin-core/src/web.rs @@ -1430,9 +1430,15 @@ pub(crate) mod tests { }; let mut port = [0u8; 2]; client.read_exact(&mut port).await.unwrap(); - let target = format!("{host}:{}", u16::from_be_bytes(port)); + let port = u16::from_be_bytes(port); + let target = format!("{host}:{port}"); targets.send(target.clone()).unwrap(); - let mut server = TcpStream::connect(target).await.unwrap(); + // The proxy resolves the name it is given (SOCKS5h). `localhost` is + // 127.0.0.1 to it, whatever this machine's resolver says: some answer + // `::1` only, and the servers of the tests listen on 127.0.0.1. + let dial = + if host == "localhost" { format!("127.0.0.1:{port}") } else { target }; + let mut server = TcpStream::connect(dial).await.unwrap(); client.write_all(&[5, 0, 0, 1, 0, 0, 0, 0, 0, 0]).await.unwrap(); let _ = tokio::io::copy_bidirectional(&mut client, &mut server).await; }); From c35bbb5ba8c310ef8c6242a926d51fa677a08668 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 14:32:53 +0300 Subject: [PATCH 16/18] Run the portal proxy test on a bus of its own, or say it checked nothing voelin-platform's tests/proxy.rs says to run it under dbus-run-session, and without DBUS_SESSION_BUS_ADDRESS it returned at once. With one set it ran on the desktop's bus and failed at "the portal leaves the bus": the test has its stand-in release org.freedesktop.portal.Desktop, and the first call afterwards starts the real xdg-desktop-portal, which the bus can start by name; it answers instead of the "missing" the test expects for a minute. A private bus from plain dbus-run-session starts it the same way (the test failed the same three times under it here), so the documented way did not work on a desktop that has the portal installed. The test now runs itself again under dbus-run-session with a bus configuration of its own, a session bus without service directories, so that nothing on it can be started by name. Without dbus-run-session, or when the bus does not come up, it says "skipped, nothing was checked" with the reason and passes; when the test ran on its bus and failed, it fails with the output. The stand-in and the assertions are the ones that were there. On the bus with the default services the same inner test still fails as before (checked by hand), and on the bus of its own it passes. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-platform/tests/proxy.rs | 76 ++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/crates/voelin-platform/tests/proxy.rs b/crates/voelin-platform/tests/proxy.rs index 079420b..bead427 100644 --- a/crates/voelin-platform/tests/proxy.rs +++ b/crates/voelin-platform/tests/proxy.rs @@ -1,8 +1,10 @@ -//! The desktop's proxy through a stand-in xdg-desktop-portal on the -//! session bus. Run it on a private bus: -//! `dbus-run-session -- cargo test -p voelin-platform --test proxy`; -//! without a session bus it checks nothing. Its own test binary: answers -//! are kept process-wide. +//! The desktop's proxy through a stand-in xdg-desktop-portal on a session +//! bus. The test runs itself again under `dbus-run-session` on a bus of its +//! own that starts no services: on a desktop's bus the real portal is running +//! or startable, and when the stand-in leaves the bus (as the test has it do) +//! the real one is started and answers instead. Without `dbus-run-session`, +//! or a bus daemon for it, the test says so and checks nothing. Its own test +//! binary: answers are kept process-wide. #![cfg(all(unix, not(target_os = "macos"), feature = "portal"))] @@ -11,6 +13,9 @@ use std::sync::atomic::{AtomicU32, Ordering}; use voelin_platform::proxy::proxy_for; +/// Set for the run on the bus of its own. +const ON_ITS_OWN_BUS: &str = "VOELIN_PROXY_TEST_ON_ITS_OWN_BUS"; + /// What the GNOME portal answers: a SOCKS proxy for one host, none for the /// others. struct Resolver { @@ -34,10 +39,67 @@ impl Resolver { } } +/// The configuration of the bus of its own: a session bus without the service +/// directories, so that nothing on it can be started by name. Its socket is +/// made in `dir`. +fn bus_config(dir: &std::path::Path) -> String { + format!( + r#" + + session + unix:tmpdir={} + EXTERNAL + + + + + + +"#, + dir.display() + ) +} + +/// Run this test again under `dbus-run-session` on a bus of its own, and say +/// nothing was checked when that bus cannot be had. +fn on_a_bus_of_its_own() { + let dir = std::env::temp_dir(); + let config = dir.join(format!("voelin-proxy-test-bus-{}.conf", std::process::id())); + std::fs::write(&config, bus_config(&dir)).unwrap(); + let run = std::process::Command::new("dbus-run-session") + .arg(format!("--config-file={}", config.display())) + .arg("--") + .arg(std::env::current_exe().unwrap()) + .args(["--exact", "the_portal_names_the_proxy", "--nocapture", "--test-threads=1"]) + .env(ON_ITS_OWN_BUS, "1") + .output(); + let _ = std::fs::remove_file(&config); + let run = match run { + Ok(run) => run, + Err(e) => { + eprintln!("skipped, nothing was checked: dbus-run-session cannot be run ({e})"); + return; + } + }; + let text = + format!("{}{}", String::from_utf8_lossy(&run.stdout), String::from_utf8_lossy(&run.stderr)); + if run.status.success() { + return; + } + // The test ran and failed, or the bus never came up. + assert!( + !text.contains("running 1 test"), + "the test failed on its own bus ({}):\n{text}", + run.status + ); + eprintln!("skipped, nothing was checked: no bus of its own could be started:\n{text}"); +} + #[tokio::test] async fn the_portal_names_the_proxy() { - if std::env::var_os("DBUS_SESSION_BUS_ADDRESS").is_none() { - eprintln!("no session bus: run under dbus-run-session"); + if std::env::var_os(ON_ITS_OWN_BUS).is_none() { + on_a_bus_of_its_own(); return; } let lookups = Arc::new(AtomicU32::new(0)); From 6329e5678013410bc3d128b43acc755ec41caee2 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 15:06:54 +0300 Subject: [PATCH 17/18] Make peer_config_follows_codecs state what preferred_codec promises on any machine The test compared preferred_codec(&all, Some(H264)).is_some() with whether an H.264 encoder exists. preferred_codec falls back to another encodable codec when the configured one cannot be encoded, so is_some() is true on every machine with any encoder and the assertion held only where an H.264 encoder exists. The first CI run that could fetch the private dependency (Gitea run 1089, runner image without an H.264 encoder) failed on it; a developer machine with FFmpeg or a GPU passed. The test now says the contract: a configured H.264 is the result when all.encoder_codecs() has it, and otherwise the result equals the automatic choice, preferred_codec(&all, None). The built-in codecs (no OpenH264) pin both branches on every machine: VP9 configured gives VP9, H.264 configured gives the automatic choice, VP8. The H.264-in-software offer assertion assumed VP8 second after H.264 (offer_codecs(&all, H264)[..2]). A hardware AV1 or VP9 encoder ranks before libvpx's VP8, so a machine with software H.264 and one of them fails it (the dev machine does with the named av1_vaapi encoder and hardware off). It now says H.264 leads exactly the codecs the VP8-led offer has. Checked at 9714dc2 in docker.gitea.com/runner-images:ubuntu-24.04 with the apt packages of .github/actions/system-deps and rustup 1.94: the test failed at media.rs:3426 and passes now; the voelin-core lib tests there were 268 passed, 1 failed, 2 ignored before and are 269 passed, 0 failed, 2 ignored after. Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/media.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/crates/voelin-core/src/media.rs b/crates/voelin-core/src/media.rs index 6d77331..5eb0986 100644 --- a/crates/voelin-core/src/media.rs +++ b/crates/voelin-core/src/media.rs @@ -3410,7 +3410,14 @@ mod tests { assert!(all.is_hardware(backend), "{codec} offered in software"); } if all.encoder_codecs().contains(&Codec::H264) && !offer.contains(&Codec::H264) { - assert_eq!(offer_codecs(&all, Codec::H264)[..2], [Codec::H264, Codec::Vp8]); + // H.264 in software only (so not in `offer`): it leads the same + // codecs as with VP8 as the stream codec, whichever hardware + // encoders this machine has (a hardware AV1 or VP9 encoder ranks + // before VP8, so VP8 is not always second). + let h264 = offer_codecs(&all, Codec::H264); + assert_eq!(h264[0], Codec::H264, "{h264:?}"); + assert_eq!(h264.len(), offer.len() + 1, "{h264:?} against {offer:?}"); + assert!(offer.iter().all(|c| h264.contains(c)), "{h264:?} against {offer:?}"); } // Whatever this machine has: codecs every TeamSpeak client decodes // come before H.264, HEVC last, and the automatic stream codec is @@ -3423,10 +3430,23 @@ mod tests { let ranks: Vec<_> = offer[1..].iter().map(rank).collect(); assert!(ranks.is_sorted(), "{offer:?}"); assert!(preferred_codec(&all, None).is_some_and(decoded_everywhere), "{all:?}"); - assert_eq!( - preferred_codec(&all, Some(Codec::H264)).is_some(), - all.encoder_codecs().contains(&Codec::H264) - ); + // A configured codec is the stream codec when this machine can encode + // it; otherwise the result is the automatic choice, + // `preferred_codec(&all, None)` (some codec on any machine that + // encodes anything). Whether H.264 is encodable depends on the + // machine (a desktop with FFmpeg or a GPU has an encoder, a CI + // runner has none), so the expectation follows `all.encoder_codecs()`. + let h264 = preferred_codec(&all, Some(Codec::H264)); + if all.encoder_codecs().contains(&Codec::H264) { + assert_eq!(h264, Some(Codec::H264), "{all:?}"); + } else { + assert_eq!(h264, preferred_codec(&all, None), "{all:?}"); + } + // The built-in codecs are the same everywhere (no OpenH264 loaded): + // VP9 is encodable and wins, H.264 is not and falls back to VP8. + assert_eq!(preferred_codec(&codecs, Some(Codec::Vp9)), Some(Codec::Vp9)); + assert_eq!(preferred_codec(&codecs, Some(Codec::H264)), preferred_codec(&codecs, None)); + assert_eq!(preferred_codec(&codecs, None), Some(Codec::Vp8)); } /// A sink whose viewers chose `codecs`; keeps every video frame with its From f374f5797ba3a41965c6f9ccd7364ae448d062e3 Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 15:26:46 +0300 Subject: [PATCH 18/18] Record the round after the gate in the design of the session seam 17.8: the commits of the follow-up round, the five flaky tests (all fixed, how each was reproduced and what the evidence is, including the two that are rewrites and the one that was never seen again), and what ran on both toolchains: fmt and clippy per commit, the lib suite ten times in a row on each with no exclusions, the integration tests, cargo doc, the workspace check with the environment that made it build, and the smoke script before and after on fresh stacks. The status line names the round. Co-Authored-By: Claude Sonnet 5.5 --- docs/session-seam.md | 101 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/docs/session-seam.md b/docs/session-seam.md index 7f11c9c..26c7ee0 100644 --- a/docs/session-seam.md +++ b/docs/session-seam.md @@ -3,8 +3,10 @@ Status: design (2026-10-20); slices 1, 2 and 3 are implemented (section 13 says how slice 1 differs from this text, sections 14 and 15 what its reviews changed, section 16 what slice 2 built, found and corrected, section 17 what -slice 3 moved, changed and ran, and 17.7 the round after its review, which -brought the branch onto main `ad20979`); section 10 has the slices. +slice 3 moved, changed and ran, 17.7 the round after its review, which +brought the branch onto main `ad20979`, and 17.8 the round after the gate of the +merge; 17.6 has the complete edge list for the second half); section 10 has +the slices. Design for the first half of plan step 7 (Phase 4): the engine consumes `voelin_proto::link::Session`, `ServerLink` becomes an adapter over it, and @@ -1823,3 +1825,98 @@ included. The last bullet of 17.6 (documents that still name the old paths) is closed by `76a884a`; the others stand. + +### 17.8 The round after the gate (`phase4/seam-followups`) + +The Opus gate of the merge (`c60acf9`) accepted it with one minor and notes for +H9. This round, on `phase4/seam-followups` from `c60acf9`, closes the minor, +writes the notes down (17.6) and deals with the five tests that failed on +their own on `main`. No history was rewritten. The `mao-*` agents were not +registered in the session, so a general-purpose agent played +`mao-implementer`, attempt 1. + +| Commit | What | +|---|---| +| `a856f90` | The gate's minor. `ts::identity::from_json` is the classification `from_blob` had (malformed, cut short, not an identity, unreadable, with line and column, never the value), taking the JSON text; `from_blob` and `ts_session::inner_options` both use it. `inner_options` had put the `serde_json` error into the text, and `tsproto`'s key reader reports a key that does not import as `invalid_value(Unexpected::Str(key), ..)`, so the key reached `LinkEvent::Disconnected(Some(text))`, `Event::Error` and the status line. A credential that is not UTF-8 is "it is not text". Four tests, each with a key that lost its last two characters and none holding 8 characters in a row of the key: `identity::tests` (which also asserts that the reader's own message does quote it), `ts_session::tests` (`inner_options`), `link::tests` (the `Disconnected` text through `SessionLink` and the real connector) and `session_fake` (`ConnectVoice` through the engine with `Backends::default()`: the `Disconnected` state, the `Error` event and every event after it). The three connector-side ones fail with the `serde_json` text put back. | +| `563482d` | `VoiceOptions::nickname` and `server_password` have their docs; `Backends::set_account` says that no connector reads `ConnectParams.account` yet and that H4 moves the myTeamSpeak proof to it. | +| `96ff0e0` | The edge list of 17.6, and the H9 row of 11.2 pointing to it. | +| `9254e08` | `identity::tests::improve_level_keeps_the_key`. | +| `0d67dd7` | `voice_features::contacts_are_kept_in_the_database`. | +| `4be37e1` | `session::banner_tests::a_failing_banner_is_logged_once_with_its_address`, through `web::tests::info_lines`. | +| `e614a1c` | `discover::tests::without_records_the_gateway_itself_is_asked`. | +| `a90bb70` | `web::tests::pictures_go_through_the_proxy_named_for_each_hop`. | +| `c35bbb5` | `voelin-platform`'s `proxy::the_portal_names_the_proxy`. | + +**The five flakes: all fixed, none recorded as known.** Two of the fixes are +rewrites of a test helper and a test, not one-line edits. + +- `improve_level_keeps_the_key`: a fresh `Identity::create()` stops at the first + counter of level 8 or more and about one in 32 has 13 already, which + `improve_level` returns as it is. The test asks for three levels above what + its identity has. 8 failures in 300 runs of the single test before, 0 in 300 + after. +- `contacts_are_kept_in_the_database`: dropping an `Engine` does not close the + history database. The engine task ends later, the history writer is joined + there, and closing the connection checkpoints the write-ahead log under an + exclusive lock with fsyncs; the second `History::open` waits for that lock + for the 5 s busy timeout only and fails with `DatabaseBusy` when a loaded + disk makes the close slower. A connection was still open (the `-wal` file + still there) in 23 of 24 instrumented runs, and 10 of those 24 (eight at a + time on a loaded machine) failed. The test now waits for the `-wal` file to + go (SQLite deletes it when the last connection closes) before it reopens. + With every fsync of the test process delayed by 6 s (`strace -f -e + inject=fsync,fdatasync:delay_enter=6000000`) the old test fails every time at + the reopen, and the new one passes. +- `a_failing_banner_is_logged_once_with_its_address` (`lines == []`): + `web::tests::info_lines` read the log with `tracing::subscriber::with_default`. + While that scoped subscriber is the only one alive, `tracing-core` registers + a callsite that another test's thread meets first against that thread's own + default (none) and the callsite stays disabled for every thread + (`callsite::Dispatchers::rebuilder`, `has_just_one`). Several tests of + `banner_tests` reach the same callsite through `image_finished`. The helper + now installs one recording subscriber as the global default the first time + and records into a buffer per thread. A new test (`info_lines_see_a_callsite_ + another_thread_met_first`) fails with the old helper (`lines == []`, the + failure that was seen) and passes with the new one. The old helper failed 1 of + 300 runs of `banner_tests`, the new one 0 of 600. The failure of the whole + suite did not occur in the twenty full runs below, so the evidence for this + fix is the mechanism, the new test and these rates. +- The two `localhost` tests fail where `localhost` resolves to `::1` only (the + servers of the tests listen on 127.0.0.1). The discovery test's `probing` + helper and the test SOCKS proxy dial `localhost` at 127.0.0.1; what the tests + check (the name the gateway is asked at, the name the proxy is given) is + unchanged. +- `the_portal_names_the_proxy` did not need `dbus-run-session` only: with a + session bus, on the desktop's or on a private one made by plain + `dbus-run-session`, it failed here three times out of three at "the portal + leaves the bus", because the bus can start the real `xdg-desktop-portal` by + name, which the first call after the stand-in has left does, and the real + one answers instead of the "missing for a minute" the test expects. The test + now runs itself again under `dbus-run-session` with a bus configuration of + its own, a session bus without service directories. Without + `dbus-run-session`, or when the bus does not come up, it prints "skipped, + nothing was checked" and the reason and passes. On the bus with the default + services the same test still fails (checked by hand). + +**What ran.** The environment of 17.7, taken again: `nix shell` of `gcc cmake +gnumake pkg-config jq` and the `.dev` outputs of `alsa-lib openssl libvpx dav1d +pipewire fontconfig freetype libxkbcommon expat`, with `PKG_CONFIG_PATH` (the +`.dev` outputs), `LIBCLANG_PATH`, `BINDGEN_EXTRA_CLANG_ARGS` (`-isystem` the +`glibc.dev` headers: `libspa-sys` fails without) and, to run the binaries it +builds, `LD_LIBRARY_PATH` (the `.out` outputs of those: `libvpx.so.12`) set by +hand, and the 1.94 and nightly toolchains from their store paths in front of +`PATH`. The `dev rust-nightly` shell does not build here (`cargo-llvm-cov`). +With that, `cargo check --workspace --all-targets --locked` passes on 1.94, the +`voelin-ui`, `voelin-ui-vm`, `voelinctl`, `voelin-gateway` and `voelin-android` +targets included. + +| Check | Result | +|---|---| +| `cargo fmt $(scripts/own-crates.sh) --check` | 1.94: clean at the head and at each of the nine commits, checked out detached one by one. `cargo fmt --all --check` as such is not clean at `c60acf9` on any toolchain: it includes the vendored `crates/proto`, which formats with upstream's nightly configuration, and the nightly `rustfmt` also reformats own files that 1.94's leaves alone (the CI runs the form above). | +| `cargo clippy -p voelin-core -p voelin-platform --all-targets --locked --no-deps -- -D warnings` | 1.94: clean at each of the nine commits, checked out detached one by one. | +| `cargo test -p voelin-core --locked --lib`, ten times in a row, no exclusions | Nightly: ten runs, each 252 passed, 2 ignored. 1.94: the same ten times. (The baseline of 17.5 and 17.7 had two failures in each run and needed `--skip`.) | +| `cargo test -p voelin-core --locked`, once | Both toolchains: green. Integration tests: `gateway` 9, `live` 6 and `stream_live` 3 (they skip without `VOELIN_LIVE`), `session_backends` 2, `session_fake` 20 passed and 2 ignored, `settings` 1, `voice_features` 3. | +| `cargo test -p voelin-platform --locked` | Both toolchains: 24 lib tests, `crash` 3, `proxy` 1 (on its own bus), `x11` 1 (skipped without a display), 2 doc tests. | +| `RUSTDOCFLAGS=-D warnings cargo doc --no-deps -p voelin-core --locked` | 1.94 and nightly: clean. | +| `Cargo.lock`, `THIRD_PARTY_NOTICES.md` | Unchanged: `git diff c60acf9 -- Cargo.lock Cargo.toml` is empty, so there was nothing to regenerate. | +| `scripts/it-smoke.sh ts3 ts6`, on `c60acf9` (before) and at the head (after) | The stack of `VoelinGateWay/dev/docker-compose.yml` as a compose project of its own (`voelin-seam-followups`), the state directory under the scratch directory. On a fresh stack each (`down -v`, `up -d` before each): both pass every per-server scenario of ts3 and ts6 (connect and tree, server and channel chat, voice tone, invisible presence, relay, gateway, history, pins and reactions, the engine's voice features, the TeamSpeak 6 streams), the TeamSpeak session module stage (12 passed, 2 ignored; 16.38 s before, 16.73 s after) and fail in the same place, the engine stage at `ts6_banners` (`live.rs:396`, 5 passed, 1 failed), the failure 17.5 and 17.7 record. Two more runs on the first stack, which was no longer fresh (before, then after), gave the same: the outputs have 100 lines each and differ only in ids, counters, tone ratios and the number of tests filtered out of the module stage (236 before, 240 after: this round's four unit tests). The very first run, on `c60acf9` on the first stack, stopped earlier, at the first gateway request of the admin identity of ts3 (`config_set` not answered, observe stayed `Connecting`); it did not repeat on the fresh stack at `c60acf9`, nor in any later run, and was not chased. |