aha_misc/tavern/option.rs
1//! Some options
2
3use std::path::PathBuf;
4
5use clap::Args;
6
7/// Network protocol types supported by the client.
8#[derive(Debug, Clone, Copy)]
9pub enum Protocol {
10 /// TCP protocol
11 Tcp,
12 /// UDP protocol
13 Udp,
14}
15
16/// Options for configuring network client fuzzing.
17///
18/// This struct defines parameters needed for fuzzing network clients,
19/// including protocol type, host, port, and timing configurations.
20#[derive(Args, Debug)]
21pub struct NetworkClientOptions {
22 /// Network protocol (tcp/udp)
23 #[arg(long, default_value = "tcp")]
24 pub protocol: String,
25
26 /// Target host
27 #[arg(long, default_value = "127.0.0.1")]
28 pub host: String,
29
30 /// Target port
31 #[arg(long, default_value = "13337")]
32 pub port: u16,
33
34 /// Sleep time in microseconds
35 #[arg(long, default_value = "100000")]
36 pub sleep: u64,
37
38 /// Restart try time if connection fails
39 #[arg(long, default_value = "10")]
40 pub try_time: u64,
41}
42
43impl NetworkClientOptions {
44 /// Get the protocol enum from the string configuration.
45 ///
46 /// # Returns
47 /// A `Protocol` enum value corresponding to the configured protocol string.
48 ///
49 /// # Panics
50 /// Panics if an invalid protocol is specified.
51 pub fn protocol(&self) -> Protocol {
52 match self.protocol.as_str() {
53 "tcp" => Protocol::Tcp,
54 "udp" => Protocol::Udp,
55 _ => panic!("Invalid protocol specified"),
56 }
57 }
58}
59
60/// SSL configuration options.
61///
62/// This struct defines the parameters needed for SSL connections,
63/// including certificate and key file paths.
64#[derive(Args, Debug)]
65pub struct SSLOptions {
66 /// SSL cert file
67 #[arg(long = "cert-file")]
68 pub cert_file: Option<PathBuf>,
69
70 /// SSL key file
71 #[arg(long = "key-file")]
72 pub key_file: Option<PathBuf>,
73}