Signed-off-by: Faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-10-04 19:11:37 +03:00
1 parent 52cd9e1425
commit 24acc1910a
38 files changed
+9850 -217

No files matched your search

+21 -2
View File
@@ -44,6 +44,7 @@ use tsproto_packets::packets::{InCommandBuf, OutCommand, OutPacket, PacketType};
#[cfg(feature = "audio")]
pub mod audio;
mod myts;
pub mod prelude;
pub mod resolver;
pub mod sync;
@@ -382,9 +383,11 @@ impl Connection {
address: address.into(),
local_address: None,
identity: None,
myts_identity: None,
server: None,
name: "TeamSpeakUser".into(),
version: Version::Windows_3_X_X__1,
metadata: Cow::Borrowed(""),
hardware_id: "923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc".into(),
channel: None,
channel_password: None,
@@ -536,7 +539,7 @@ impl Connection {
.as_ref()
.map(|p| tsproto_types::crypto::encode_password(p.as_bytes()))
.unwrap_or_default();
let packet = c2s::OutClientInitMessage::new(&mut iter::once(c2s::OutClientInitPart {
let mut packet = c2s::OutClientInitMessage::new(&mut iter::once(c2s::OutClientInitPart {
name: Cow::Borrowed(options.name.as_ref()),
version: Cow::Borrowed(client_version),
platform: Cow::Borrowed(client_platform),
@@ -549,7 +552,7 @@ impl Connection {
default_channel: Cow::Borrowed(options.channel.as_deref().unwrap_or_default()),
default_channel_password: Cow::Borrowed(default_channel_password.as_ref()),
password: Cow::Borrowed(password.as_ref()),
metadata: "".into(),
metadata: Cow::Borrowed(options.metadata.as_ref()),
version_sign: Cow::Borrowed(client_version_sign.as_ref()),
client_key_offset: counter,
phonetic_name: "".into(),
@@ -564,6 +567,13 @@ impl Connection {
security_hash: None,
}));
// Voelin patch: account proof is bound to this transport's negotiated IV.
// The generated legacy client_myteamspeak_id field stays absent.
if let Some(identity) = &options.myts_identity {
let params = client.params.as_ref().ok_or(Error::InitserverParamsMissing)?;
identity.proof(&params.shared_iv).write_to(&mut packet);
}
client.send_packet(packet.into_packet()).map_err(Error::SendClientinit)?;
match tokio::time::timeout(
@@ -1711,9 +1721,11 @@ pub struct ConnectOptions {
address: ServerAddress,
local_address: Option<SocketAddr>,
identity: Option<Identity>,
myts_identity: Option<tsproto::myts::Identity>,
server: Option<UidBuf>,
name: Cow<'static, str>,
version: Version,
metadata: Cow<'static, str>,
hardware_id: Cow<'static, str>,
channel: Option<Cow<'static, str>>,
channel_password: Option<Cow<'static, str>>,
@@ -1853,6 +1865,13 @@ impl ConnectOptions {
self
}
/// Application metadata, independently of the signed compatibility version.
/// Voelin patch: carries the actual application name/build to the server.
pub fn metadata<S: Into<Cow<'static, str>>>(mut self, metadata: S) -> Self {
self.metadata = metadata.into();
self
}
/// The hardware ID (HWID) of the client.
///
/// # Default
+91
View File
@@ -0,0 +1,91 @@
//! Voelin patch: connection-bound myTeamSpeak proof and live account changes.
use tsproto::myts::Identity;
use tsproto_packets::packets::{Direction, Flags, OutCommand, PacketType};
use crate::{ConnectOptions, Connection, ConnectionState, Error, MessageHandle, Result};
impl ConnectOptions {
/// Snapshot the account credential for the initial connection and reconnects.
/// This is separate from the server identity and account profile UUID.
pub fn myts_identity(mut self, identity: Option<Identity>) -> Self {
self.myts_identity = identity;
self
}
}
impl Connection {
/// Publish a connection-bound account proof, or clear the account identity.
///
/// Always updates the reconnect options, even if currently disconnected or
/// sending fails. A running connection attempt owns its previous snapshot:
/// callers must cancel and rebuild that attempt after `NotConnected`.
/// Await the returned handle's `StreamItem::MessageResult` for server acceptance.
pub fn update_myts_identity(&mut self, identity: Option<Identity>) -> Result<MessageHandle> {
self.options.myts_identity = identity;
let iv = match &self.state {
ConnectionState::Connected { con, .. } => {
con.client.params.as_ref().ok_or(Error::InitserverParamsMissing)?.shared_iv
}
_ => return Err(Error::NotConnected),
};
let packet = update_packet(self.options.myts_identity.as_ref(), &iv);
self.send_command_with_result(packet)
}
}
fn update_packet(identity: Option<&Identity>, iv: &[u8; 64]) -> OutCommand {
let mut packet =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "updatemytsid");
if let Some(identity) = identity {
identity.proof(iv).write_to(&mut packet);
} else {
// Empty arguments are serialized without '=' by the existing writer.
packet.write_arg("myTeamspeakId", &"");
}
packet
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn clear_contains_no_previous_account_proof() {
let packet = update_packet(None, &[0; 64]).into_packet();
assert_eq!(packet.content(), b"updatemytsid myTeamspeakId");
}
#[test]
fn update_uses_current_connection_challenge() {
// Scalar one and the standard compressed Edwards base point.
let mut private = [0; 32];
private[0] = 1;
let mut public = [0x66; 32];
public[0] = 0x58;
let identity = Identity::new(vec![1; 33], 42, public, private, vec![2; 65]).unwrap();
let first = update_packet(Some(&identity), &[0; 64]).into_packet();
let second = update_packet(Some(&identity), &[1; 64]).into_packet();
assert_ne!(first.content(), second.content());
let wire = std::str::from_utf8(first.content()).unwrap();
assert!(wire.starts_with("updatemytsid myTeamspeakId="));
assert!(wire.contains(" acTime=42 "));
assert!(!wire.contains("client_myteamspeak_id"));
assert_eq!(wire.split(' ').count(), 7);
}
#[test]
fn failed_update_still_replaces_reconnect_snapshot() {
// Building opens no socket until the connection future is polled.
let mut private = [0; 32];
private[0] = 1;
let mut public = [0x66; 32];
public[0] = 0x58;
let identity = Identity::new(vec![1; 33], 42, public, private, vec![2; 65]).unwrap();
let mut connection =
Connection::build("localhost").myts_identity(Some(identity)).connect().unwrap();
assert!(connection.options.myts_identity.is_some());
assert!(matches!(connection.update_myts_identity(None), Err(Error::NotConnected)));
assert!(connection.options.myts_identity.is_none());
}
}