Documentation
¶
Overview ¶
Package netutil classifies network addresses, ranks the host's LAN interfaces and guards HTTP handlers so only LAN clients get through.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Guard ¶
Guard returns middleware that answers 403 to any request whose source address is neither private (see IsPrivate) nor inside one of allowed.
func GuardFunc ¶
GuardFunc is Guard with an allow-list that is looked up per request, for lists that an administrator can edit while the server runs.
func IsPrivate ¶
IsPrivate reports whether addr is a private, link-local, CGNAT or loopback address. IPv4-mapped IPv6 addresses are judged by their IPv4 form and any IPv6 zone is ignored. The zero Addr is not private.
func IsVirtualName ¶
IsVirtualName reports whether an interface name looks like a virtual, container or Apple-internal adapter that must not supply LAN addresses.
Types ¶
type Candidate ¶
Candidate is a private LAN address on a physical-looking interface.
func Candidates ¶
Candidates enumerates the host's network interfaces and returns the ranked private LAN addresses (see Rank).
func Rank ¶
Rank filters ifaces down to usable LAN addresses and orders them best first. Interfaces that are down, loopback or virtual are dropped, as are loopback, unspecified and multicast addresses and anything IsPrivate rejects. Ties break on interface index, then address; duplicate addresses keep their first (best) occurrence.
type Interface ¶
Interface is a network interface reduced to the fields ranking needs, so Rank can be tested on fake data.
func Interfaces ¶
Interfaces lists the host's network interfaces with their unicast addresses. An interface whose addresses cannot be read is reported with no addresses rather than failing the whole scan.