golint fixes (#553)

* golint fixes

Comment all RR with references to relevant RFC or other docs.
Some lint fixes in edns0.go.

* Some more fixes
This commit is contained in:
Miek Gieben 2017-11-07 13:45:27 +00:00 committed by GitHub
parent f73262699a
commit 4bcc48899c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 93 additions and 25 deletions

View File

@ -153,8 +153,7 @@ func TestPack(t *testing.T) {
t.Error("packing should fail") t.Error("packing should fail")
} }
x.Answer = make([]RR, 1) x.Answer = make([]RR, 1)
x.Answer[0], err = NewRR(rr[0]) if x.Answer[0], err = NewRR(rr[0]); err != nil {
if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if _, err := x.Pack(); err == nil { if _, err := x.Pack(); err == nil {

View File

@ -114,13 +114,13 @@ func TestTrimDomainName(t *testing.T) {
// These test cases provide both origin, s, and the expected result. // These test cases provide both origin, s, and the expected result.
// If you find a bug in the while, this is probably the easiest place // If you find a bug in the while, this is probably the easiest place
// to add it as a test case. // to add it as a test case.
var tests_wild = []struct{ e1, e2, expected string }{ var testsWild = []struct{ e1, e2, expected string }{
{"mathoverflow.net.", ".", "mathoverflow.net"}, {"mathoverflow.net.", ".", "mathoverflow.net"},
{"mathoverflow.net", ".", "mathoverflow.net"}, {"mathoverflow.net", ".", "mathoverflow.net"},
{"", ".", "@"}, {"", ".", "@"},
{"@", ".", "@"}, {"@", ".", "@"},
} }
for i, test := range tests_wild { for i, test := range testsWild {
actual := TrimDomainName(test.e1, test.e2) actual := TrimDomainName(test.e1, test.e2)
if test.expected != actual { if test.expected != actual {
t.Errorf("%d TrimDomainName(%#v, %#v): expected (%v) got (%v)\n", i, test.e1, test.e2, test.expected, actual) t.Errorf("%d TrimDomainName(%#v, %#v): expected (%v) got (%v)\n", i, test.e1, test.e2, test.expected, actual)

16
edns.go
View File

@ -182,7 +182,8 @@ func (e *EDNS0_NSID) pack() ([]byte, error) {
return h, nil return h, nil
} }
func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } // Option implements the EDNS0 interface.
func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } // Option returns the option code.
func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil } func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil }
func (e *EDNS0_NSID) String() string { return string(e.Nsid) } func (e *EDNS0_NSID) String() string { return string(e.Nsid) }
@ -216,6 +217,7 @@ type EDNS0_SUBNET struct {
DraftOption bool // Set to true if using the old (0x50fa) option code DraftOption bool // Set to true if using the old (0x50fa) option code
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_SUBNET) Option() uint16 { func (e *EDNS0_SUBNET) Option() uint16 {
if e.DraftOption { if e.DraftOption {
return EDNS0SUBNETDRAFT return EDNS0SUBNETDRAFT
@ -345,6 +347,7 @@ func (e *EDNS0_COOKIE) pack() ([]byte, error) {
return h, nil return h, nil
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_COOKIE) Option() uint16 { return EDNS0COOKIE } func (e *EDNS0_COOKIE) Option() uint16 { return EDNS0COOKIE }
func (e *EDNS0_COOKIE) unpack(b []byte) error { e.Cookie = hex.EncodeToString(b); return nil } func (e *EDNS0_COOKIE) unpack(b []byte) error { e.Cookie = hex.EncodeToString(b); return nil }
func (e *EDNS0_COOKIE) String() string { return e.Cookie } func (e *EDNS0_COOKIE) String() string { return e.Cookie }
@ -366,6 +369,7 @@ type EDNS0_UL struct {
Lease uint32 Lease uint32
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_UL) Option() uint16 { return EDNS0UL } func (e *EDNS0_UL) Option() uint16 { return EDNS0UL }
func (e *EDNS0_UL) String() string { return strconv.FormatUint(uint64(e.Lease), 10) } func (e *EDNS0_UL) String() string { return strconv.FormatUint(uint64(e.Lease), 10) }
@ -395,6 +399,7 @@ type EDNS0_LLQ struct {
LeaseLife uint32 LeaseLife uint32
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_LLQ) Option() uint16 { return EDNS0LLQ } func (e *EDNS0_LLQ) Option() uint16 { return EDNS0LLQ }
func (e *EDNS0_LLQ) pack() ([]byte, error) { func (e *EDNS0_LLQ) pack() ([]byte, error) {
@ -431,6 +436,7 @@ type EDNS0_DAU struct {
AlgCode []uint8 AlgCode []uint8
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU } func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU }
func (e *EDNS0_DAU) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_DAU) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil }
@ -452,6 +458,7 @@ type EDNS0_DHU struct {
AlgCode []uint8 AlgCode []uint8
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU } func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU }
func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil }
@ -473,6 +480,7 @@ type EDNS0_N3U struct {
AlgCode []uint8 AlgCode []uint8
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U } func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U }
func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil } func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil }
func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil } func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil }
@ -495,6 +503,7 @@ type EDNS0_EXPIRE struct {
Expire uint32 Expire uint32
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_EXPIRE) Option() uint16 { return EDNS0EXPIRE } func (e *EDNS0_EXPIRE) Option() uint16 { return EDNS0EXPIRE }
func (e *EDNS0_EXPIRE) String() string { return strconv.FormatUint(uint64(e.Expire), 10) } func (e *EDNS0_EXPIRE) String() string { return strconv.FormatUint(uint64(e.Expire), 10) }
@ -533,6 +542,7 @@ type EDNS0_LOCAL struct {
Data []byte Data []byte
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_LOCAL) Option() uint16 { return e.Code } func (e *EDNS0_LOCAL) Option() uint16 { return e.Code }
func (e *EDNS0_LOCAL) String() string { func (e *EDNS0_LOCAL) String() string {
return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data) return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data)
@ -564,6 +574,7 @@ type EDNS0_TCP_KEEPALIVE struct {
Timeout uint16 // an idle timeout value for the TCP connection, specified in units of 100 milliseconds, encoded in network byte order. Timeout uint16 // an idle timeout value for the TCP connection, specified in units of 100 milliseconds, encoded in network byte order.
} }
// Option implements the EDNS0 interface.
func (e *EDNS0_TCP_KEEPALIVE) Option() uint16 { return EDNS0TCPKEEPALIVE } func (e *EDNS0_TCP_KEEPALIVE) Option() uint16 { return EDNS0TCPKEEPALIVE }
func (e *EDNS0_TCP_KEEPALIVE) pack() ([]byte, error) { func (e *EDNS0_TCP_KEEPALIVE) pack() ([]byte, error) {
@ -616,7 +627,8 @@ type EDNS0_PADDING struct {
Padding []byte Padding []byte
} }
func (e *EDNS0_PADDING) pack() ([]byte, error) { return e.Padding, nil } // Option implements the EDNS0 interface.
func (e *EDNS0_PADDING) Option() uint16 { return EDNS0PADDING } func (e *EDNS0_PADDING) Option() uint16 { return EDNS0PADDING }
func (e *EDNS0_PADDING) pack() ([]byte, error) { return e.Padding, nil }
func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = b; return nil } func (e *EDNS0_PADDING) unpack(b []byte) error { e.Padding = b; return nil }
func (e *EDNS0_PADDING) String() string { return fmt.Sprintf("%0X", e.Padding) } func (e *EDNS0_PADDING) String() string { return fmt.Sprintf("%0X", e.Padding) }

