Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Oct 30, 2023
1 parent 991634a commit 63e770d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/creds/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) struct Combinator {
pass_it: Box<dyn creds::Generator>,
pass_expr: creds::Expression,
dispatched: usize,
total: usize,
search_space_size: usize,
single: bool,
}

Expand Down Expand Up @@ -49,17 +49,20 @@ impl Combinator {
)
};

let total = user_it.search_space_size() * std::cmp::max(pass_it.search_space_size(), 1);
let search_space_size =
user_it.search_space_size() * std::cmp::max(pass_it.search_space_size(), 1);
let dispatched = 0;
let current_user = None;
let mut combinator = Self {
user_expr,
user_it,
pass_it,
pass_expr,
options,
total,
search_space_size,
single,
dispatched: 0,
current_user: None,
dispatched,
current_user,
};

// restore from last state if needed
Expand All @@ -75,7 +78,7 @@ impl Combinator {
}

pub fn search_space_size(&self) -> usize {
self.total
self.search_space_size
}

pub fn username_expression(&self) -> &creds::Expression {
Expand Down Expand Up @@ -106,7 +109,7 @@ impl Iterator for Combinator {

fn next(&mut self) -> Option<Self::Item> {
// we're done
if self.dispatched == self.total {
if self.dispatched == self.search_space_size {
return None;
}

Expand Down

0 comments on commit 63e770d

Please sign in to comment.