Documentation
¶
Overview ¶
Package portscan performs TCP connect scans against one or more ports on a host. It uses only stdlib net.Dial, no raw sockets, no root required, works identically on Linux, macOS, and Windows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCompact ¶
FormatCompact renders open ports as "22/ssh 443/https" for terminal display. Falls back to "N/tcp" when the port is not in the IANA registry.
func ParsePorts ¶
ParsePorts parses a port specification into a sorted, deduplicated list. Accepts comma-separated ports (22,80,443), ranges (1-1024), or a mix. The empty string and the sentinel "default" both scan all 65535 ports.
Types ¶
type Result ¶
type Result struct {
Port int
Proto string // always "tcp" for now
Open bool
LatencyMs float64
IANA iana.Entry // full IANA record; zero value when port is not in registry
}
Result is the scan outcome for a single port.
func Scan ¶
func Scan(ctx context.Context, host string, ports []int, timeout time.Duration, concurrency int, db iana.DB) []Result
Scan performs TCP connect probes on host:ports concurrently and returns results sorted by port number. db may be nil (IANA names will be empty). concurrency controls simultaneous dials per call; 0 defaults to 50.