Skip to content

Refactor port scanning and improve batch size handling#905

Open
0xreacher wants to merge 1 commit intobee-san:masterfrom
0xreacher:patch-1
Open

Refactor port scanning and improve batch size handling#905
0xreacher wants to merge 1 commit intobee-san:masterfrom
0xreacher:patch-1

Conversation

@0xreacher
Copy link
Copy Markdown

Fix #1 - Wrong batch size in warning message (opts.batch_size → batch_size): The warning was showing the raw CLI value, not the actual adjusted value that ran. Users would try lowering a number that wasn't what the scanner used.

Fix #2 - or_insert_with(Vec::new) -> or_default(): Idiomatic Rust, clippy::pedantic flags the old form. Functionally identical but cleaner.

Fix #3 - scripts_to_run.clone() moved out of loop: Was cloning the entire Vec once per IP. Now iterates by reference (for script_f in &scripts_to_run) and only clones the individual ScriptFile when mutation is actually needed. Zero behavior change, much better perf at scale.

Fix #4 - Removed redundant debug!("Call format {call_f}"): The output! macro right above it already logs the full call format string. Duplicate log at a different level adds noise.

Fix #5 - usize::MAX fallback → DEFAULT_FILE_DESCRIPTORS_LIMIT: The most dangerous one. If try_into() ever failed, the returned usize::MAX would make infer_batch_size think the system has infinite file descriptors and skip all safety adjustments potentially crashing with a massive batch size. Now falls back to the same conservative 8000 limit the rest of the code uses.

Refactor port scanning logic to improve performance and fix bugs related to batch size and ulimit handling. Update warnings and logging for better clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeout for sockets Http link for port 80 Idea: Popular ports first Make the readme nice Recreate ASCII art to RustScan

1 participant