Skip to content

Accept combined ports and ranges in --ports - #1

Merged
WouterHadrian merged 6 commits into
masterfrom
feat/combine-ports-and-range-input
Sep 17, 2026
Merged

WouterHadrian merged 6 commits into
masterfrom
feat/combine-ports-and-range-input

Conversation

@WouterHadrian

Copy link
Copy Markdown

Why

port-scanner builds RustScan from mikhail5555/RustScan, branch combine-ports-and-range-input — a personal repo, an unprotected branch, cloned at build time with --depth 1 -b <branch> and no commit pin. Whatever that branch points at when the image builds goes into production scanning. That branch is also 125 commits behind upstream.

This brings the feature into our own fork, on top of current upstream, so we can pin it and land fixes on it. It is the prerequisite for #2 reaching production.

What we depend on

port-scanner/pkg/utils/ports.go ToPortRangesString collapses a port list into a compact string mixing individual ports and ranges:

22,80,443,1000-2000,

Upstream cannot parse that. --ports is Option<Vec<u16>> with value_delimiter = ',', and --range is a separate, mutually exclusive single start-end. These six commits replace both with one --ports that accepts either form, keeping range as an alias.

Contents

Mikhail Epifanov's six commits from combine-ports-and-range-input (Jun 2025), cherry-picked onto master at 2e78c22 with original authorship preserved:

ea556ab  allow both individual ports and ranges of ports to be passed as opt
acb2e4c  fix broken tests
1500a36  fix lazy runtime error
27b9af6  remove lazy
c4d9382  use custom type to make value_parser work
b2612f3  remove unnecessary into

Conflict resolved — please check this one

src/input.rs only. Upstream added range: Option<PortRange> to the config-file Config struct after these commits were written. The incoming commits delete the separate --range option, so PortRange no longer exists and upstream's line cannot compile. I took the incoming side and dropped the field.

Behaviour change: a RustScan config file setting range = ... is no longer accepted. The --range flag still works as an alias. port-scanner passes everything as flags and ships no config file, so this does not affect us — but it is a real difference from upstream and worth a second pair of eyes.

Verification

Built and tested against rust:1.93:

  • cargo build --release — clean
  • cargo test — 80 passed, 0 failed, 8 ignored
  • ./rustscan --ports 22,80,443,1000-2000 --addresses 127.0.0.1 --batch-size 10 --greppable --scan-order random --timeout 200 — parses; this is the exact shape port-scanner emits

Follow-ups, not in this PR

  • Repoint modules/port-scanner/Dockerfile at this fork and pin a commit SHA rather than a branch
  • Upstream this feature — it is generally useful and would let us drop the delta

🤖 Generated with Claude Code

@WouterHadrian
WouterHadrian merged commit f8373a4 into master Sep 17, 2026
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.

2 participants