cli: Add option to create a packet capture

This commit is contained in:
Douile 2023-11-22 02:23:32 +00:00
parent abbcae618f
commit 8d17ca4e48
No known key found for this signature in database
GPG key ID: 1EC3120F9A1028F2
2 changed files with 11 additions and 1 deletions

View file

@ -38,6 +38,10 @@ struct Cli {
#[arg(short, long, default_value = "generic")]
output_mode: OutputMode,
#[cfg(feature = "packet_capture")]
#[arg(short, long)]
capture: Option<String>,
/// Optional timeout settings for the server query.
#[command(flatten, next_help_heading = "Timeouts")]
timeout_settings: Option<TimeoutSettings>,
@ -177,6 +181,11 @@ fn main() -> Result<()> {
// Resolve the IP address
let ip = resolve_ip_or_domain(&args.ip, &mut extra_options)?;
#[cfg(feature = "packet_capture")]
unsafe {
gamedig::capture::simple_setup_capture(args.capture.clone());
}
// Query the server using game definition, parsed IP, and user command line
// flags.
let result = query_with_timeout_and_extra_settings(game, &ip, args.port, args.timeout_settings, extra_options)?;