feat(tools): add protocol probe and audio test binaries (TODO-044,047)

Protocol probe: connects to server, reports capabilities, channels,
clients. Audio test: DSP pipeline benchmark with configurable params.
This commit is contained in:
Edison Jwa
2026-06-11 21:58:26 +09:00
parent 11a2541042
commit 6c00fae1cf
7 changed files with 4256 additions and 0 deletions
+2
View File
@@ -40,6 +40,8 @@ members = [
exclude = [
"apps/chanora_flutter",
"tools/protocol-probe",
"tools/audio-test",
]
[workspace.package]
+321
View File
@@ -0,0 +1,321 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "anstream"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
[[package]]
name = "anstyle-parse"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
dependencies = [
"anstyle",
"once_cell_polyfill",
"windows-sys",
]
[[package]]
name = "anyhow"
version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
[[package]]
name = "audio-test"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "clap"
version = "4.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
[[package]]
name = "colorchoice"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "log"
version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"
[[package]]
name = "nu-ansi-term"
version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys",
]
[[package]]
name = "once_cell"
version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "once_cell_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "pin-project-lite"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "smallvec"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thread_local"
version = "1.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
dependencies = [
"cfg-if",
]
[[package]]
name = "tracing"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
name = "unicode-ident"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "valuable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
+15
View File
@@ -0,0 +1,15 @@
[package]
name = "audio-test"
version = "0.1.0"
edition = "2021"
publish = false
[[bin]]
name = "audio-test"
path = "src/main.rs"
[dependencies]
clap = { version = "4", features = ["derive"] }
anyhow = "1"
tracing = "0.1"
tracing-subscriber = "0.3"
+59
View File
@@ -0,0 +1,59 @@
use anyhow::Result;
use clap::Parser;
use std::time::Instant;
#[derive(Parser)]
#[command(name = "audio-test", about = "Audio DSP pipeline benchmark")]
struct Args {
/// Sample rate
#[arg(long, default_value = "48000")]
sample_rate: u32,
/// Block size in samples
#[arg(long, default_value = "480")]
block_size: usize,
/// Number of iterations
#[arg(long, default_value = "10000")]
iterations: u32,
/// Test frequency Hz
#[arg(long, default_value = "1000")]
frequency: f32,
}
fn generate_block(sample_rate: u32, frequency: f32, size: usize) -> Vec<f32> {
(0..size)
.map(|i| {
let t = i as f32 / sample_rate as f32;
(2.0 * std::f32::consts::PI * frequency * t).sin() * 0.5
})
.collect()
}
fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let args = Args::parse();
println!("Audio Test Tool");
println!("Sample rate: {}Hz, Block: {} samples, Iterations: {}",
args.sample_rate, args.block_size, args.iterations);
let block = generate_block(args.sample_rate, args.frequency, args.block_size);
// Benchmark: copy + process simulation
let start = Instant::now();
for _ in 0..args.iterations {
let mut output = block.clone();
for sample in output.iter_mut() {
*sample *= 0.95; // simple gain
}
std::hint::black_box(&output);
}
let elapsed = start.elapsed();
println!("Total: {:?}", elapsed);
println!("Per block: {:?}", elapsed / args.iterations);
println!("Blocks/sec: {:.0}", args.iterations as f64 / elapsed.as_secs_f64());
println!("Realtime factor: {:.1}x",
(args.iterations as f64 * args.block_size as f64 / args.sample_rate as f64) / elapsed.as_secs_f64());
Ok(())
}
+3735
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
[package]
name = "protocol-probe"
version = "0.1.0"
edition = "2021"
publish = false
[[bin]]
name = "protocol-probe"
path = "src/main.rs"
[dependencies]
chanora_protocol = { path = "../../crates/chanora_protocol" }
chanora_resolver = { path = "../../crates/chanora_resolver" }
tokio = { version = "1", features = ["full"] }
clap = { version = "4", features = ["derive"] }
anyhow = "1"
tracing = "0.1"
tracing-subscriber = "0.3"
serde_json = "1"
+105
View File
@@ -0,0 +1,105 @@
use anyhow::Result;
use clap::Parser;
use chanora_protocol::{ConnectConfig, ProtocolClient};
use chanora_resolver::ChanoraResolver;
#[derive(Parser)]
#[command(name = "protocol-probe", about = "Probe a TeamSpeak server for capabilities and compatibility")]
struct Args {
/// Server address (hostname:port or ts3server:// URL)
server: String,
/// Nickname to use
#[arg(short, long, default_value = "Probe")]
nickname: String,
/// Server password (optional)
#[arg(short, long)]
password: Option<String>,
/// Verbose output
#[arg(short, long)]
verbose: bool,
}
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
let args = Args::parse();
println!("Protocol Probe Tool");
println!("===================");
println!("Server: {}", args.server);
println!();
// Step 1: Resolve address
println!("1. Resolving address...");
let resolver = ChanoraResolver::new()?;
match resolver.resolve_client_address(&args.server).await {
Ok(address) => {
println!(" Resolved: {}", address);
}
Err(e) => {
println!(" Resolution failed: {}", e);
return Ok(());
}
}
// Step 2: Connect
println!("2. Connecting...");
let cfg = ConnectConfig {
address: args.server.clone(),
nickname: args.nickname.clone(),
password: args.password.clone(),
..ConnectConfig::default()
};
let client = match ProtocolClient::connect(cfg).await {
Ok(c) => {
println!(" Connected successfully");
c
}
Err(e) => {
println!(" Connection failed: {}", e);
return Ok(());
}
};
// Step 3: Collect server info
println!("3. Server Info:");
match client.snapshot().await {
Ok(snap) => {
println!(" Name: {}", snap.server_name);
println!(" Platform: {}", snap.platform);
println!(" Version: {}", snap.version);
println!(" Channels: {}", snap.channels.len());
println!(" Clients: {}", snap.clients.len());
println!(" Welcome: {}", snap.welcome_message);
}
Err(e) => {
println!(" Snapshot failed: {}", e);
}
}
// Step 4: Client info
println!("4. Client Info:");
match client.client_profile(0).await {
Ok(profile) => {
println!(" ID: {:?}", profile.database_id);
println!(" Name: {}", profile.name);
println!(" UID: {}", profile.unique_id);
println!(" Server groups: {:?}", profile.server_groups);
println!(" Channel: {:?}", profile.channel);
}
Err(e) => {
println!(" Profile failed: {}", e);
}
}
// Step 5: Disconnect
println!("5. Disconnecting...");
client.disconnect().await;
println!(" Done");
Ok(())
}