Skip to content

Commit

Permalink
add default arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyYe committed Mar 2, 2024
1 parent 54a9a13 commit 86851e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::Parser;
use sequence::PortSequenceDetector;
use server::Server;

Expand All @@ -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<dyn std::error::Error>> {
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);

Expand Down

0 comments on commit 86851e6

Please sign in to comment.