...

Source file src/github.com/miekg/dns/duplicate.go

Documentation: github.com/miekg/dns

     1  package dns
     2  
     3  //go:generate go run duplicate_generate.go
     4  
     5  // IsDuplicate checks of r1 and r2 are duplicates of each other, excluding the TTL.
     6  // So this means the header data is equal *and* the RDATA is the same. Returns true
     7  // if so, otherwise false. It's a protocol violation to have identical RRs in a message.
     8  func IsDuplicate(r1, r2 RR) bool {
     9  	// Check whether the record header is identical.
    10  	if !r1.Header().isDuplicate(r2.Header()) {
    11  		return false
    12  	}
    13  
    14  	// Check whether the RDATA is identical.
    15  	return r1.isDuplicate(r2)
    16  }
    17  
    18  func (r1 *RR_Header) isDuplicate(_r2 RR) bool {
    19  	r2, ok := _r2.(*RR_Header)
    20  	if !ok {
    21  		return false
    22  	}
    23  	if r1.Class != r2.Class {
    24  		return false
    25  	}
    26  	if r1.Rrtype != r2.Rrtype {
    27  		return false
    28  	}
    29  	if !isDuplicateName(r1.Name, r2.Name) {
    30  		return false
    31  	}
    32  	// ignore TTL
    33  	return true
    34  }
    35  
    36  // isDuplicateName checks if the domain names s1 and s2 are equal.
    37  func isDuplicateName(s1, s2 string) bool { return equal(s1, s2) }
    38  

View as plain text