Documentation
¶
Overview ¶
Package lanaddr finds the address a LAN relay advertises (R74 PP2, docs/76 §6.1 item 4): the IPv4 address of the interface that holds the default route, with loopback, link-local, container and virtual bridges, VPN tunnels and every non-private address (CGNAT and public ones included) excluded. The host can pick another candidate in the console; a DHCP change is picked up by the Watcher.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
Candidate is one advertisable address.
func Filter ¶
Filter is the pure half of Detect: the candidates among ifs, primary first. Only private addresses are kept (RFC 1918, and unique-local IPv6), because the pinned join link is accepted only for private literals (docs/76 §6.1 item 5). The primary is the first IPv4 address on defaultRouteIface; without one (no default route, as at a LAN party with no internet, or a route over a VPN), the first IPv4 candidate in interface-name order.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher tracks the advertised address: the host's override when set, otherwise the primary candidate, re-detected every period.
func NewWatcher ¶
NewWatcher returns a watcher; override is -lan-address ("auto", "" or an IP literal). It detects nothing until Refresh or Run.
func (*Watcher) Candidates ¶
Candidates is the last detection, primary first.
func (*Watcher) Refresh ¶
func (w *Watcher) Refresh()
Refresh re-detects now. A detection error keeps the previous candidates.
func (*Watcher) Run ¶
Run refreshes immediately and then every period until ctx ends. It returns nil on cancellation, so it can ride serve.Options.Extra.
func (*Watcher) SetOverride ¶
SetOverride pins the advertised address (the console's pick); the zero Addr goes back to detection.