Documentation
¶
Index ¶
- func Check(tld string) (bool, error)
- func ConfigureResolver() error
- func InstallSudoers() error
- func ReadContainerDNS() []string
- func ReadUpstreamDNS() []string
- func ResolverHint() string
- func Setup() errordeprecated
- func Teardown()
- func WaitReady(timeout time.Duration) error
- func WriteDnsmasqConfig(dir string) error
- func WriteDnsmasqConfigDual(dir, v4Target, v6Target string) error
- func WriteDnsmasqConfigFor(dir, target string) error
- type Diagnostic
- type Step
- type StepStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check resolves test-lerd-probe.{tld} and reports whether the answer is one the lerd dnsmasq could legitimately return. With lan:expose off, the expected answer is 127.0.0.1 (loopback). With lan:expose on, the dnsmasq answers with the host's primary LAN IP so remote clients can reach the actual nginx instance, but the local host still routes those packets through its own loopback interface so the site is reachable from the server itself too.
Returns (true, nil) if DNS resolution is working correctly for the given TLD in either mode.
func ConfigureResolver ¶ added in v0.1.53
func ConfigureResolver() error
ConfigureResolver configures the system DNS resolver to forward .test to the lerd-dns dnsmasq container on port 5300. Call this after lerd-dns is running so that any immediate resolvectl changes don't break DNS before dnsmasq is up.
func InstallSudoers ¶ added in v0.3.0
func InstallSudoers() error
InstallSudoers writes a sudoers drop-in granting the current user passwordless access to resolvectl commands. This is required for the autostart service which runs non-interactively and cannot prompt for a sudo password.
func ReadContainerDNS ¶ added in v1.0.4
func ReadContainerDNS() []string
ReadContainerDNS returns DNS servers for aardvark-dns on the lerd network, preferring pasta's info.json (typically 169.254.1.1) and falling back to host upstreams then pastaDefaultForwarder so the list is never empty.
func ReadUpstreamDNS ¶ added in v1.0.3
func ReadUpstreamDNS() []string
ReadUpstreamDNS returns upstream DNS server IPs from the running system. Sources tried in order:
- /run/systemd/resolve/resolv.conf — real upstreams on systemd-resolved systems
- /etc/resolv.conf — fallback
- nmcli — DHCP-provided DNS from NetworkManager
Returns nil if nothing is found; callers should omit no-resolv in that case.
func ResolverHint ¶ added in v1.6.0
func ResolverHint() string
ResolverHint returns a user-facing hint for restarting the active DNS resolver.
func Setup
deprecated
func Setup() error
Setup writes DNS configuration for .test resolution and restarts the resolver. On systemd-resolved + NetworkManager systems (Ubuntu etc.) it uses an NM dispatcher script. On pure systemd-resolved systems it uses a resolved drop-in. On NetworkManager-only systems it uses NM's embedded dnsmasq.
Deprecated: prefer calling WriteDnsmasqConfig then ConfigureResolver separately so that the dnsmasq container can be started between the two steps.
func Teardown ¶ added in v0.1.55
func Teardown()
Teardown removes all lerd DNS configuration from the system and restores normal resolution.
func WaitReady ¶ added in v0.4.3
WaitReady blocks until lerd-dns is accepting TCP connections on port 5300 (dnsmasq supports DNS over TCP), or until the timeout elapses. Returns nil when ready, error on timeout.
func WriteDnsmasqConfig ¶
WriteDnsmasqConfig writes the lerd dnsmasq config to the given directory, auto-detecting the right target based on whether `lerd lan:expose` is on.
When cfg.LAN.Exposed is false the config answers .test queries with 127.0.0.1 / ::1, suitable for local-only use. When it's true the config answers with the host's primary LAN IP (v4 + v6 when available) so remote clients reach the actual nginx instance through the lerd-dns-forwarder service.
func WriteDnsmasqConfigDual ¶ added in v1.18.0
WriteDnsmasqConfigDual is the v4+v6 form of WriteDnsmasqConfigFor. Pass v6Target = "" to skip the AAAA record entirely.
func WriteDnsmasqConfigFor ¶ added in v1.8.0
WriteDnsmasqConfigFor writes the lerd dnsmasq config with `target` as the IPv4 answer for `*.test`. An AAAA pair is derived (::1 locally, host's global v6 when LAN-exposed). Upstreams come from the system; if none are usable, the pasta default forwarder is used so .test routing keeps working.
Types ¶
type Diagnostic ¶ added in v1.19.0
type Diagnostic struct {
TLD string `json:"tld"`
Steps []Step `json:"steps"`
FirstFailure int `json:"first_failure"`
}
Diagnostic is the result of walking the DNS chain end to end. Steps are returned in chain order; FirstFailure points at the index of the first rung that returned Fail (or -1 when everything passed).
func Diagnose ¶ added in v1.19.0
func Diagnose(tld string) Diagnostic
Diagnose walks the DNS chain top to bottom and returns a structured result. tld defaults to "test" when empty.
type Step ¶ added in v1.19.0
type Step struct {
Name string `json:"name"`
Status StepStatus `json:"status"`
Detail string `json:"detail,omitempty"`
Hint string `json:"hint,omitempty"`
}
Step is a single rung in the layered diagnostic. Higher rungs can only pass when the lower ones do; once a rung fails, the orchestrator marks every subsequent rung Skip with a brief reason so the user sees exactly where the chain breaks without a wall of cascaded failures.
type StepStatus ¶ added in v1.19.0
type StepStatus string
StepStatus is the outcome of a single rung in the layered DNS check.
const ( StepOK StepStatus = "ok" StepFail StepStatus = "fail" StepWarn StepStatus = "warn" StepSkip StepStatus = "skip" )