Skip to content

Commit 4c983b1

Browse files
committed
fix(scanner): fix Division-by-Zero
1 parent c62d29b commit 4c983b1

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/scanning/crawler.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ pub async fn crawl(gen_config: IpGenerator) {
130130
} else {
131131
0.0
132132
};
133-
let percent = format!("{:.2}", (processed_count as f64 / total_found_count as f64) * 100.0);
133+
134+
let percent = if total_found_count > 0 {
135+
format!("{:.2}", (total_found_count as f64 / processed_count as f64) * 100.0)
136+
} else {
137+
"0.00".to_string()
138+
};
134139

135140
logger::info(
136141
format!(
137-
"Crawl iteration finished in {}. Found {} servers from {} targets. ({}% {}{})",
142+
"Crawl iteration finished in {}. Found {} servers from {} targets, {}%. ({}{})",
138143
format_time(elapsed_time.as_secs()).hex(DefaultColor::Highlight.hex()),
139144
total_found_count.hex(DefaultColor::Highlight.hex()),
140145
total_targets.hex(DefaultColor::Highlight.hex()),

0 commit comments

Comments
 (0)