diff --git a/dns.go b/dns.go index b70ba3e4..4a5a6967 100644 --- a/dns.go +++ b/dns.go @@ -18,7 +18,7 @@ // // r := new(dns.MX) // r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 3600} -// r.Pref = 10 +// r.Preference = 10 // r.Mx = "mx.miek.nl." // // Or directly from a string: diff --git a/dnssec.go b/dnssec.go index 83a018eb..2dd77fd1 100644 --- a/dnssec.go +++ b/dnssec.go @@ -201,7 +201,7 @@ func (k *DNSKEY) ToDS(h int) *DS { } // Sign signs an RRSet. The signature needs to be filled in with -// the values: Inception, Expiration, KeyTag, SignerName and Algorithm. +// the values: OrigTtl, Inception, Expiration, KeyTag, SignerName and Algorithm. // The rest is copied from the RRset. Sign returns true when the signing went OK, // otherwise false. // There is no check if RRSet is a proper (RFC 2181) RRSet. @@ -217,7 +217,9 @@ func (rr *RRSIG) Sign(k PrivateKey, rrset []RR) error { rr.Hdr.Rrtype = TypeRRSIG rr.Hdr.Name = rrset[0].Header().Name rr.Hdr.Class = rrset[0].Header().Class - rr.OrigTtl = rrset[0].Header().Ttl + if rr.OrigTtl == 0 { // If set don't override + rr.OrigTtl = rrset[0].Header().Ttl + } rr.TypeCovered = rrset[0].Header().Rrtype rr.TypeCovered = rrset[0].Header().Rrtype rr.Labels = uint8(CountLabel(rrset[0].Header().Name)) diff --git a/kscan.go b/kscan.go index 22492c27..6c477b80 100644 --- a/kscan.go +++ b/kscan.go @@ -20,10 +20,10 @@ func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) { return k.ReadPrivateKey(strings.NewReader(s), "") } -// NewPrivateKey reads a private key from the io.Reader q. The string file is +// ReadPrivateKey reads a private key from the io.Reader q. The string file is // only used in error reporting. // The public key must be -// known, because some cryptographics algorithms embed the public inside the privatekey. +// known, because some cryptographic algorithms embed the public inside the privatekey. func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) { m, e := parseKey(q, file) if m == nil { diff --git a/labels.go b/labels.go index ff25453f..8d93228d 100644 --- a/labels.go +++ b/labels.go @@ -110,7 +110,7 @@ func Split(s string) []int { if s == "." { return nil } - idx := []int{0} + idx := make([]int, 1, 3) off := 0 end := false diff --git a/msg.go b/msg.go index 98978a2f..45024ce1 100644 --- a/msg.go +++ b/msg.go @@ -1602,10 +1602,12 @@ func Copy(r RR) RR { // Put the parts of the name in the compression map. func compressionLenHelper(c map[string]int, s string) { pref := "" - lbs := SplitDomainName(s) + lbs := Split(s) for j := len(lbs) - 1; j >= 0; j-- { - c[lbs[j]+"."+pref] = 1 + len(pref) + len(lbs[j]) - pref = lbs[j] + "." + pref + l := 1 + len(pref) + pref = s[lbs[j]:] + l += len(pref) + c[pref] = l } }