From 9657fe66adcdc74d54c8ec231db5163748ab251b Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Mon, 6 Nov 2023 16:54:27 +1030 Subject: [PATCH] Cleanup IsRRSet (#1502) This is a very minor change that simply neatens up this function. --- defaults.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/defaults.go b/defaults.go index 068a99013..02d9199a4 100644 --- a/defaults.go +++ b/defaults.go @@ -291,26 +291,19 @@ func IsFqdn(s string) bool { return (len(s)-i)%2 != 0 } -// IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181. -// This means the RRs need to have the same type, name, and class. Returns true -// if the RR set is valid, otherwise false. +// IsRRset reports whether a set of RRs is a valid RRset as defined by RFC 2181. +// This means the RRs need to have the same type, name, and class. func IsRRset(rrset []RR) bool { if len(rrset) == 0 { return false } - if len(rrset) == 1 { - return true - } - rrHeader := rrset[0].Header() - rrType := rrHeader.Rrtype - rrClass := rrHeader.Class - rrName := rrHeader.Name + baseH := rrset[0].Header() for _, rr := range rrset[1:] { - curRRHeader := rr.Header() - if curRRHeader.Rrtype != rrType || curRRHeader.Class != rrClass || curRRHeader.Name != rrName { + curH := rr.Header() + if curH.Rrtype != baseH.Rrtype || curH.Class != baseH.Class || curH.Name != baseH.Name { // Mismatch between the records, so this is not a valid rrset for - //signing/verifying + // signing/verifying return false } }