dnsstatus

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package dnsstatus reports, for each DNS record a feature needs, whether it is live, still waiting, different or blocked, and what the zone already holds.

Index

Constants

View Source
const (
	EnvLookupTimeout   = "APP_DNS_STATUS_LOOKUP_TIMEOUT"
	EnvProviderTimeout = "APP_DNS_STATUS_PROVIDER_TIMEOUT"
	EnvConcurrency     = "APP_DNS_STATUS_CONCURRENCY"
	EnvCacheSeconds    = "APP_DNS_STATUS_CACHE_SECONDS"
)

Env knobs for public DNS checks and the result cache.

View Source
const (
	Live      = "live"
	Waiting   = "waiting"
	Different = "different"
	Conflict  = "conflict"
	Unknown   = "unknown"
)

Record statuses.

View Source
const (
	SourceProvider  = "provider"
	SourcePublicDNS = "public_dns"
)

Where the found records came from.

Variables

This section is empty.

Functions

func CacheTTL

func CacheTTL() time.Duration

CacheTTL is how long a result is reused; 0 disables reuse.

func JoinTXT

func JoinTXT(v string) string

JoinTXT rejoins a TXT value written as quoted strings (DKIM and SPF are often split into 255 byte chunks) into the single string receivers see.

func Key

func Key(wants []Want, parts ...string) string

Key identifies one status request for the cache.

func Normalize

func Normalize(typ, v string) string

Normalize is the comparable form of a record value: case, trailing dots, quotes, TXT chunks and spacing do not make two values differ.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache reuses a result for a few seconds and coalesces identical concurrent requests, so a retry burst does one round of lookups. The zero value is ready.

func (*Cache) Do

func (c *Cache) Do(key string, ttl time.Duration, fn func() Status) Status

Do returns a result younger than ttl, waits for an identical call in flight, or runs fn.

type Counts

type Counts struct {
	Live      int `json:"live"`
	Waiting   int `json:"waiting"`
	Different int `json:"different"`
	Conflict  int `json:"conflict"`
	Unknown   int `json:"unknown"`
	Total     int `json:"total"`
}

Counts tallies records by status.

type Found

type Found struct {
	Type    string `json:"type"`
	Name    string `json:"name"`
	Value   string `json:"value"`
	TTL     int    `json:"ttl,omitempty"`
	Proxied *bool  `json:"proxied,omitempty"`
}

Found is one record that already exists at the name.

type Options

type Options struct {
	Timeout         time.Duration
	ProviderTimeout time.Duration
	Concurrency     int
}

Options bounds public DNS checks.

func OptionsFromEnv

func OptionsFromEnv() Options

OptionsFromEnv reads the lookup timeouts and concurrency from env.

type Record

type Record struct {
	ID        string  `json:"id"`
	Type      string  `json:"type"`
	Name      string  `json:"name"`
	Value     string  `json:"value"`
	TTL       int     `json:"ttl"`
	Priority  *int    `json:"priority,omitempty"`
	Status    string  `json:"status"`
	Found     []Found `json:"found"`
	Reason    string  `json:"reason,omitempty"`
	CheckedAt string  `json:"checked_at"`
}

Record is the live status of one wanted record.

type Resolver

type Resolver interface {
	LookupTXT(ctx context.Context, name string) ([]string, error)
	LookupCNAME(ctx context.Context, name string) (string, error)
	LookupMX(ctx context.Context, name string) ([]*net.MX, error)
	LookupHost(ctx context.Context, host string) ([]string, error)
	LookupSRV(ctx context.Context, service, proto, name string) (string, []*net.SRV, error)
}

Resolver is the slice of net.Resolver a public DNS check needs.

type Status

type Status struct {
	ProviderSource string   `json:"provider_source"`
	CheckedAt      string   `json:"checked_at"`
	Counts         Counts   `json:"counts"`
	Records        []Record `json:"records"`
	// DelegationWarning means the records come from a provider zone public DNS does not use yet.
	DelegationWarning bool   `json:"delegation_warning,omitempty"`
	DelegationReason  string `json:"delegation_reason,omitempty"`
}

Status is the per-record report plus its counts and source.

func FromResolver

func FromResolver(ctx context.Context, r Resolver, wants []Want, o Options, now time.Time) Status

FromResolver grades wants against public DNS, a bounded number of lookups at a time.

func FromZone

func FromZone(wants []Want, sets []ZoneSet, o ZoneOptions, now time.Time) Status

FromZone grades wants against a provider's authoritative zone listing.

type Want

type Want struct {
	ID       string
	Type     string
	Name     string
	Value    string
	TTL      int
	Priority *int
	// Reach adds names that must stay unproxied for this record to work (mta-sts).
	Reach []string
}

Want is one record a feature needs. Name is absolute without a trailing dot; MX and SRV carry the priority separately from Value.

type ZoneOptions

type ZoneOptions struct {
	// Shadow lists names mail must reach directly; a proxied record there is a conflict.
	Shadow map[string]bool
	// ProxyAware is true when the provider has a proxy flag, so false is meaningful.
	ProxyAware bool
}

ZoneOptions tunes FromZone.

type ZoneSet

type ZoneSet struct {
	Name    string
	Type    string
	TTL     int
	Values  []string
	Proxied bool
}

ZoneSet is one record set of a provider listing, with an absolute name.

Jump to

Keyboard shortcuts

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