docs/migration.md

# Migration Guide

portr is archived. This document maps the things portr did to the
tools I now use in its place. If you are a former portr user, you
can drop portr from your workflow by picking one of these.

## TL;DR

- **You want fast sweeps:** `rustscan`
- **You want everything else:** `nmap`
- **Both together:** `rustscan ... -- -sV` pipes into nmap for
  service detection

Everything below is detail on how common portr invocations port
over.

## Basic single-host scan

portr:

    portr 1.1.1.1

nmap:

    nmap -p 1-65535 -T4 1.1.1.1

rustscan:

    rustscan -a 1.1.1.1

nmap defaults to the top 1000 ports; rustscan defaults to all
65535. portr was the latter, so `rustscan -a` is the closer match
behaviourally.

## Specified port range

portr:

    portr scanme.nmap.org -p 1-1024

nmap:

    nmap -p 1-1024 scanme.nmap.org

rustscan:

    rustscan -a scanme.nmap.org -r 1-1024

Both newer tools accept CSV (`-p 22,80,443`) as well.

## CIDR sweeps

portr:

    portr 192.168.1.0/24 -p 22,80,443 --concurrency 256

nmap:

    nmap -p 22,80,443 -T4 --min-rate 1000 192.168.1.0/24

rustscan:

    rustscan -a 192.168.1.0/24 -p 22,80,443 -b 1000

rustscan's `-b` (batch size) is the analogue of portr's
`--concurrency`. nmap has several knobs for parallelism; the
`--min-rate` approach is usually what you want.

## Output as plain text

portr had `--no-tui`. Equivalents:

- nmap: `-oG -` (grepable output to stdout) or default stdout
- rustscan: default; use `--greppable` for single-line output

Both are pipeable to `awk`, `cut`, or `jq` (nmap has `-oX -` for
XML, which some downstream tools prefer).

## Timeouts

portr `--timeout 500ms`. Equivalents:

- nmap: `--host-timeout 500ms` (per host) or `--max-rtt-timeout`
  (per probe). Both are more granular than portr's simple knob.
- rustscan: `-T 500` (milliseconds; whole number)

nmap's timing templates (`-T0` paranoid to `-T5` insane) bundle
several values together and are what most people should use
instead of hand-tuning.

## Flag-by-flag

    portr                    nmap                       rustscan
    ---------------------    -----------------------    ------------------
    -p 1-1024                -p 1-1024                  -r 1-1024
    -p 22,80,443             -p 22,80,443               -p 22,80,443
    --concurrency 256        --min-rate 1000            -b 256
    --timeout 500ms          --host-timeout 500ms       -T 500
    --no-tui                 (default)                  --greppable

## Getting service banners

portr didn't. For that, switch to nmap's `-sV`:

    rustscan -a 1.1.1.1 -- -sV

rustscan's `--` passes the remaining args to nmap. This is the
cleanest composition: rustscan does the fast discovery, nmap does
the slow fingerprint.

## Scripts / automation

If you had scripts that parsed portr's output, they look for lines
like:

    1.1.1.1 80/tcp OPEN
    1.1.1.1 443/tcp OPEN

The closest in nmap is `-oG`:

    nmap -p 80,443 -oG - 1.1.1.1

which emits:

    Host: 1.1.1.1 ()  Status: Up
    Host: 1.1.1.1 ()  Ports: 80/open/tcp//http///, 443/open/tcp//https///

It's not line-per-port, so a small awk script is needed:

    nmap -p 80,443 -oG - 1.1.1.1 \
      | awk '/Ports:/ { for (i=5;i<=NF;i++) if ($i ~ /open/) print $2, $i }'

rustscan's `--greppable` is more portr-like, emitting:

    1.1.1.1 -> [80,443]

but you still need to split that array. If your previous pipeline
was portr-specific, expect to adjust parsers.

## Stdin input

portr didn't support stdin. nmap does via `-iL -`:

    echo 1.1.1.1 | nmap -iL -

and rustscan via `-a`:

    echo 1.1.1.1 | xargs rustscan -a

Handy for composition with anything upstream producing target
lists.

## Exit codes

portr returned:
- 0 on success
- 1 on a CLI error

nmap returns 0 even for "no hosts up" scans; check stderr. rustscan
returns 0 similarly. If you relied on portr's exit code to signal
"something open," you need to count open ports in your parser
instead.

## What you can't do in nmap or rustscan

- **Live TUI with filtering.** Neither replacement has portr's
  tview-style live view. If you miss that, `watch rustscan ...`
  works for a poor-person's refresh loop; there is no tool I
  recommend that brings back the TUI aesthetic, and see
  [design-notes.md](/src/portr/docs-design-notes-md/) for why I
  think that's fine.
- **Colored "open/closed/filtered" per port.** Both replacements
  print open ports only by default; closed/filtered are silent.
  nmap's `-v -v` gives you more, but none of it color-coded in
  portr's way.

## A sample one-liner replacement

A common portr invocation I used:

    portr 10.0.0.1 -p 22,80,443,8080 --timeout 300ms

maps cleanly to:

    nmap -p 22,80,443,8080 --host-timeout 300ms 10.0.0.1

Or, if you want rustscan's speed and nmap's fingerprinting:

    rustscan -a 10.0.0.1 -p 22,80,443,8080 -T 300 -- -sV

Pick whichever matches how you think. The mental model of portr
maps more directly to rustscan; nmap is the deeper tool if you need
depth.