The scanner uses Boost.Asio coroutines to run many in-flight connection attempts while limiting
parallelism with a simple queue and an inflight counter.
run_scansqueues(address, port)pairs and spawns coroutines untilmax_inflightis reached.- Each coroutine performs one scan (
TCP connect,TCP banner, orUDP) and calls the result callback. - When a coroutine finishes, it decrements
inflightand launches more work. - A
steady_timeracts as a latch to wait until all work completes.
ping_loopperforms a full scan cycle, tracks state changes, then sleeps for the configured interval before repeating.- Only changes are reported after the first pass.
icmp_scan_hostsresolves/expands targets, then runs ICMP pings sequentially per address.icmp_ping_looprepeats the ICMP scan cycle on an interval and reports changes.
- Fairness: Ports for a host are processed in queue order; no priority between hosts.
- Backpressure:
max_inflightcaps concurrent scans but does not adapt to network conditions. - Single io_context: All work is scheduled onto one executor.
-
Per-host rate limits
- Limit concurrent scans per host to avoid hot-spotting a single target.
-
Adaptive concurrency
- Scale
max_inflightbased on recent timeouts/errors to avoid overwhelming slow networks.
- Scale
-
Address rotation
- Round-robin across resolved addresses instead of scanning all ports per address in one batch.
-
Work stealing queues
- Use multiple queues (per host or per protocol) to reduce head-of-line blocking.
-
Batch DNS resolution
- Cache resolved addresses across ping cycles to reduce resolver load when
--pingis used.
- Cache resolved addresses across ping cycles to reduce resolver load when
-
Timeout tuning
- Separate connect timeout from read timeout for banner mode to reduce false negatives.
-
Parallel ping loops
- Run ICMP and TCP/UDP scan cycles concurrently for mixed modes.
-
Multi-threaded io_context
- Run multiple threads with shared
io_contextfor CPU-bound parsing or logging overhead.
- Run multiple threads with shared
-
Structured metrics
- Track per-host latency and error rates; feed into adaptive scheduling.
-
Cancellation / stop signals
- Add signal handling to stop in-flight scans gracefully.