dnsinspect

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dnsinspect asks DNS questions the control plane controls itself: public resolvers and the zone's authoritative servers, so a stale cache on this host never decides whether a domain is ready.

Index

Constants

View Source
const (
	ProviderCloudflare   = "cloudflare"
	ProviderRoute53      = "route53"
	ProviderDigitalOcean = "digitalocean"
	ProviderHetzner      = "hetzner"
	ProviderNamecheap    = "namecheap"
	ProviderGoDaddy      = "godaddy"
	ProviderPorkbun      = "porkbun"
	ProviderGoogle       = "google"
	ProviderAzure        = "azure"
	ProviderNS1          = "ns1"
	ProviderDeSEC        = "desec"
	ProviderOther        = "other"
	ProviderUnknown      = "unknown"
)

Name server provider classes reported by ProviderOf.

View Source
const EnvPublicResolvers = "APP_DNS_PUBLIC_RESOLVERS"

EnvPublicResolvers overrides the public resolver list (comma separated host or host:port); "off", "false" or "0" disables public queries.

View Source
const LocalName = "this server"

LocalName labels this host's own resolver in reports.

Variables

This section is empty.

Functions

func FlushCommand

func FlushCommand() string

FlushCommand is the one-line command that clears this host's resolver cache, or empty when the resolver is not one we can name. It is shown to the operator, never run.

func ProviderOf

func ProviderOf(ns []string) string

ProviderOf classifies a zone by its name server hostnames so the UI can offer to connect the matching DNS provider. Mixed sets count as other.

func PublicResolvers

func PublicResolvers() []string

PublicResolvers returns the configured public resolver addresses (host:port).

Types

type Exchanger

type Exchanger func(ctx context.Context, server, name string, qtype uint16, recurse bool) (*dns.Msg, error)

Exchanger sends one query; tests replace it.

type Inspection

type Inspection struct {
	Zone string `json:"zone,omitempty"`
	// DelegatedNS is what public resolvers say the zone's name servers are;
	// ZoneNS is what the zone's own servers say.
	DelegatedNS   []string `json:"delegated_ns,omitempty"`
	ZoneNS        []string `json:"zone_ns,omitempty"`
	Authoritative []Source `json:"authoritative"`
	Public        []Source `json:"public"`
	// AuthReachable is true when at least one authoritative server answered.
	AuthReachable bool `json:"auth_reachable"`
	// NegativeTTL is the SOA negative-caching time of the zone, in seconds.
	NegativeTTL uint32 `json:"negative_ttl,omitempty"`
}

Inspection is everything one run learned.

type Inspector

type Inspector struct {
	Public []string
	// LocalServers overrides the resolvers read from resolv.conf (tests).
	LocalServers []string
	// AuthPort is the port authoritative servers are queried on; 0 means 53.
	AuthPort int
	// AllowPrivate lets authoritative servers sit on private addresses; only
	// tests set it, since otherwise a zone could aim this host at its LAN.
	AllowPrivate bool
	Timeout      time.Duration
	Exchange     Exchanger
}

Inspector queries public resolvers and authoritative servers.

func New

func New() *Inspector

New returns an Inspector using the configured public resolvers.

func (*Inspector) Inspect

func (in *Inspector) Inspect(ctx context.Context, host string) Inspection

Inspect looks host up on every configured public resolver and on each of its zone's authoritative servers.

func (*Inspector) Local

func (in *Inspector) Local(ctx context.Context, host string) Source

Local asks this host's configured resolver directly, so the answer carries the cache's remaining TTL that net.Resolver hides.

type Source

type Source struct {
	Name      string   `json:"name"`
	Addresses []string `json:"addresses,omitempty"`
	// TTL is the longest answer TTL in seconds; for an empty answer it is the
	// negative-caching TTL the server reported.
	TTL   uint32 `json:"ttl,omitempty"`
	Error string `json:"error,omitempty"`
}

Source is one resolver's answer for the domain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL