Documentation
¶
Overview ¶
Package rdatafields classifies the fields of an RDATA struct so that code can normalize them without a hand-maintained switch statement per rtype.
The classification is derived from the struct tags that codeberg.org/miekg/dns/rdata already puts on its fields, plus a small exclusion list (tagged fields that are domain names but are NOT hostnames) and a small inclusion list (fields that are hostnames but carry no usable tag, mostly in pkg/privatetypes/rdata).
build/normalizergen uses Fields to generate models.normalizeRDATA without runtime reflection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsObsolete ¶
IsObsolete reports whether structName is on the skip list above. Exported so a generator can log what it left out.
Types ¶
type Field ¶
type Field struct {
Name string // Go field name, e.g. "Target"
Index int // index into the struct, for reflect.Value.Field
Kind Kind
Slice bool // true if the field is a []string, e.g. HIP.RendezvousServers
}
Field is one classified field of an rdata struct.
type Kind ¶
type Kind int
Kind says how a field must be normalized before it is compared.
const ( // KindOther means "leave it alone". KindOther Kind = iota // KindTargetHost is a domain name that names a host: CNAME.Target, // MX.Mx, SRV.Target, ALIAS.Target, and so on. It is case-insensitive // and fully qualified, so we store it downcased and ending in ".". KindTargetHost // KindMailbox is an email address encoded as a domain name // (SOA.Mbox, RP.Mbox). It is case-insensitive on the wire, but the // local part is conventionally preserved, and it does not name a // host. We do not rewrite these. KindMailbox // KindHexLower is a hex-encoded blob (DS.Digest, SSHFP.FingerPrint, // TLSA.Certificate). Case-insensitive; we store it downcased. KindHexLower // KindOpaqueName is a domain name that is neither a host nor a // mailbox: a DNSSEC internal (RRSIG.SignerName, NSEC.NextDomain) or // an identifier that merely borrows the wire format // (TSIG.Algorithm). These must be preserved byte for byte. KindOpaqueName )
func Classify ¶
func Classify(structName string, f reflect.StructField) Kind
Classify returns the Kind of one field of the rdata struct named structName. structName is the Go struct name ("CNAME"), not the rtype name, so that types which share a struct (HTTPS and SVCB, CDS and DS) are classified once.