View File

@ -164,14 +164,15 @@ const (
_Z = 1 << 6 // Z _Z = 1 << 6 // Z
_AD = 1 << 5 // authticated data _AD = 1 << 5 // authticated data
_CD = 1 << 4 // checking disabled _CD = 1 << 4 // checking disabled
)
// Various constants used in the LOC RR, See RFC 1887.
const (
LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2. LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2.
LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2. LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2.
LOC_HOURS = 60 * 1000
LOC_HOURS = 60 * 1000 LOC_DEGREES = 60 * LOC_HOURS
LOC_DEGREES = 60 * LOC_HOURS LOC_ALTITUDEBASE = 100000
LOC_ALTITUDEBASE = 100000
) )
// Different Certificate Types, see RFC 4398, Section 2.1 // Different Certificate Types, see RFC 4398, Section 2.1
@ -237,6 +238,7 @@ type ANY struct {
func (rr *ANY) String() string { return rr.Hdr.String() } func (rr *ANY) String() string { return rr.Hdr.String() }
// CNAME RR. See RFC 1034.
type CNAME struct { type CNAME struct {
Hdr RR_Header Hdr RR_Header
Target string `dns:"cdomain-name"` Target string `dns:"cdomain-name"`
@ -244,6 +246,7 @@ type CNAME struct {
func (rr *CNAME) String() string { return rr.Hdr.String() + sprintName(rr.Target) } func (rr *CNAME) String() string { return rr.Hdr.String() + sprintName(rr.Target) }
// HINFO RR. See RFC 1034.
type HINFO struct { type HINFO struct {
Hdr RR_Header Hdr RR_Header
Cpu string Cpu string
@ -254,6 +257,7 @@ func (rr *HINFO) String() string {
return rr.Hdr.String() + sprintTxt([]string{rr.Cpu, rr.Os}) return rr.Hdr.String() + sprintTxt([]string{rr.Cpu, rr.Os})
} }
// MB RR. See RFC 1035.
type MB struct { type MB struct {
Hdr RR_Header Hdr RR_Header
Mb string `dns:"cdomain-name"` Mb string `dns:"cdomain-name"`
@ -261,6 +265,7 @@ type MB struct {
func (rr *MB) String() string { return rr.Hdr.String() + sprintName(rr.Mb) } func (rr *MB) String() string { return rr.Hdr.String() + sprintName(rr.Mb) }
// MG RR. See RFC 1035.
type MG struct { type MG struct {
Hdr RR_Header Hdr RR_Header
Mg string `dns:"cdomain-name"` Mg string `dns:"cdomain-name"`
@ -268,6 +273,7 @@ type MG struct {
func (rr *MG) String() string { return rr.Hdr.String() + sprintName(rr.Mg) } func (rr *MG) String() string { return rr.Hdr.String() + sprintName(rr.Mg) }
// MINFO RR. See RFC 1035.
type MINFO struct { type MINFO struct {
Hdr RR_Header Hdr RR_Header
Rmail string `dns:"cdomain-name"` Rmail string `dns:"cdomain-name"`
@ -278,6 +284,7 @@ func (rr *MINFO) String() string {
return rr.Hdr.String() + sprintName(rr.Rmail) + " " + sprintName(rr.Email) return rr.Hdr.String() + sprintName(rr.Rmail) + " " + sprintName(rr.Email)
} }
// MR RR. See RFC 1035.
type MR struct { type MR struct {
Hdr RR_Header Hdr RR_Header
Mr string `dns:"cdomain-name"` Mr string `dns:"cdomain-name"`
@ -287,6 +294,7 @@ func (rr *MR) String() string {
return rr.Hdr.String() + sprintName(rr.Mr) return rr.Hdr.String() + sprintName(rr.Mr)
} }
// MF RR. See RFC 1035.
type MF struct { type MF struct {
Hdr RR_Header Hdr RR_Header
Mf string `dns:"cdomain-name"` Mf string `dns:"cdomain-name"`
@ -296,6 +304,7 @@ func (rr *MF) String() string {
return rr.Hdr.String() + sprintName(rr.Mf) return rr.Hdr.String() + sprintName(rr.Mf)
} }
// MD RR. See RFC 1035.
type MD struct { type MD struct {
Hdr RR_Header Hdr RR_Header
Md string `dns:"cdomain-name"` Md string `dns:"cdomain-name"`
@ -305,6 +314,7 @@ func (rr *MD) String() string {
return rr.Hdr.String() + sprintName(rr.Md) return rr.Hdr.String() + sprintName(rr.Md)
} }
// MX RR. See RFC 1035.
type MX struct { type MX struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -315,6 +325,7 @@ func (rr *MX) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Mx) return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Mx)
} }
// AFSDB RR. See RFC 1183.
type AFSDB struct { type AFSDB struct {
Hdr RR_Header Hdr RR_Header
Subtype uint16 Subtype uint16
@ -325,6 +336,7 @@ func (rr *AFSDB) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Subtype)) + " " + sprintName(rr.Hostname) return rr.Hdr.String() + strconv.Itoa(int(rr.Subtype)) + " " + sprintName(rr.Hostname)
} }
// X25 RR. See RFC 1183, Section 3.1.
type X25 struct { type X25 struct {
Hdr RR_Header Hdr RR_Header
PSDNAddress string PSDNAddress string
@ -334,6 +346,7 @@ func (rr *X25) String() string {
return rr.Hdr.String() + rr.PSDNAddress return rr.Hdr.String() + rr.PSDNAddress
} }
// RT RR. See RFC 1183, Section 3.3.
type RT struct { type RT struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -344,6 +357,7 @@ func (rr *RT) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Host) return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Host)
} }
// NS RR. See RFC 1035.
type NS struct { type NS struct {
Hdr RR_Header Hdr RR_Header
Ns string `dns:"cdomain-name"` Ns string `dns:"cdomain-name"`
@ -353,6 +367,7 @@ func (rr *NS) String() string {
return rr.Hdr.String() + sprintName(rr.Ns) return rr.Hdr.String() + sprintName(rr.Ns)
} }
// PTR RR. See RFC 1035.
type PTR struct { type PTR struct {
Hdr RR_Header Hdr RR_Header
Ptr string `dns:"cdomain-name"` Ptr string `dns:"cdomain-name"`
@ -362,6 +377,7 @@ func (rr *PTR) String() string {
return rr.Hdr.String() + sprintName(rr.Ptr) return rr.Hdr.String() + sprintName(rr.Ptr)
} }
// RP RR. See RFC 1138, Section 2.2.
type RP struct { type RP struct {
Hdr RR_Header Hdr RR_Header
Mbox string `dns:"domain-name"` Mbox string `dns:"domain-name"`
@ -372,6 +388,7 @@ func (rr *RP) String() string {
return rr.Hdr.String() + rr.Mbox + " " + sprintTxt([]string{rr.Txt}) return rr.Hdr.String() + rr.Mbox + " " + sprintTxt([]string{rr.Txt})
} }
// SOA RR. See RFC 1035.
type SOA struct { type SOA struct {
Hdr RR_Header Hdr RR_Header
Ns string `dns:"cdomain-name"` Ns string `dns:"cdomain-name"`
@ -392,6 +409,7 @@ func (rr *SOA) String() string {
" " + strconv.FormatInt(int64(rr.Minttl), 10) " " + strconv.FormatInt(int64(rr.Minttl), 10)
} }
// TXT RR. See RFC 1035.
type TXT struct { type TXT struct {
Hdr RR_Header Hdr RR_Header
Txt []string `dns:"txt"` Txt []string `dns:"txt"`
@ -524,6 +542,7 @@ func nextByte(b []byte, offset int) (byte, int) {
return b[offset+1], 2 return b[offset+1], 2
} }
// SPF RR. See RFC 4408, Section 3.1.1.
type SPF struct { type SPF struct {
Hdr RR_Header Hdr RR_Header
Txt []string `dns:"txt"` Txt []string `dns:"txt"`
@ -531,6 +550,7 @@ type SPF struct {
func (rr *SPF) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } func (rr *SPF) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
// AVC RR. See https://www.iana.org/assignments/dns-parameters/AVC/avc-completed-template.
type AVC struct { type AVC struct {
Hdr RR_Header Hdr RR_Header
Txt []string `dns:"txt"` Txt []string `dns:"txt"`
@ -538,6 +558,7 @@ type AVC struct {
func (rr *AVC) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } func (rr *AVC) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) }
// SRV RR. See RFC 2782.
type SRV struct { type SRV struct {
Hdr RR_Header Hdr RR_Header
Priority uint16 Priority uint16
@ -553,6 +574,7 @@ func (rr *SRV) String() string {
strconv.Itoa(int(rr.Port)) + " " + sprintName(rr.Target) strconv.Itoa(int(rr.Port)) + " " + sprintName(rr.Target)
} }
// NAPTR RR. See RFC 2915.
type NAPTR struct { type NAPTR struct {
Hdr RR_Header Hdr RR_Header
Order uint16 Order uint16
@ -573,7 +595,7 @@ func (rr *NAPTR) String() string {
rr.Replacement rr.Replacement
} }
// The CERT resource record, see RFC 4398. // CERT RR. See RFC 4398.
type CERT struct { type CERT struct {
Hdr RR_Header Hdr RR_Header
Type uint16 Type uint16
@ -599,7 +621,7 @@ func (rr *CERT) String() string {
" " + rr.Certificate " " + rr.Certificate
} }
// The DNAME resource record, see RFC 2672. // DNAME RR. See RFC 2672.
type DNAME struct { type DNAME struct {
Hdr RR_Header Hdr RR_Header
Target string `dns:"domain-name"` Target string `dns:"domain-name"`
@ -609,6 +631,7 @@ func (rr *DNAME) String() string {
return rr.Hdr.String() + sprintName(rr.Target) return rr.Hdr.String() + sprintName(rr.Target)
} }
// A RR. See RFC 1035.
type A struct { type A struct {
Hdr RR_Header Hdr RR_Header
A net.IP `dns:"a"` A net.IP `dns:"a"`
@ -621,6 +644,7 @@ func (rr *A) String() string {
return rr.Hdr.String() + rr.A.String() return rr.Hdr.String() + rr.A.String()
} }
// AAAA RR. See RFC 3596.
type AAAA struct { type AAAA struct {
Hdr RR_Header Hdr RR_Header
AAAA net.IP `dns:"aaaa"` AAAA net.IP `dns:"aaaa"`
@ -633,6 +657,7 @@ func (rr *AAAA) String() string {
return rr.Hdr.String() + rr.AAAA.String() return rr.Hdr.String() + rr.AAAA.String()
} }
// PX RR. See RFC 2163.
type PX struct { type PX struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -644,6 +669,7 @@ func (rr *PX) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Map822) + " " + sprintName(rr.Mapx400) return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Map822) + " " + sprintName(rr.Mapx400)
} }
// GPOS RR. See RFC 1712.
type GPOS struct { type GPOS struct {
Hdr RR_Header Hdr RR_Header
Longitude string Longitude string
@ -655,6 +681,7 @@ func (rr *GPOS) String() string {
return rr.Hdr.String() + rr.Longitude + " " + rr.Latitude + " " + rr.Altitude return rr.Hdr.String() + rr.Longitude + " " + rr.Latitude + " " + rr.Altitude
} }
// LOC RR. See RFC RFC 1876.
type LOC struct { type LOC struct {
Hdr RR_Header Hdr RR_Header
Version uint8 Version uint8
@ -731,11 +758,12 @@ func (rr *LOC) String() string {
return s return s
} }
// SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931. // SIG RR. See RFC 2535. The SIG RR is identical to RRSIG and nowadays only used for SIG(0), See RFC 2931.
type SIG struct { type SIG struct {
RRSIG RRSIG
} }
// RRSIG RR. See RFC 4034 and RFC 3755.
type RRSIG struct { type RRSIG struct {
Hdr RR_Header Hdr RR_Header
TypeCovered uint16 TypeCovered uint16
@ -763,6 +791,7 @@ func (rr *RRSIG) String() string {
return s return s
} }
// NSEC RR. See RFC 4034 and RFC 3755.
type NSEC struct { type NSEC struct {
Hdr RR_Header Hdr RR_Header
NextDomain string `dns:"domain-name"` NextDomain string `dns:"domain-name"`
@ -790,14 +819,13 @@ func (rr *NSEC) len() int {
return l return l
} }
type DLV struct { // DLV RR. See RFC 4431.
DS type DLV struct{ DS }
}
type CDS struct { // CDS RR. See RFC 7344.
DS type CDS struct{ DS }
}
// DS RR. See RFC 4034 and RFC 3658.
type DS struct { type DS struct {
Hdr RR_Header Hdr RR_Header
KeyTag uint16 KeyTag uint16
@ -813,6 +841,7 @@ func (rr *DS) String() string {
" " + strings.ToUpper(rr.Digest) " " + strings.ToUpper(rr.Digest)
} }
// KX RR. See RFC 2230.
type KX struct { type KX struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -824,6 +853,7 @@ func (rr *KX) String() string {
" " + sprintName(rr.Exchanger) " " + sprintName(rr.Exchanger)
} }
// TA RR. See http://www.watson.org/~weiler/INI1999-19.pdf.
type TA struct { type TA struct {
Hdr RR_Header Hdr RR_Header
KeyTag uint16 KeyTag uint16
@ -839,6 +869,7 @@ func (rr *TA) String() string {
" " + strings.ToUpper(rr.Digest) " " + strings.ToUpper(rr.Digest)
} }
// TALINK RR. See https://www.iana.org/assignments/dns-parameters/TALINK/talink-completed-template.
type TALINK struct { type TALINK struct {
Hdr RR_Header Hdr RR_Header
PreviousName string `dns:"domain-name"` PreviousName string `dns:"domain-name"`
@ -850,6 +881,7 @@ func (rr *TALINK) String() string {
sprintName(rr.PreviousName) + " " + sprintName(rr.NextName) sprintName(rr.PreviousName) + " " + sprintName(rr.NextName)
} }
// SSHFP RR. See RFC RFC 4255.
type SSHFP struct { type SSHFP struct {
Hdr RR_Header Hdr RR_Header
Algorithm uint8 Algorithm uint8
@ -863,14 +895,17 @@ func (rr *SSHFP) String() string {
" " + strings.ToUpper(rr.FingerPrint) " " + strings.ToUpper(rr.FingerPrint)
} }
// KEY RR. See RFC RFC 2535.
type KEY struct { type KEY struct {
DNSKEY DNSKEY
} }
// CDNSKEY RR. See RFC 7344.
type CDNSKEY struct { type CDNSKEY struct {
DNSKEY DNSKEY
} }
// DNSKEY RR. See RFC 4034 and RFC 3755.
type DNSKEY struct { type DNSKEY struct {
Hdr RR_Header Hdr RR_Header
Flags uint16 Flags uint16
@ -886,6 +921,7 @@ func (rr *DNSKEY) String() string {
" " + rr.PublicKey " " + rr.PublicKey
} }
// RKEY RR. See https://www.iana.org/assignments/dns-parameters/RKEY/rkey-completed-template.
type RKEY struct { type RKEY struct {
Hdr RR_Header Hdr RR_Header
Flags uint16 Flags uint16
@ -901,6 +937,7 @@ func (rr *RKEY) String() string {
" " + rr.PublicKey " " + rr.PublicKey
} }
// NSAPPTR RR. See RFC 1348.
type NSAPPTR struct { type NSAPPTR struct {
Hdr RR_Header Hdr RR_Header
Ptr string `dns:"domain-name"` Ptr string `dns:"domain-name"`
@ -908,6 +945,7 @@ type NSAPPTR struct {
func (rr *NSAPPTR) String() string { return rr.Hdr.String() + sprintName(rr.Ptr) } func (rr *NSAPPTR) String() string { return rr.Hdr.String() + sprintName(rr.Ptr) }
// NSEC3 RR. See RFC 5155.
type NSEC3 struct { type NSEC3 struct {
Hdr RR_Header Hdr RR_Header
Hash uint8 Hash uint8
@ -946,6 +984,7 @@ func (rr *NSEC3) len() int {
return l return l
} }
// NSEC3PARAM RR. See RFC 5155.
type NSEC3PARAM struct { type NSEC3PARAM struct {
Hdr RR_Header Hdr RR_Header
Hash uint8 Hash uint8
@ -964,6 +1003,7 @@ func (rr *NSEC3PARAM) String() string {
return s return s
} }
// TKEY RR. See RFC 2930.
type TKEY struct { type TKEY struct {
Hdr RR_Header Hdr RR_Header
Algorithm string `dns:"domain-name"` Algorithm string `dns:"domain-name"`
@ -982,7 +1022,7 @@ func (rr *TKEY) String() string {
return "" return ""
} }
// RFC3597 represents an unknown/generic RR. // RFC3597 represents an unknown/generic RR. See RFC 3597.
type RFC3597 struct { type RFC3597 struct {
Hdr RR_Header Hdr RR_Header
Rdata string `dns:"hex"` Rdata string `dns:"hex"`
@ -1006,6 +1046,7 @@ func rfc3597Header(h RR_Header) string {
return s return s
} }
// URI RR. See RFC 7553.
type URI struct { type URI struct {
Hdr RR_Header Hdr RR_Header
Priority uint16 Priority uint16
@ -1018,6 +1059,7 @@ func (rr *URI) String() string {
" " + strconv.Itoa(int(rr.Weight)) + " " + sprintTxtOctet(rr.Target) " " + strconv.Itoa(int(rr.Weight)) + " " + sprintTxtOctet(rr.Target)
} }
// DHCID RR. See RFC 4701.
type DHCID struct { type DHCID struct {
Hdr RR_Header Hdr RR_Header
Digest string `dns:"base64"` Digest string `dns:"base64"`
@ -1025,6 +1067,7 @@ type DHCID struct {
func (rr *DHCID) String() string { return rr.Hdr.String() + rr.Digest } func (rr *DHCID) String() string { return rr.Hdr.String() + rr.Digest }
// TLSA RR. See RFC 6698.
type TLSA struct { type TLSA struct {
Hdr RR_Header Hdr RR_Header
Usage uint8 Usage uint8
@ -1041,6 +1084,7 @@ func (rr *TLSA) String() string {
" " + rr.Certificate " " + rr.Certificate
} }
// SMIMEA RR. See RFC 8162.
type SMIMEA struct { type SMIMEA struct {
Hdr RR_Header Hdr RR_Header
Usage uint8 Usage uint8
@ -1063,6 +1107,7 @@ func (rr *SMIMEA) String() string {
return s return s
} }
// HIP RR. See RFC 8005.
type HIP struct { type HIP struct {
Hdr RR_Header Hdr RR_Header
HitLength uint8 HitLength uint8
@ -1084,6 +1129,7 @@ func (rr *HIP) String() string {
return s return s
} }
// NINFO RR. See https://www.iana.org/assignments/dns-parameters/NINFO/ninfo-completed-template.
type NINFO struct { type NINFO struct {
Hdr RR_Header Hdr RR_Header
ZSData []string `dns:"txt"` ZSData []string `dns:"txt"`
@ -1091,6 +1137,7 @@ type NINFO struct {
func (rr *NINFO) String() string { return rr.Hdr.String() + sprintTxt(rr.ZSData) } func (rr *NINFO) String() string { return rr.Hdr.String() + sprintTxt(rr.ZSData) }
// NID RR. See RFC RFC 6742.
type NID struct { type NID struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -1104,6 +1151,7 @@ func (rr *NID) String() string {
return s return s
} }
// L32 RR, See RFC 6742.
type L32 struct { type L32 struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -1118,6 +1166,7 @@ func (rr *L32) String() string {
" " + rr.Locator32.String() " " + rr.Locator32.String()
} }
// L64 RR, See RFC 6742.
type L64 struct { type L64 struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -1131,6 +1180,7 @@ func (rr *L64) String() string {
return s return s
} }
// LP RR. See RFC 6742.
type LP struct { type LP struct {
Hdr RR_Header Hdr RR_Header
Preference uint16 Preference uint16
@ -1141,6 +1191,7 @@ func (rr *LP) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Fqdn) return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Fqdn)
} }
// EUI48 RR. See RFC 7043.
type EUI48 struct { type EUI48 struct {
Hdr RR_Header Hdr RR_Header
Address uint64 `dns:"uint48"` Address uint64 `dns:"uint48"`
@ -1148,6 +1199,7 @@ type EUI48 struct {
func (rr *EUI48) String() string { return rr.Hdr.String() + euiToString(rr.Address, 48) } func (rr *EUI48) String() string { return rr.Hdr.String() + euiToString(rr.Address, 48) }
// EUI64 RR. See RFC 7043.
type EUI64 struct { type EUI64 struct {
Hdr RR_Header Hdr RR_Header
Address uint64 Address uint64
@ -1155,6 +1207,7 @@ type EUI64 struct {
func (rr *EUI64) String() string { return rr.Hdr.String() + euiToString(rr.Address, 64) } func (rr *EUI64) String() string { return rr.Hdr.String() + euiToString(rr.Address, 64) }
// CAA RR. See RFC 6844.
type CAA struct { type CAA struct {
Hdr RR_Header Hdr RR_Header
Flag uint8 Flag uint8
@ -1166,6 +1219,7 @@ func (rr *CAA) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Flag)) + " " + rr.Tag + " " + sprintTxtOctet(rr.Value) return rr.Hdr.String() + strconv.Itoa(int(rr.Flag)) + " " + rr.Tag + " " + sprintTxtOctet(rr.Value)
} }
// UID RR. Deprecated, IANA-Reserved.
type UID struct { type UID struct {
Hdr RR_Header Hdr RR_Header
Uid uint32 Uid uint32
@ -1173,6 +1227,7 @@ type UID struct {
func (rr *UID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Uid), 10) } func (rr *UID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Uid), 10) }
// GID RR. Deprecated, IANA-Reserved.
type GID struct { type GID struct {
Hdr RR_Header Hdr RR_Header
Gid uint32 Gid uint32
@ -1180,6 +1235,7 @@ type GID struct {
func (rr *GID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Gid), 10) } func (rr *GID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Gid), 10) }
// UINFO RR. Deprecated, IANA-Reserved.
type UINFO struct { type UINFO struct {
Hdr RR_Header Hdr RR_Header
Uinfo string Uinfo string
@ -1187,6 +1243,7 @@ type UINFO struct {
func (rr *UINFO) String() string { return rr.Hdr.String() + sprintTxt([]string{rr.Uinfo}) } func (rr *UINFO) String() string { return rr.Hdr.String() + sprintTxt([]string{rr.Uinfo}) }
// EID RR. See http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt.
type EID struct { type EID struct {
Hdr RR_Header Hdr RR_Header
Endpoint string `dns:"hex"` Endpoint string `dns:"hex"`
@ -1194,6 +1251,7 @@ type EID struct {
func (rr *EID) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Endpoint) } func (rr *EID) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Endpoint) }
// NIMLOC RR. See http://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt.
type NIMLOC struct { type NIMLOC struct {
Hdr RR_Header Hdr RR_Header
Locator string `dns:"hex"` Locator string `dns:"hex"`
@ -1201,6 +1259,7 @@ type NIMLOC struct {
func (rr *NIMLOC) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Locator) } func (rr *NIMLOC) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Locator) }
// OPENPGPKEY RR. See RFC 7929.
type OPENPGPKEY struct { type OPENPGPKEY struct {
Hdr RR_Header Hdr RR_Header
PublicKey string `dns:"base64"` PublicKey string `dns:"base64"`

View File

@ -27,7 +27,7 @@ var skipLen = map[string]struct{}{
var packageHdr = ` var packageHdr = `
// *** DO NOT MODIFY *** // *** DO NOT MODIFY ***
// AUTOGENERATED BY go generate from type_generate.go // AUTOGENERATED BY go generate from types_generate.go
package dns package dns
@ -56,7 +56,6 @@ var TypeToString = map[uint16]string{
`)) `))
var headerFunc = template.Must(template.New("headerFunc").Parse(` var headerFunc = template.Must(template.New("headerFunc").Parse(`
// Header() functions
{{range .}} func (rr *{{.}}) Header() *RR_Header { return &rr.Hdr } {{range .}} func (rr *{{.}}) Header() *RR_Header { return &rr.Hdr }
{{end}} {{end}}

View File

@ -1,5 +1,5 @@
// *** DO NOT MODIFY *** // *** DO NOT MODIFY ***
// AUTOGENERATED BY go generate from type_generate.go // AUTOGENERATED BY go generate from types_generate.go
package dns package dns
@ -163,7 +163,6 @@ var TypeToString = map[uint16]string{
TypeNSAPPTR: "NSAP-PTR", TypeNSAPPTR: "NSAP-PTR",
} }
// Header() functions
func (rr *A) Header() *RR_Header { return &rr.Hdr } func (rr *A) Header() *RR_Header { return &rr.Hdr }
func (rr *AAAA) Header() *RR_Header { return &rr.Hdr } func (rr *AAAA) Header() *RR_Header { return &rr.Hdr }
func (rr *AFSDB) Header() *RR_Header { return &rr.Hdr } func (rr *AFSDB) Header() *RR_Header { return &rr.Hdr }