Skip to content

Commit

Permalink
fix: start reporting stats when session is fully initialized (fixes #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Nov 7, 2023
1 parent 0437d62 commit b420615
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 0 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time;

use clap::Parser;
use creds::Credentials;
use tokio::task;

#[cfg(not(windows))]
use rlimit::{setrlimit, Resource};
Expand Down Expand Up @@ -73,11 +72,6 @@ async fn main() -> Result<(), session::Error> {
e
})?;

if !session.options.quiet {
// start statistics reporting
task::spawn(report::statistics(session.clone()));
}

let start = time::Instant::now();

// start plugin
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use std::sync::Arc;
use tokio::task;

use crate::session::{Error, Session};
use crate::Options;
use crate::Plugin;
use crate::{report, Options};

type Inventory = BTreeMap<&'static str, Box<dyn Plugin>>;

Expand Down Expand Up @@ -69,14 +69,20 @@ pub(crate) async fn run(
) -> Result<(), Error> {
let single = plugin.single_credential();
let override_payload = plugin.override_payload();
let combinations = session.combinations(override_payload, single)?;

// spawn worker threads
for _ in 0..session.options.concurrency {
task::spawn(worker(plugin, session.clone()));
}

if !session.options.quiet {
// start statistics reporting
task::spawn(report::statistics(session.clone()));
}

// loop credentials for this session
for creds in session.combinations(override_payload, single)? {
for creds in combinations {
// exit on ctrl-c if we have to, otherwise send the new credentials to the workers
if session.is_stop() {
log::debug!("exiting loop");
Expand Down

0 comments on commit b420615

Please sign in to comment.