
wgresolver
Index
Variables
ErrNoIPv4 is returned when DNS resolution returns no IPv4 addresses for the configured endpoint hostname.
ErrPeerNotFound is returned when the configured peer pubkey is absent from the WireGuard device’s peer list.
type EndpointResolver
EndpointResolver maintains a fresh peer endpoint by polling DNS and updating the kernel WireGuard configuration when the resolved IP drifts.
func New
New constructs a resolver from the given config. The default wgctrl client is opened immediately so configuration errors surface at construction time; the default DNS resolver is the Go stdlib resolver.
func (*EndpointResolver) Close
Close releases resources held by the default wgctrl client. Safe to call when a custom client was injected via WithWGClient (no-op in that case).
func (*EndpointResolver) Run
Run drives the resolve loop until ctx is cancelled. Performs an initial tick on entry so failover-driven endpoint changes are picked up promptly after the resolver starts.
type Option
Option configures the EndpointResolver. Used to inject test doubles for the wgctrl client and DNS resolver.
func WithLogger
WithLogger overrides the default scoped logger.
func WithResolver
WithResolver overrides the default DNS resolver.
func WithWGClient
WithWGClient overrides the default wgctrl client. The supplied client’s Close method is not called by the resolver.
type Resolver
Resolver narrows the DNS surface so tests can substitute fakes without hitting real DNS infrastructure.
type WGClient
WGClient narrows the wgctrl surface so tests can substitute fakes without requiring a real WireGuard interface or root privileges.
Generated by gomarkdoc