account: show servers the account's avatar

As the official TeamSpeak 6 client does once connected and after a
sign-in, Voelin sends updatemytsdata with the account's certificate and
its avatar (LoginSession.mytsid_user_cert.cert and user_avatar, raw bytes
with TeamSpeak's escaping only; \a and \b now escaped too). The avatar
is sliced out of the login response as it came: its signature covers it.

Both come from a password sign-in; they are kept per account next to the
avatar picture (public data, outside the keyring) and published to every
voice connection that presents the account (Command::SetMytsData, beside
the identity). A refusal is only logged. Accounts signed in before need
one password sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VZBWxxMsxUzp4PSTKVzbZN
This commit is contained in:
Claude committed 2026-10-05 22:00:34 +00:00
1 parent c2e345c67f
commit 259a23a165
8 files changed
+308 -6

No files matched your search

+1
View File
@@ -61,6 +61,7 @@ pub use ts_bookkeeping::messages::s2c::InMessage;
pub use ts_bookkeeping::*;
pub use tsproto::resend::{ConnectionStats, PacketStat};
pub use tsproto::Identity;
pub use myts::MytsData;
pub use tsproto_types::errors::Error as TsError;
/// Wait this time for initserver, in seconds.
+59
View File
@@ -14,7 +14,38 @@ impl ConnectOptions {
}
}
/// What a voice server is shown of the myTeamSpeak account (TeamSpeak 6),
/// as myTeamSpeak signed it: the account's certificate and its avatar
/// (`LoginSession.user_avatar` as it came). The server shows the avatar to
/// everyone (`client_myteamspeak_avatar`).
#[derive(Clone, Default, PartialEq, Eq)]
pub struct MytsData {
pub certificate: Vec<u8>,
/// Empty: none.
pub avatar: Vec<u8>,
}
impl std::fmt::Debug for MytsData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MytsData")
.field("certificate", &self.certificate.len())
.field("avatar", &self.avatar.len())
.finish()
}
}
impl Connection {
/// Show the server the account's certificate and avatar
/// (`updatemytsdata`), as the official client does once connected and
/// after a sign-in, after the account proof (`updatemytsid`).
/// Await the returned handle's `StreamItem::MessageResult` for the answer.
pub fn send_myts_data(&mut self, data: &MytsData) -> Result<MessageHandle> {
if !matches!(self.state, ConnectionState::Connected { .. }) {
return Err(Error::NotConnected);
}
self.send_command_with_result(data_packet(data))
}
/// Publish a connection-bound account proof, or clear the account identity.
///
/// Always updates the reconnect options, even if currently disconnected or
@@ -34,6 +65,18 @@ impl Connection {
}
}
/// The values are the raw bytes with TeamSpeak's escaping only (no
/// base64), as the official client sends them; an empty avatar is left out.
fn data_packet(data: &MytsData) -> OutCommand {
let mut packet =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "updatemytsdata");
packet.write_bin_arg("myts_certificate", &data.certificate);
if !data.avatar.is_empty() {
packet.write_bin_arg("myts_avatar", &data.avatar);
}
packet
}
fn update_packet(identity: Option<&Identity>, iv: &[u8; 64]) -> OutCommand {
let mut packet =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "updatemytsid");
@@ -50,6 +93,22 @@ fn update_packet(identity: Option<&Identity>, iv: &[u8; 64]) -> OutCommand {
mod tests {
use super::*;
#[test]
fn account_data_goes_raw_and_escaped() {
let data = MytsData {
certificate: b"a b/c|d\\\x07\x08\x00\xff".to_vec(),
avatar: vec![0x0a, 0x02, b'h', b'i'],
};
let packet = data_packet(&data).into_packet();
assert_eq!(
packet.content(),
b"updatemytsdata myts_certificate=a\\sb\\/c\\pd\\\\\\a\\b\x00\xff myts_avatar=\\n\x02hi"
);
// Without an avatar: the certificate alone.
let packet = data_packet(&MytsData { avatar: Vec::new(), ..data }).into_packet();
assert!(!packet.content().windows(11).any(|w| w == b"myts_avatar"));
}
#[test]
fn clear_contains_no_previous_account_proof() {
let packet = update_packet(None, &[0; 64]).into_packet();