dns

package
v0.63.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dns provides DNS-related utilities, including DNS-over-HTTPS and IP reverse lookups.

Index

Constants

View Source
const DefaultTTL uint32 = 60

DefaultTTL is the DNS TTL used when a record does not specify one.

Variables

This section is empty.

Functions

func BlocklistLookupAddr

func BlocklistLookupAddr(addr string) (bool, error)

BlocklistLookupAddr checks if the given IP address is listed in the Spamhaus blocklist.

func ReverseIP

func ReverseIP(addr string) (string, error)

ReverseIP returns the reverse DNS notation for an IP address.

Types

type DNSRecord added in v0.63.0

type DNSRecord interface {
	// RecordPrefix returns the DNS owner label prefix relative to the base domain,
	// e.g. "_dmarc." or "" for the apex.
	RecordPrefix() string
	// RecordType returns the DNS record type string, e.g. "TXT" or "MX".
	RecordType() string
	// RecordValue returns the wire-ready record value for insertion into a
	// CoreDNS template answer line.
	RecordValue() string
}

DNSRecord is the canonical interface for DNS record types across this module. Existing smtp sub-package records implement it by structural compatibility; the coredns package imports this definition rather than defining its own.

type DOHClient

type DOHClient struct {
	Client *http.Client
	URL    *url.URL
}

DOHClient describes a DNS over HTTPS client.

func NewDOHClient

func NewDOHClient(url *url.URL) *DOHClient

NewDOHClient creates a new DNS over HTTPS client with the provided URL.

func (*DOHClient) Exchange

func (c *DOHClient) Exchange(msg *dns.Msg) (*dns.Msg, error)

Exchange performs a DNS query using DNS over HTTPS.

type TXTRecord added in v0.63.0

type TXTRecord struct {
	// Name is the DNS owner label relative to the base domain. "" = apex.
	Name string `mapstructure:"name" json:"name,omitempty"`
	// Value is a Go template string for the TXT record content (e.g. "v=spf1 {{.OutboundIPList}} -all").
	Value string `mapstructure:"value" json:"value"`
	// TTL is the DNS TTL in seconds advertised to resolvers. Zero uses DefaultTTL.
	TTL uint32 `mapstructure:"ttl" json:"ttl,omitempty"`
}

TXTRecord is a generic DNS TXT record with optional Go template expansion in Value.

func (*TXTRecord) Empty added in v0.63.0

func (r *TXTRecord) Empty() bool

func (*TXTRecord) RecordPrefix added in v0.63.0

func (r *TXTRecord) RecordPrefix() string

func (*TXTRecord) RecordTTL added in v0.63.0

func (r *TXTRecord) RecordTTL() uint32

RecordTTL returns the TTL to use for this record, falling back to DefaultTTL.

func (*TXTRecord) RecordType added in v0.63.0

func (r *TXTRecord) RecordType() string

func (*TXTRecord) RecordValue added in v0.63.0

func (r *TXTRecord) RecordValue() string

func (*TXTRecord) Render added in v0.63.0

func (r *TXTRecord) Render(data any) error

Render expands Go template directives in Value (e.g. {{.Domain}}, {{.Email}}).

type TemplatedRecord added in v0.63.0

type TemplatedRecord interface {
	Render(data any) error
	Empty() bool
}

TemplatedRecord is satisfied by records whose field values contain Go template strings that must be expanded before the record is served. It matches the interface already defined in github.com/dioad/net/smtp.

Jump to

Keyboard shortcuts

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