Documentation
¶
Overview ¶
Package discovery decides whether a host is reachable without running the full port scan. Phase 4 implements TCP ping only (probe a short list of common ports; any response — SYN/ACK or RST — means up). ICMP echo lands in Phase 6 alongside SYN scanning under the `rawsock` build tag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPingPorts = []uint16{80, 443, 22, 445, 3389}
DefaultPingPorts is the shortlist probed by Ping when cfg.Ports is empty. These are the ports most likely to give a quick response on a real host: at least one of them tends to be either open or actively refused on typical Windows, Linux, and macOS boxes.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Ports override DefaultPingPorts. A non-nil empty slice falls back
// to the default.
Ports []uint16
// Timeout per TCP connection attempt. 0 → 800ms.
Timeout time.Duration
}
Config tunes a discovery probe.
type Result ¶
type Result struct {
Up bool
RTT time.Duration
Via string // "tcp:<port>" on success, "" on timeout-only
}
Result summarises one discovery attempt.
func Ping ¶
Ping probes cfg.Ports in parallel and returns up=true on the first port that either completes a handshake or is actively refused (RST). A pure timeout means we couldn't tell — reported as down with an empty Via.
This matches nmap's -PE fallback behaviour: closed-but-responsive hosts still count as up.