Refactor idevice tools into single binary

This commit is contained in:
Jackson Coxson
2026-01-03 16:58:33 -07:00
parent 2eebbff172
commit 189dd5caf2
34 changed files with 1983 additions and 2777 deletions

View File

@@ -1,71 +1,20 @@
// Jackson Coxson
use clap::{Arg, Command};
use futures_util::StreamExt;
use idevice::{IdeviceService, bt_packet_logger::BtPacketLoggerClient};
use idevice::{IdeviceService, bt_packet_logger::BtPacketLoggerClient, provider::IdeviceProvider};
use jkcli::{CollectedArguments, JkArgument, JkCommand};
use tokio::io::AsyncWrite;
use crate::pcap::{write_pcap_header, write_pcap_record};
mod common;
mod pcap;
pub fn register() -> JkCommand {
JkCommand::new()
.help("Writes Bluetooth pcap data")
.with_argument(JkArgument::new().with_help("Write PCAP to this file (use '-' for stdout)"))
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let matches = Command::new("amfi")
.about("Capture Bluetooth packets")
.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)")
.index(1),
)
.arg(
Arg::new("about")
.long("about")
.help("Show about information")
.action(clap::ArgAction::SetTrue),
)
.arg(
Arg::new("out")
.long("out")
.value_name("PCAP")
.help("Write PCAP to this file (use '-' for stdout)"),
)
.get_matches();
if matches.get_flag("about") {
println!("bt_packet_logger - capture bluetooth packets");
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 out = matches.get_one::<String>("out").map(String::to_owned);
let provider = match common::get_provider(udid, host, pairing_file, "amfi-jkcoxson").await {
Ok(p) => p,
Err(e) => {
eprintln!("{e}");
return;
}
};
pub async fn main(arguments: &CollectedArguments, provider: Box<dyn IdeviceProvider>) {
let out: Option<String> = arguments.clone().next_argument();
let logger_client = BtPacketLoggerClient::connect(&*provider)
.await