Files
VoelinClient/tools/voelinctl/src/versions.rs
T
Claude e050148a32 Rename the project to Voelin; packages hold only the app, tsgw is a Linux server package
The product is Voelin (app id io.github.faumaray.Voelin), everywhere:
- crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary
  tsc-desktop -> voelin, the development CLI tsctl -> voelinctl;
- the Android app: applicationId, Kotlin package io.github.faumaray.voelin,
  VoelinApp, libvoelin_android.so (JNI class names follow);
- TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* ->
  voelin.*, signing secrets VOELIN_SIGNING_*;
- the data/config/cache/state folder tsc -> voelin, the keyring service,
  thread names, the dev compose project;
- desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs.
The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env
vars, the tsgw.v1+json protocol, the tsgw image. The window title and the
About page show "Voelin <version>" from voelin_platform::APP_NAME.

Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs,
Flatpak). voelinctl is a development tool and in no package. tsgw is for
servers and now its own Linux package, tsgw_<v>_amd64.deb and
tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit
(packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and
dependencies of its own (no GUI libraries). docs/gateway-admin.md has an
Install section.

Fixes:
- package-windows: makensis on Windows found no file through "D:/a/..."
  paths; pass Windows paths (cygpath -w).
- StartupWMClass is the app id, which the app sets as its X11 WM_CLASS
  (it was the binary name, so desktops could not match the window).
- Gradle wrapper download timeout 10 s -> 60 s (slow proxies).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-26 21:11:17 +00:00

102 lines
2.9 KiB
Rust

//! Known signed client versions.
//!
//! `clientinit` must carry a `client_version_sign` produced by TeamSpeak's
//! private key, so a client can only claim versions from this list of captured
//! signatures (the `Versions.csv` declaration file).
use anyhow::{Context, Result, bail};
use base64::prelude::*;
use tsclientlib::Version;
const VERSIONS_CSV: &str =
include_str!("../../../crates/proto/tsproto-structs/declarations/Versions.csv");
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct KnownVersion {
pub version: String,
pub platform: String,
pub signature: String,
}
impl KnownVersion {
pub fn to_version(&self) -> Result<Version> {
let signature = BASE64_STANDARD
.decode(&self.signature)
.with_context(|| format!("invalid signature for {}@{}", self.platform, self.version))?;
Ok(Version::Custom {
platform: self.platform.clone(),
version: self.version.clone(),
signature,
})
}
}
pub fn known_versions() -> Vec<KnownVersion> {
VERSIONS_CSV
.lines()
.skip(1)
.filter(|l| !l.trim().is_empty())
.filter_map(|l| {
// The version string contains no commas, the signature is base64.
let mut parts = l.splitn(3, ',');
Some(KnownVersion {
version: parts.next()?.to_string(),
platform: parts.next()?.to_string(),
signature: parts.next()?.trim().to_string(),
})
})
.collect()
}
/// Resolve a `--client-version` argument.
///
/// Accepts `default` (the library default), an index into [`known_versions`],
/// or `<platform>@<version>` with the exact strings from `voelinctl versions`.
pub fn resolve(spec: &str) -> Result<Option<Version>> {
if spec == "default" {
return Ok(None);
}
let versions = known_versions();
if let Ok(i) = spec.parse::<usize>() {
let Some(v) = versions.get(i) else {
bail!("version index {i} out of range (0..{})", versions.len());
};
return v.to_version().map(Some);
}
let Some((platform, version)) = spec.split_once('@') else {
bail!("expected `default`, an index or `<platform>@<version>`, got {spec:?}");
};
match versions.iter().find(|v| v.platform == platform && v.version == version) {
Some(v) => v.to_version().map(Some),
None => bail!("unknown client version {spec:?}, see `voelinctl versions`"),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parses_all_rows() {
let versions = known_versions();
assert!(versions.len() > 50);
for v in &versions {
let signature = BASE64_STANDARD.decode(&v.signature).unwrap();
assert_eq!(signature.len(), 64, "{v:?}");
}
}
#[test]
fn resolves_specs() {
assert!(resolve("default").unwrap().is_none());
let by_index = resolve("0").unwrap().unwrap();
let first = &known_versions()[0];
let by_name = resolve(&format!("{}@{}", first.platform, first.version)).unwrap().unwrap();
assert_eq!(by_index, by_name);
assert_eq!(by_name.get_platform(), first.platform);
assert!(resolve("Nope@1.0").is_err());
assert!(resolve("100000").is_err());
assert!(resolve("garbage").is_err());
}
}