Documentation
¶
Overview ¶
Package netpolicy decides which hosts a run may contact. `sonde mcp` builds a Policy from its --allow-host patterns; the HTTP client checks both the host of every request URL and the address of every connection it opens against the same Policy, with the same normalization, so what a request names and where its bytes go cannot disagree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDenied = errors.New("not in the host allowlist")
ErrDenied reports a host outside the allowlist.
Functions ¶
func Normalize ¶
Normalize returns the canonical form of a host as written in a URL or a dial address: lowercase, without a trailing dot, IPv6 brackets or zone, and an address in its canonical text. Only plain ASCII names (letters, digits, '-' and '_' in dot-separated labels) are accepted: a resolver may read anything else differently than this package does (a '%' is cut here but not by the system resolver, a Unicode name is converted to punycode before it is dialed). A host that looks like a short or hexadecimal IPv4 form (127.1, 0x7f000001), which some resolvers read as an address, is an error too.
Types ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is a parsed allowlist. A nil *Policy allows everything.
func Parse ¶
Parse builds a Policy from patterns:
api.example.com that name, any port api.example.com:8443 that name and port *.example.com any subdomain of example.com (not example.com) 10.1.2.3, [::1]:8080 that address (port optional; IPv6 in brackets with a port) 10.0.0.0/8, fd00::/8 an address in that range * every host
Names are case-insensitive and a trailing dot is ignored. Names are never resolved: an address or range pattern matches only hosts written as addresses.