src/main.rs hinzugefügt
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
mod test;
|
||||
|
||||
use test::sendtestudp;
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(about="A tiny and slow DHCP Server in Rust")]
|
||||
#[command(name = "catDHCP")]
|
||||
#[command(version = "0.1")]
|
||||
struct Args {
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
enum Command {
|
||||
Test {
|
||||
#[command(subcommand)]
|
||||
action: TestCommands,
|
||||
}
|
||||
}
|
||||
#[derive(Subcommand)]
|
||||
enum TestCommands {
|
||||
//send test udp paket
|
||||
SendUDP {
|
||||
#[arg(long, default_value = "172.0.0.1")]
|
||||
to: String,
|
||||
|
||||
#[arg(long, default_value_t = 14)]
|
||||
port: u16,
|
||||
|
||||
///payload in hex like "44 69 65 20 41 6E 74 77 6F 72 74 20 61 75 66 20 61 6C 6C 65 73 20 69 73 74 20 34 32 21"
|
||||
#[arg(long, value_name = "HEX")]
|
||||
payload: Option<String>
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
match args.command {
|
||||
Command::Test {action} => match action {
|
||||
TestCommands::SendUDP {to,port,payload} => {
|
||||
println!("send udp packet to {}:{} with:", to, port);
|
||||
if let Some(payload) = payload {
|
||||
println!("payload: {}", payload);
|
||||
sendtestudp(to,port,payload)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user