Documentation
¶
Overview ¶
Package dns provides DNS-related utilities, including DNS-over-HTTPS and IP reverse lookups.
Index ¶
- Constants
- func BlocklistLookupAddr(addr string) (bool, error)
- func ReverseIP(addr string) (string, error)
- type DNSRecord
- type DOHClient
- type TLSARecord
- type TXTRecord
- type TemplatedFileTXTRecord
- func (r *TemplatedFileTXTRecord) Empty() bool
- func (r *TemplatedFileTXTRecord) RecordPrefix() string
- func (r *TemplatedFileTXTRecord) RecordType() string
- func (r *TemplatedFileTXTRecord) RecordValue() string
- func (r *TemplatedFileTXTRecord) Render(data any) error
- func (r *TemplatedFileTXTRecord) String() string
- type TemplatedRecord
Constants ¶
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 ¶
BlocklistLookupAddr checks if the given IP address is listed in the Spamhaus blocklist.
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 ¶
DOHClient describes a DNS over HTTPS client.
func NewDOHClient ¶
NewDOHClient creates a new DNS over HTTPS client with the provided URL.
type TLSARecord ¶ added in v0.66.0
type TLSARecord struct {
// CertPathTemplate is a Go template string (expanded against the data
// passed to Render) for the path to the PEM-encoded certificate file
// this record's value is derived from.
CertPathTemplate string `mapstructure:"cert-path-template"`
// Name is the DNS owner label this record targets, e.g. "mx" for a TLSA
// record on a mail exchanger.
Name string `mapstructure:"name"`
// Port and Proto identify the service this TLSA record applies to,
// e.g. Port 25, Proto "tcp" for SMTP.
Port uint8 `mapstructure:"port"`
Proto string `mapstructure:"proto"`
// Selector, MatchingType, and Usage are the TLSA record's own fields,
// as defined in RFC 6698.
Selector uint8 `mapstructure:"selector"`
MatchingType uint8 `mapstructure:"matching-type"`
Usage uint8 `mapstructure:"usage"`
AutoRefresh bool `mapstructure:"auto-refresh"`
AutoRefreshPeriodSeconds int64 `mapstructure:"auto-refresh-period-seconds"`
// contains filtered or unexported fields
}
TLSARecord is a TLSA/DANE record whose value is computed from the X.509 certificate at a templated file path. Content is fetched lazily on first Render and, if AutoRefresh is set, kept fresh afterward by a background ticker running every AutoRefreshPeriodSeconds -- see refreshableContent.
func (*TLSARecord) Empty ¶ added in v0.66.0
func (r *TLSARecord) Empty() bool
Empty reports whether this record has no configuration and has not yet fetched any content.
func (*TLSARecord) RecordPrefix ¶ added in v0.66.0
func (r *TLSARecord) RecordPrefix() string
func (*TLSARecord) RecordType ¶ added in v0.66.0
func (r *TLSARecord) RecordType() string
func (*TLSARecord) RecordValue ¶ added in v0.66.0
func (r *TLSARecord) RecordValue() string
func (*TLSARecord) Render ¶ added in v0.66.0
func (r *TLSARecord) Render(data any) error
func (*TLSARecord) String ¶ added in v0.66.0
func (r *TLSARecord) String() string
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) RecordPrefix ¶ added in v0.63.0
func (*TXTRecord) RecordTTL ¶ added in v0.63.0
RecordTTL returns the TTL to use for this record, falling back to DefaultTTL.
func (*TXTRecord) RecordType ¶ added in v0.63.0
func (*TXTRecord) RecordValue ¶ added in v0.63.0
type TemplatedFileTXTRecord ¶ added in v0.66.0
type TemplatedFileTXTRecord struct {
// PathTemplate is a Go template string (expanded against the data passed
// to Render) for the path to the file this record's value is read from.
PathTemplate string `mapstructure:"path-template"`
// Name is the DNS owner label this record targets, e.g.
// "default._domainkey" for a DKIM selector record. "" targets the apex.
Name string `mapstructure:"name"`
AutoRefresh bool `mapstructure:"auto-refresh"`
AutoRefreshPeriodSeconds int64 `mapstructure:"auto-refresh-period-seconds"`
// contains filtered or unexported fields
}
TemplatedFileTXTRecord is a DNS TXT record whose value is the contents of a file at a templated path. Content is fetched lazily on first Render and, if AutoRefresh is set, kept fresh afterward by a background ticker running every AutoRefreshPeriodSeconds -- see refreshableContent.
func (*TemplatedFileTXTRecord) Empty ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) Empty() bool
Empty reports whether this record has no configuration and has not yet fetched any content.
func (*TemplatedFileTXTRecord) RecordPrefix ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) RecordPrefix() string
func (*TemplatedFileTXTRecord) RecordType ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) RecordType() string
func (*TemplatedFileTXTRecord) RecordValue ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) RecordValue() string
func (*TemplatedFileTXTRecord) Render ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) Render(data any) error
func (*TemplatedFileTXTRecord) String ¶ added in v0.66.0
func (r *TemplatedFileTXTRecord) String() string
type TemplatedRecord ¶ added in v0.63.0
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.