Implement os_trace_relay

This commit is contained in:
Jackson Coxson
2025-05-16 17:19:45 -06:00
parent b8e0989549
commit 6c03e8f60d
6 changed files with 476 additions and 1 deletions

View File

@@ -77,6 +77,10 @@ path = "src/pair.rs"
name = "syslog_relay"
path = "src/syslog_relay.rs"
[[bin]]
name = "os_trace_relay"
path = "src/os_trace_relay.rs"
[dependencies]
idevice = { path = "../idevice", features = ["full"] }
tokio = { version = "1.43", features = ["io-util", "macros", "time", "full"] }

View File

@@ -0,0 +1,68 @@
// Jackson Coxson
use clap::{Arg, Command};
use idevice::{os_trace_relay::OsTraceRelayClient, IdeviceService};
mod common;
#[tokio::main]
async fn main() {
env_logger::init();
let matches = Command::new("os_trace_relay")
.about("Relay system logs")
.arg(
Arg::new("host")
.long("host")
.value_name("HOST")
.help("IP address of the device"),
)
.arg(
Arg::new("pairing_file")
.long("pairing-file")
.value_name("PATH")
.help("Path to the pairing file"),
)
.arg(
Arg::new("udid")
.value_name("UDID")
.help("UDID of the device (overrides host/pairing file)"),
)
.arg(
Arg::new("about")
.long("about")
.help("Show about information")
.action(clap::ArgAction::SetTrue),
)
.get_matches();
if matches.get_flag("about") {
println!("Relay logs on the device");
println!("Copyright (c) 2025 Jackson Coxson");
return;
}
let udid = matches.get_one::<String>("udid");
let host = matches.get_one::<String>("host");
let pairing_file = matches.get_one::<String>("pairing_file");
let provider = match common::get_provider(udid, host, pairing_file, "misagent-jkcoxson").await {
Ok(p) => p,
Err(e) => {
eprintln!("{e}");
return;
}
};
let log_client = OsTraceRelayClient::connect(&*provider)
.await
.expect("Unable to connect to misagent");
let mut relay = log_client.start_trace(None).await.expect("Start failed");
loop {
println!(
"{:#?}",
relay.next().await.expect("Failed to read next log")
);
}
}