mirror of
https://github.com/vanhauser-thc/thc-hydra.git
synced 2025-08-20 21:33:51 -07:00
Extract maxfail in to a variable
Reduce code duplication, make code easier to read
This commit is contained in:
parent
cdfce6b977
commit
39cf5133a6
1 changed files with 10 additions and 14 deletions
24
hydra.c
24
hydra.c
|
@ -1562,26 +1562,22 @@ void hydra_kill_head(int head_no, int killit, int fail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void hydra_increase_fail_count(int target_no, int head_no) {
|
void hydra_increase_fail_count(int target_no, int head_no) {
|
||||||
int i, k;
|
int i, k, ok, success, tasks, a, b, maxfail;
|
||||||
|
|
||||||
if (target_no < 0)
|
if (target_no < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ok = hydra_targets[target_no]->ok;
|
||||||
|
tasks = hydra_options.tasks;
|
||||||
|
success = tasks - hydra_targets[target_no]->failed;
|
||||||
|
a = tasks <= 4 && ok ? 6 - tasks : 1;
|
||||||
|
b = success < 5 && ok ? 6 - success : 1;
|
||||||
|
maxfail = MAXFAIL + a + b + (ok ? 2 : -2);
|
||||||
|
|
||||||
hydra_targets[target_no]->fail_count++;
|
hydra_targets[target_no]->fail_count++;
|
||||||
if (debug)
|
if (debug)
|
||||||
printf("[DEBUG] hydra_increase_fail_count: %d >= %d => disable\n", hydra_targets[target_no]->fail_count,
|
printf("[DEBUG] hydra_increase_fail_count: %d >= %d => disable\n", hydra_targets[target_no]->fail_count, maxfail);
|
||||||
MAXFAIL + (hydra_options.tasks <= 4 && hydra_targets[target_no]->ok ? 6 - hydra_options.tasks : 1) + (hydra_options.tasks - hydra_targets[target_no]->failed < 5
|
if (hydra_targets[target_no]->fail_count >= maxfail) {
|
||||||
&& hydra_targets[target_no]->ok ? 6 - (hydra_options.tasks -
|
|
||||||
hydra_targets
|
|
||||||
[target_no]->failed) : 1)
|
|
||||||
+ (hydra_targets[target_no]->ok ? 2 : -2));
|
|
||||||
if (hydra_targets[target_no]->fail_count >=
|
|
||||||
MAXFAIL + (hydra_options.tasks <= 4 && hydra_targets[target_no]->ok ? 6 - hydra_options.tasks : 1) + (hydra_options.tasks - hydra_targets[target_no]->failed < 5
|
|
||||||
&& hydra_targets[target_no]->ok ? 6 - (hydra_options.tasks -
|
|
||||||
hydra_targets
|
|
||||||
[target_no]->failed) : 1) +
|
|
||||||
(hydra_targets[target_no]->ok ? 2 : -2)
|
|
||||||
) {
|
|
||||||
k = 0;
|
k = 0;
|
||||||
for (i = 0; i < hydra_options.max_use; i++)
|
for (i = 0; i < hydra_options.max_use; i++)
|
||||||
if (hydra_heads[i]->active >= 0 && hydra_heads[i]->target_no == target_no)
|
if (hydra_heads[i]->active >= 0 && hydra_heads[i]->target_no == target_no)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue