Remove the RRset type - only add obvious stuff
This commit is contained in:
parent
09ac6c8dc5
commit
19f8d266b5
|
@ -16,8 +16,9 @@ Features:
|
|||
* UDP/TCP queries, IPv4 and IPv6;
|
||||
* RFC 1035 zone file parsing;
|
||||
* Fast:
|
||||
* reply speed around 30K qps (Faster hardware -> more qps);
|
||||
* Parsing RRs (zone files) with 30K RR/s;
|
||||
* reply speed around 35K qps (Faster hardware -> more qps);
|
||||
* Parsing RRs (zone files) with 30K RR/s, that 5M records
|
||||
in about 170 seconds;
|
||||
* This is expected to be optimized further.
|
||||
* Client and server side programming (mimicking the http package);
|
||||
* Asynchronous queries for client and server;
|
||||
|
|
68
dns.go
68
dns.go
|
@ -99,74 +99,6 @@ type RR interface {
|
|||
Len() int
|
||||
}
|
||||
|
||||
// An RRset is a slice of RRs.
|
||||
type RRset []RR
|
||||
|
||||
func NewRRset() RRset {
|
||||
s := make([]RR, 0)
|
||||
return s
|
||||
}
|
||||
|
||||
func (s RRset) String() string {
|
||||
str := ""
|
||||
for _, r := range s {
|
||||
str += r.String() + "\n"
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
// Pop removes the last pushed RR from the RRset. Returns nil
|
||||
// when there is nothing to remove.
|
||||
func (s *RRset) Pop() RR {
|
||||
if len(*s) == 0 {
|
||||
return nil
|
||||
}
|
||||
// Pop and remove the entry
|
||||
r := (*s)[len(*s)-1]
|
||||
*s = (*s)[:len(*s)-1]
|
||||
return r
|
||||
}
|
||||
|
||||
// Push pushes the RR r to the RRset.
|
||||
func (s *RRset) Push(r RR) bool {
|
||||
if len(*s) == 0 {
|
||||
*s = append(*s, r)
|
||||
return true
|
||||
}
|
||||
// For RRSIGs this is not true (RFC???)
|
||||
// Don't make it a failure if this happens
|
||||
// if (*s)[0].Header().Ttl != r.Header().Ttl {
|
||||
// return false
|
||||
// }
|
||||
if (*s)[0].Header().Name != r.Header().Name {
|
||||
return false
|
||||
}
|
||||
if (*s)[0].Header().Class != r.Header().Class {
|
||||
return false
|
||||
}
|
||||
*s = append(*s, r)
|
||||
return true
|
||||
}
|
||||
|
||||
// Ok checks if the RRSet is RFC 2181 compliant.
|
||||
func (s RRset) Ok() bool {
|
||||
ttl := s[0].Header().Ttl
|
||||
name := s[0].Header().Name
|
||||
class := s[0].Header().Class
|
||||
for _, rr := range s[1:] {
|
||||
if rr.Header().Ttl != ttl {
|
||||
return false
|
||||
}
|
||||
if rr.Header().Name != name {
|
||||
return false
|
||||
}
|
||||
if rr.Header().Class != class {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Exchange is used in communicating with the resolver.
|
||||
type Exchange struct {
|
||||
Request *Msg // The question sent.
|
||||
|
|
|
@ -186,7 +186,7 @@ func (k *RR_DNSKEY) ToDS(h int) *RR_DS {
|
|||
// otherwise false.
|
||||
// The signature data in the RRSIG is filled by this method.
|
||||
// There is no check if RRSet is a proper (RFC 2181) RRSet.
|
||||
func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) error {
|
||||
func (s *RR_RRSIG) Sign(k PrivateKey, rrset []RR) error {
|
||||
if k == nil {
|
||||
return ErrPrivKey
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ func (s *RR_RRSIG) Sign(k PrivateKey, rrset RRset) error {
|
|||
|
||||
// Verify validates an RRSet with the signature and key. This is only the
|
||||
// cryptographic test, the signature validity period most be checked separately.
|
||||
func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset RRset) error {
|
||||
func (s *RR_RRSIG) Verify(k *RR_DNSKEY, rrset []RR) error {
|
||||
// Frist the easy checks
|
||||
if s.KeyTag != k.KeyTag() {
|
||||
return ErrKey
|
||||
|
@ -483,7 +483,7 @@ func (p wireSlice) Less(i, j int) bool {
|
|||
func (p wireSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
// Return the raw signature data.
|
||||
func rawSignatureData(rrset RRset, s *RR_RRSIG) (buf []byte) {
|
||||
func rawSignatureData(rrset []RR, s *RR_RRSIG) (buf []byte) {
|
||||
wires := make(wireSlice, len(rrset))
|
||||
for i, r := range rrset {
|
||||
h := r.Header()
|
||||
|
|
Loading…
Reference in New Issue