diff --git a/Cargo.toml b/Cargo.toml index 27c0e78..91f0bcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,12 @@ [package] -name = "knock" +name = "knockd" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { Version = "4.5.1", features = ["derive"] } pnet = "0.34.0" serde = { version = "1.0.197", features = ["derive"] } serde_yaml = "0.9.32" diff --git a/src/main.rs b/src/main.rs index 2aa739b..80bc164 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use clap::Parser; use sequence::PortSequenceDetector; use server::Server; @@ -6,9 +7,19 @@ mod executor; mod sequence; mod server; +#[derive(Parser, Debug)] +#[command(version, about, long_about = "A port knocking server written in Rust")] +struct Args { + /// Path to the configuration file + #[arg(short, long, default_value = "config.yaml")] + config: String, +} + fn main() -> Result<(), Box> { + let args = Args::parse(); + // Load the configuration - let config = config::load_config("config.yaml")?; + let config = config::load_config(&args.config)?; // Create the sequence detector let detector = PortSequenceDetector::new(config);