Documentation
¶
Overview ¶
Package target parses target specifications (IPs, ranges, CIDR, hostnames, @file references) into a lazy iterator of addresses.
Supported input forms (see §4.1 of scry-plan.md):
192.168.1.10 single IPv4 ::1 single IPv6 192.168.1.10-50 last-octet IPv4 range 192.168.1.10-192.168.2.20 arbitrary IPv4 range 2001:db8::1-2001:db8::ff arbitrary IPv6 range 192.168.1.0/24 IPv4 CIDR 2001:db8::/120 IPv6 CIDR example.com hostname (resolved via Options.Resolver) @targets.txt file, one target per line, # comments allowed
Any input may itself be a comma-separated list. Whitespace around tokens is stripped.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileReader ¶
FileReader reads the contents of a file referenced via @path.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator yields target addresses lazily. It is not safe for concurrent use.
func Parse ¶
Parse parses one or more target specs and returns an iterator. Each spec may itself be a comma-separated list.
func (*Iterator) Total ¶
Total returns the total number of addresses this iterator will produce, if known statically, and a second value indicating whether the count is known. The count is not known when any source is a hostname that has not yet been resolved. Excludes are not subtracted from the count.
type Options ¶
type Options struct {
// Excludes are target specs (single, range, CIDR) whose addresses will be
// skipped by the iterator.
Excludes []string
// Resolver is called for hostname targets. If nil, net.DefaultResolver is
// used. Set to a function returning an error to forbid DNS.
Resolver Resolver
// FileReader is called for @file targets. If nil, os.ReadFile is used.
FileReader FileReader
// Context is passed to the Resolver. If nil, context.Background() is used.
Context context.Context
}
Options tunes parser behavior. All fields are optional; zero values are sane.