Complete reference for all DNS resource record types supported by the library. All RR types implement the RR interface.
Base interface implemented by all resource records.
type RR interface {
Header() *RR_Header
String() string
}Common header for all resource records.
type RR_Header struct {
Name string // Owner name (must be FQDN)
Rrtype uint16 // RR type
Class uint16 // RR class
Ttl uint32 // Time to live
Rdlength uint16 // Rdata length
}
func (h *RR_Header) Header() *RR_Header
func (h *RR_Header) String() string// NewRR parses single RR from string
func NewRR(s string) (RR, error)
// Copy creates deep copy of RR
func Copy(r RR) RR
// Len returns RR length in wire format
func Len(rr RR) int
// IsDuplicate checks if two RRs are duplicates
func IsDuplicate(r1, r2 RR) bool
// IsRRset validates if slice is proper RRset
func IsRRset(rrset []RR) booltype A struct {
Hdr RR_Header
A net.IP // IPv4 address
}type AAAA struct {
Hdr RR_Header
AAAA net.IP // IPv6 address
}type CNAME struct {
Hdr RR_Header
Target string // Canonical name
}type NS struct {
Hdr RR_Header
Ns string // Name server domain name
}type PTR struct {
Hdr RR_Header
Ptr string // Pointer domain name
}type MX struct {
Hdr RR_Header
Preference uint16 // Preference value
Mx string // Mail exchange domain name
}type SOA struct {
Hdr RR_Header
Ns string // Primary name server
Mbox string // Responsible party mailbox
Serial uint32 // Serial number
Refresh uint32 // Refresh interval
Retry uint32 // Retry interval
Expire uint32 // Expire time
Minttl uint32 // Minimum TTL
}type TXT struct {
Hdr RR_Header
Txt []string // Text strings
}type SRV struct {
Hdr RR_Header
Priority uint16 // Priority
Weight uint16 // Weight
Port uint16 // Port number
Target string // Target domain name
}type DNSKEY struct {
Hdr RR_Header
Flags uint16 // Flags
Protocol uint8 // Protocol (always 3)
Algorithm uint8 // Algorithm
PublicKey string // Base64 encoded public key
}
func (k *DNSKEY) KeyTag() uint16
func (k *DNSKEY) ToDS(h uint8) *DS
func (k *DNSKEY) ToCDNSKEY() *CDNSKEY
func (k *DNSKEY) NewPrivateKey(s string) (crypto.PrivateKey, error)type DS struct {
Hdr RR_Header
KeyTag uint16 // Key tag
Algorithm uint8 // Algorithm
DigestType uint8 // Digest type
Digest string // Hex encoded digest
}
func (ds *DS) ToCDS() *CDStype RRSIG struct {
Hdr RR_Header
TypeCovered uint16 // Type covered by signature
Algorithm uint8 // Algorithm
Labels uint8 // Number of labels
OrigTtl uint32 // Original TTL
Expiration uint32 // Signature expiration
Inception uint32 // Signature inception
KeyTag uint16 // Key tag
SignerName string // Signer name
Signature string // Base64 encoded signature
}
func (rr *RRSIG) Sign(k crypto.Signer, rrset []RR) error
func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error
func (rr *RRSIG) ValidityPeriod(t time.Time) booltype NSEC struct {
Hdr RR_Header
NextDomain string // Next domain name
TypeBitMap []uint16 // Type bit map
}type NSEC3 struct {
Hdr RR_Header
Hash uint8 // Hash algorithm
Flags uint8 // Flags
Iterations uint16 // Iterations
SaltLength uint8 // Salt length
Salt string // Hex encoded salt
HashLength uint8 // Hash length
NextDomain string // Next hashed owner name
TypeBitMap []uint16 // Type bit map
}
func (rr *NSEC3) Cover(name string) bool
func (rr *NSEC3) Match(name string) booltype NSEC3PARAM struct {
Hdr RR_Header
Hash uint8 // Hash algorithm
Flags uint8 // Flags
Iterations uint16 // Iterations
SaltLength uint8 // Salt length
Salt string // Hex encoded salt
}type CDNSKEY struct {
DNSKEY // Embeds DNSKEY
}type CDS struct {
DS // Embeds DS
}type DLV struct {
DS // Embeds DS
}type TA struct {
Hdr RR_Header
KeyTag uint16 // Key tag
Algorithm uint8 // Algorithm
DigestType uint8 // Digest type
Digest string // Hex encoded digest
}type TLSA struct {
Hdr RR_Header
Usage uint8 // Certificate usage
Selector uint8 // Selector
MatchingType uint8 // Matching type
Certificate string // Hex encoded certificate data
}
func (rr *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error
func (rr *TLSA) Verify(cert *x509.Certificate) errortype SMIMEA struct {
Hdr RR_Header
Usage uint8 // Certificate usage
Selector uint8 // Selector
MatchingType uint8 // Matching type
Certificate string // Hex encoded certificate data
}
func (rr *SMIMEA) Sign(usage, selector, matchingType int, cert *x509.Certificate) error
func (rr *SMIMEA) Verify(cert *x509.Certificate) errortype CERT struct {
Hdr RR_Header
Type uint16 // Certificate type
KeyTag uint16 // Key tag
Algorithm uint8 // Algorithm
Certificate string // Base64 encoded certificate
}type SSHFP struct {
Hdr RR_Header
Algorithm uint8 // Algorithm
Type uint8 // Fingerprint type
FingerPrint string // Hex encoded fingerprint
}type IPSECKEY struct {
Hdr RR_Header
Precedence uint8 // Precedence
GatewayType uint8 // Gateway type
Algorithm uint8 // Algorithm
GatewayAddr net.IP // Gateway IP address
GatewayHost string // Gateway hostname
PublicKey string // Base64 encoded public key
}type OPENPGPKEY struct {
Hdr RR_Header
PublicKey string // Base64 encoded public key
}type KEY struct {
DNSKEY // Embeds DNSKEY
}type RKEY struct {
Hdr RR_Header
Flags uint16 // Flags
Protocol uint8 // Protocol
Algorithm uint8 // Algorithm
PublicKey string // Base64 encoded public key
}type SIG struct {
RRSIG // Embeds RRSIG
}
func (rr *SIG) Sign(k crypto.Signer, m *Msg) ([]byte, error)
func (rr *SIG) Verify(k *KEY, msg []byte) errortype SVCB struct {
Hdr RR_Header
Priority uint16 // Priority
Target string // Target domain name
Value []SVCBKeyValue // Service parameters
}type HTTPS struct {
SVCB // Embeds SVCB
}type NAPTR struct {
Hdr RR_Header
Order uint16 // Order
Preference uint16 // Preference
Flags string // Flags
Service string // Service
Regexp string // Regular expression
Replacement string // Replacement domain name
}type L32 struct {
Hdr RR_Header
Preference uint16 // Preference
Locator32 net.IP // IPv4 locator
}type L64 struct {
Hdr RR_Header
Preference uint16 // Preference
Locator64 uint64 // 64-bit locator
}type LP struct {
Hdr RR_Header
Preference uint16 // Preference
Fqdn string // FQDN
}type NID struct {
Hdr RR_Header
Preference uint16 // Preference
NodeID uint64 // Node ID
}type EUI48 struct {
Hdr RR_Header
Address uint64 // 48-bit address
}type EUI64 struct {
Hdr RR_Header
Address uint64 // 64-bit address
}type LOC struct {
Hdr RR_Header
Version uint8 // Version
Size uint8 // Size
HorizPre uint8 // Horizontal precision
VertPre uint8 // Vertical precision
Latitude uint32 // Latitude
Longitude uint32 // Longitude
Altitude uint32 // Altitude
}type GPOS struct {
Hdr RR_Header
Longitude string // Longitude
Latitude string // Latitude
Altitude string // Altitude
}type CAA struct {
Hdr RR_Header
Flag uint8 // Flags
Tag string // Property tag
Value string // Property value
}type URI struct {
Hdr RR_Header
Priority uint16 // Priority
Weight uint16 // Weight
Target string // URI target
}type SPF struct {
Hdr RR_Header
Txt []string // SPF text strings
}type DNAME struct {
Hdr RR_Header
Target string // Delegation target
}type TALINK struct {
Hdr RR_Header
PreviousName string // Previous trust anchor name
NextName string // Next trust anchor name
}type HIP struct {
Hdr RR_Header
HitLength uint8 // HIT length
PublicKeyAlgorithm uint8 // Public key algorithm
PublicKeyLength uint16 // Public key length
Hit string // Hex encoded HIT
PublicKey string // Base64 encoded public key
RendezvousServers []string // Rendezvous server names
}type APL struct {
Hdr RR_Header
Prefixes []APLPrefix // Address prefixes
}
type APLPrefix struct {
Negation bool // Negation flag
Network net.IPNet // IP network
}type DHCID struct {
Hdr RR_Header
Digest string // Base64 encoded digest
}type ZONEMD struct {
Hdr RR_Header
Serial uint32 // Serial number
Scheme uint8 // Scheme
Hash uint8 // Hash algorithm
Digest string // Hex encoded digest
}type AMTRELAY struct {
Hdr RR_Header
Precedence uint8 // Precedence
GatewayType uint8 // Gateway type (includes discovery bit)
GatewayAddr net.IP // Gateway IP address
GatewayHost string // Gateway hostname
}type RESINFO struct {
Hdr RR_Header
Txt []string // Information strings
}type AVC struct {
Hdr RR_Header
Txt []string // AVC strings
}type NINFO struct {
Hdr RR_Header
ZSData []string // Zone status data
}type HINFO struct {
Hdr RR_Header
Cpu string // CPU type
Os string // Operating system
}type RP struct {
Hdr RR_Header
Mbox string // Mailbox domain name
Txt string // TXT domain name
}type AFSDB struct {
Hdr RR_Header
Subtype uint16 // Subtype
Hostname string // Hostname
}type X25 struct {
Hdr RR_Header
PSDNAddress string // PSDN address
}type ISDN struct {
Hdr RR_Header
Address string // ISDN address
SubAddress string // Sub-address
}type RT struct {
Hdr RR_Header
Preference uint16 // Preference
Host string // Intermediate host
}type PX struct {
Hdr RR_Header
Preference uint16 // Preference
Map822 string // RFC 822 mapping
Mapx400 string // X.400 mapping
}type KX struct {
Hdr RR_Header
Preference uint16 // Preference
Exchanger string // Key exchanger
}type MB struct {
Hdr RR_Header
Mb string // Mailbox domain name
}type MD struct {
Hdr RR_Header
Md string // Mail destination
}type MF struct {
Hdr RR_Header
Mf string // Mail forwarder
}type MG struct {
Hdr RR_Header
Mg string // Mail group member
}type MR struct {
Hdr RR_Header
Mr string // Mail rename name
}type MINFO struct {
Hdr RR_Header
Rmail string // Responsible mailbox
Email string // Error mailbox
}type NULL struct {
Hdr RR_Header
Data string // Arbitrary data
}type NSAPPTR struct {
Hdr RR_Header
Ptr string // Pointer domain name
}type NIMLOC struct {
Hdr RR_Header
Locator string // Hex encoded locator
}type EID struct {
Hdr RR_Header
Endpoint string // Hex encoded endpoint
}type NXT struct {
NSEC // Embeds NSEC
}type NXNAME struct {
Hdr RR_Header
// No rdata
}type UID struct {
Hdr RR_Header
Uid uint32 // User ID
}type GID struct {
Hdr RR_Header
Gid uint32 // Group ID
}type UINFO struct {
Hdr RR_Header
Uinfo string // User information
}type UNSPEC struct {
Hdr RR_Header
// No rdata
}type ANY struct {
Hdr RR_Header
// No rdata
}type OPT struct {
Hdr RR_Header
Option []EDNS0 // EDNS0 options
}
func (rr *OPT) Do() bool
func (rr *OPT) SetDo(do bool)
func (rr *OPT) Version() uint8
func (rr *OPT) SetVersion(v uint8)
func (rr *OPT) ExtendedRcode() int
func (rr *OPT) SetExtendedRcode(v uint8)
func (rr *OPT) UDPSize() uint16
func (rr *OPT) SetUDPSize(size uint16)See EDNS0 Details for complete EDNS0 documentation.
type TKEY struct {
Hdr RR_Header
Algorithm string // Algorithm domain name
Inception uint32 // Inception time
Expiration uint32 // Expiration time
Mode uint16 // Mode
Error uint16 // Error code
KeySize uint16 // Key size
Key string // Hex encoded key
OtherLen uint16 // Other data length
OtherData string // Hex encoded other data
}type TSIG struct {
Hdr RR_Header
Algorithm string // Algorithm domain name
TimeSigned uint64 // Time signed
Fudge uint16 // Time fudge
MACSize uint16 // MAC size
MAC string // Hex encoded MAC
OrigId uint16 // Original message ID
Error uint16 // Error code
OtherLen uint16 // Other data length
OtherData string // Hex encoded other data
}See TSIG Details for complete TSIG documentation.
type RFC3597 struct {
Hdr RR_Header
Rdata string // Hex encoded rdata
}type SVCBKeyValue interface {
Key() SVCBKey
String() string
}type SVCBMandatory struct {
Code []SVCBKey // Mandatory keys
}
type SVCBAlpn struct {
Alpn []string // ALPN protocol IDs
}
type SVCBNoDefaultAlpn struct {
// No fields
}
type SVCBPort struct {
Port uint16 // Port number
}
type SVCBIPv4Hint struct {
Hint []net.IP // IPv4 hints
}
type SVCBIPv6Hint struct {
Hint []net.IP // IPv6 hints
}
type SVCBECHConfig struct {
ECH []byte // ECH configuration
}
type SVCBDoHPath struct {
Template string // DoH URI template
}
type SVCBOhttp struct {
Target string // OHTTP target
}
type SVCBLocal struct {
KeyCode SVCBKey // Key code
Data []byte // Data
}rr := &dns.A{
Hdr: dns.RR_Header{
Name: "example.com.",
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: 3600,
},
A: net.ParseIP("192.0.2.1"),
}rr := &dns.MX{
Hdr: dns.RR_Header{
Name: "example.com.",
Rrtype: dns.TypeMX,
Class: dns.ClassINET,
Ttl: 3600,
},
Preference: 10,
Mx: "mail.example.com.",
}rr := &dns.SOA{
Hdr: dns.RR_Header{
Name: "example.com.",
Rrtype: dns.TypeSOA,
Class: dns.ClassINET,
Ttl: 3600,
},
Ns: "ns1.example.com.",
Mbox: "admin.example.com.",
Serial: 2024010101,
Refresh: 3600,
Retry: 1800,
Expire: 604800,
Minttl: 86400,
}rr, err := dns.NewRR("example.com. 3600 IN A 192.0.2.1")
if err != nil {
log.Fatal(err)
}
// Type assert to specific type
if a, ok := rr.(*dns.A); ok {
fmt.Printf("IPv4: %s\n", a.A)
}rr := &dns.TXT{
Hdr: dns.RR_Header{
Name: "example.com.",
Rrtype: dns.TypeTXT,
Class: dns.ClassINET,
Ttl: 3600,
},
Txt: []string{"v=spf1 mx -all", "google-site-verification=abc123"},
}rr := &dns.SRV{
Hdr: dns.RR_Header{
Name: "_http._tcp.example.com.",
Rrtype: dns.TypeSRV,
Class: dns.ClassINET,
Ttl: 3600,
},
Priority: 10,
Weight: 60,
Port: 80,
Target: "www.example.com.",
}original := &dns.A{
Hdr: dns.RR_Header{
Name: "example.com.",
Rrtype: dns.TypeA,
Class: dns.ClassINET,
Ttl: 3600,
},
A: net.ParseIP("192.0.2.1"),
}
copied := dns.Copy(original).(*dns.A)All RR type codes are defined as constants:
const (
TypeA uint16 = 1
TypeNS uint16 = 2
TypeMD uint16 = 3
TypeMF uint16 = 4
TypeCNAME uint16 = 5
TypeSOA uint16 = 6
TypeMB uint16 = 7
TypeMG uint16 = 8
TypeMR uint16 = 9
TypeNULL uint16 = 10
TypePTR uint16 = 12
TypeHINFO uint16 = 13
TypeMINFO uint16 = 14
TypeMX uint16 = 15
TypeTXT uint16 = 16
TypeRP uint16 = 17
TypeAFSDB uint16 = 18
TypeX25 uint16 = 19
TypeISDN uint16 = 20
TypeRT uint16 = 21
TypeNSAPPTR uint16 = 23
TypeSIG uint16 = 24
TypeKEY uint16 = 25
TypePX uint16 = 26
TypeGPOS uint16 = 27
TypeAAAA uint16 = 28
TypeLOC uint16 = 29
TypeNXT uint16 = 30
TypeEID uint16 = 31
TypeNIMLOC uint16 = 32
TypeSRV uint16 = 33
TypeATMA uint16 = 34
TypeNAPTR uint16 = 35
TypeKX uint16 = 36
TypeCERT uint16 = 37
TypeDNAME uint16 = 39
TypeOPT uint16 = 41
TypeAPL uint16 = 42
TypeDS uint16 = 43
TypeSSHFP uint16 = 44
TypeIPSECKEY uint16 = 45
TypeRRSIG uint16 = 46
TypeNSEC uint16 = 47
TypeDNSKEY uint16 = 48
TypeDHCID uint16 = 49
TypeNSEC3 uint16 = 50
TypeNSEC3PARAM uint16 = 51
TypeTLSA uint16 = 52
TypeSMIMEA uint16 = 53
TypeHIP uint16 = 55
TypeNINFO uint16 = 56
TypeRKEY uint16 = 57
TypeTALINK uint16 = 58
TypeCDS uint16 = 59
TypeCDNSKEY uint16 = 60
TypeOPENPGPKEY uint16 = 61
TypeCSYNC uint16 = 62
TypeZONEMD uint16 = 63
TypeSVCB uint16 = 64
TypeHTTPS uint16 = 65
TypeSPF uint16 = 99
TypeUINFO uint16 = 100
TypeUID uint16 = 101
TypeGID uint16 = 102
TypeUNSPEC uint16 = 103
TypeNID uint16 = 104
TypeL32 uint16 = 105
TypeL64 uint16 = 106
TypeLP uint16 = 107
TypeEUI48 uint16 = 108
TypeEUI64 uint16 = 109
TypeNXNAME uint16 = 128
TypeURI uint16 = 256
TypeCAA uint16 = 257
TypeAVC uint16 = 258
TypeAMTRELAY uint16 = 260
TypeRESINFO uint16 = 261
TypeTKEY uint16 = 249
TypeTSIG uint16 = 250
TypeIXFR uint16 = 251
TypeAXFR uint16 = 252
TypeMAILB uint16 = 253
TypeMAILA uint16 = 254
TypeANY uint16 = 255
TypeTA uint16 = 32768
TypeDLV uint16 = 32769
TypeReserved uint16 = 65535
)// TypeToString converts type code to string
func TypeToString(t uint16) string
// StringToType converts string to type code
func StringToType(s string) (uint16, bool)
// Type methods
type Type uint16
func (t Type) String() string