Skip to content

Commit

Permalink
refactor(entry): run subcommands from engine; cleaned main
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Nov 25, 2023
1 parent 3480fc8 commit 8543867
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
26 changes: 26 additions & 0 deletions src/engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::{
commands::{
fuzz::fuzzer::fuzz_url, rdns::rev_dns::reverse_dns_lookup,
status::statuscode::handle_status_command, takeover::sub_takeover::subdomain_takeover,
urldencode::dencode_urls,
},
interface::args::{Cli, CommandChoice},
log::abort,
};
use clap::Parser;

pub async fn start() {
let cli = Cli::parse();

let result = match cli.command {
CommandChoice::Status(status_args) => handle_status_command(status_args).await,
CommandChoice::Fuzzer(fuzz_args) => fuzz_url(fuzz_args).await,
CommandChoice::Rdns(rdns_args) => reverse_dns_lookup(rdns_args).await,
CommandChoice::Takeover(takeover_args) => subdomain_takeover(takeover_args).await,
CommandChoice::Dencode(dencode_args) => dencode_urls(dencode_args).await,
};

if let Err(err) = result {
abort(&format!("{}", err));
}
}
32 changes: 3 additions & 29 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,10 @@
use {
crate::{
commands::{
fuzz::fuzzer::fuzz_url, rdns::rev_dns::reverse_dns_lookup,
status::statuscode::handle_status_command, takeover::sub_takeover::subdomain_takeover,
urldencode::dencode_urls,
},
interface::args::{Cli, CommandChoice},
},
anyhow::Result,
clap::Parser,
};

mod commands;
mod engine;
mod interface;
mod log;

//  asynchronous entry point where the magic happens :dizzy: 
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();

let result = match cli.command {
CommandChoice::Status(status_args) => handle_status_command(status_args).await,
CommandChoice::Fuzzer(fuzz_args) => fuzz_url(fuzz_args).await,
CommandChoice::Rdns(rdns_args) => reverse_dns_lookup(rdns_args).await,
CommandChoice::Takeover(takeover_args) => subdomain_takeover(takeover_args).await,
CommandChoice::Dencode(dencode_args) => dencode_urls(dencode_args).await,
};

if let Err(err) = result {
eprintln!("Error: {}", err);
std::process::exit(1);
}
Ok(())
async fn main() {
engine::start().await;
}

0 comments on commit 8543867

Please sign in to comment.