Expand description
§Addresses, as a person writes them
The grammar that turns what someone typed into an IpSet. This is the
address half of a target expression; the ports after it are
super::target’s business.
§What it accepts
| Written | Means |
|---|---|
127.0.0.1, 2001:db8::1 | one address |
192.0.2.0/24, 2001:db8::/64 | a CIDR block |
198.51.100.1-198.51.100.50 | a range, both ends written out |
198.51.100.1-50, 192.168.1.1-2.254 | a range whose end continues the start’s octets |
fe80::1%en0 | a link-local address on a named interface |
lan | a keyword, resolved by the caller |
The shortened range is IPv4 only: the end is read as however many trailing
octets it names, so 198.51.100.1-50 ends at 198.51.100.50 and
192.168.1.1-2.254 at 192.168.2.254. IPv6 has no comparable form, and
inventing one would make ::1-5 ambiguous with hex.
§An IPv4-mapped address is the IPv4 host it spells
::ffff:192.0.2.1 is how RFC 4291 §2.5.5.2 writes 192.0.2.1 inside an IPv6
address; a dual-stack socket handed it connects over IPv4, and no packet carries it.
So an address, block or range written wholly inside ::ffff:0:0/96 becomes the IPv4
one it spells, as Exclusions reads it too.
Kept as IPv6 it would be probed as off-link IPv6 and reported apart from the same
machine written normally.
A range reaching outside the block is kept as written: whoever writes ::/0 means
IPv6.
§Lookups are supplied by the caller
Resolving lan reads this host’s interface table, and resolving %en0 looks up a
name in it. Both arrive as caller-supplied functions (ResolverFn,
ZoneResolverFn), so this module knows nothing about the machine. An expression
needing a lookup the caller did not supply is refused, so a scan never silently
covers less than its input said.
Hostnames are resolved by super::target::TargetMapBuilder, since whether a name
may be looked up is a policy question. An expression matching none of the forms
above comes back as IpParseError::Malformed, the signal to try it as a name.
Enums§
- IpParse
Error - Errors encountered during the parsing or resolution of IP-related strings.
- Keyword
- A name standing for a set of addresses only the running host can supply.
Functions§
- insert_
expression - Identifies the format of a single address expression and inserts it into an existing set.
- names_
keyword - Whether any of these target expressions names
keyword. - to_set
- Resolves a list of address expressions into one
IpSet.
Type Aliases§
- Resolver
Fn - Expands a
Keywordinto the addresses it stands for. - Zone
Resolver Fn - Looks up an interface by name and returns its scope id.