Skip to content

Commit 9657fe6

Browse files
authored
Cleanup IsRRSet (#1502)
This is a very minor change that simply neatens up this function.
1 parent 02e9e72 commit 9657fe6

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

defaults.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,26 +291,19 @@ func IsFqdn(s string) bool {
291291
return (len(s)-i)%2 != 0
292292
}
293293

294-
// IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181.
295-
// This means the RRs need to have the same type, name, and class. Returns true
296-
// if the RR set is valid, otherwise false.
294+
// IsRRset reports whether a set of RRs is a valid RRset as defined by RFC 2181.
295+
// This means the RRs need to have the same type, name, and class.
297296
func IsRRset(rrset []RR) bool {
298297
if len(rrset) == 0 {
299298
return false
300299
}
301-
if len(rrset) == 1 {
302-
return true
303-
}
304-
rrHeader := rrset[0].Header()
305-
rrType := rrHeader.Rrtype
306-
rrClass := rrHeader.Class
307-
rrName := rrHeader.Name
308300

301+
baseH := rrset[0].Header()
309302
for _, rr := range rrset[1:] {
310-
curRRHeader := rr.Header()
311-
if curRRHeader.Rrtype != rrType || curRRHeader.Class != rrClass || curRRHeader.Name != rrName {
303+
curH := rr.Header()
304+
if curH.Rrtype != baseH.Rrtype || curH.Class != baseH.Class || curH.Name != baseH.Name {
312305
// Mismatch between the records, so this is not a valid rrset for
313-
//signing/verifying
306+
// signing/verifying
314307
return false
315308
}
316309
}

0 commit comments

Comments
 (0)