Merge branch 'master' of github.com:miekg/dns

This commit is contained in:
Miek Gieben 2014-01-27 14:32:07 +00:00
commit 9c0ff1489b
5 changed files with 13 additions and 9 deletions

2
dns.go
View File

@ -18,7 +18,7 @@
// //
// r := new(dns.MX) // r := new(dns.MX)
// r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, Class: dns.ClassINET, Ttl: 3600} // 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." // r.Mx = "mx.miek.nl."
// //
// Or directly from a string: // Or directly from a string:

View File

@ -201,7 +201,7 @@ func (k *DNSKEY) ToDS(h int) *DS {
} }
// Sign signs an RRSet. The signature needs to be filled in with // 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, // The rest is copied from the RRset. Sign returns true when the signing went OK,
// otherwise false. // otherwise false.
// There is no check if RRSet is a proper (RFC 2181) RRSet. // 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.Rrtype = TypeRRSIG
rr.Hdr.Name = rrset[0].Header().Name rr.Hdr.Name = rrset[0].Header().Name
rr.Hdr.Class = rrset[0].Header().Class 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.TypeCovered = rrset[0].Header().Rrtype rr.TypeCovered = rrset[0].Header().Rrtype
rr.Labels = uint8(CountLabel(rrset[0].Header().Name)) rr.Labels = uint8(CountLabel(rrset[0].Header().Name))

View File

@ -20,10 +20,10 @@ func (k *DNSKEY) NewPrivateKey(s string) (PrivateKey, error) {
return k.ReadPrivateKey(strings.NewReader(s), "") 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. // only used in error reporting.
// The public key must be // 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) { func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (PrivateKey, error) {
m, e := parseKey(q, file) m, e := parseKey(q, file)
if m == nil { if m == nil {

View File

@ -110,7 +110,7 @@ func Split(s string) []int {
if s == "." { if s == "." {
return nil return nil
} }
idx := []int{0} idx := make([]int, 1, 3)
off := 0 off := 0
end := false end := false

8
msg.go
View File

@ -1602,10 +1602,12 @@ func Copy(r RR) RR {
// Put the parts of the name in the compression map. // Put the parts of the name in the compression map.
func compressionLenHelper(c map[string]int, s string) { func compressionLenHelper(c map[string]int, s string) {
pref := "" pref := ""
lbs := SplitDomainName(s) lbs := Split(s)
for j := len(lbs) - 1; j >= 0; j-- { for j := len(lbs) - 1; j >= 0; j-- {
c[lbs[j]+"."+pref] = 1 + len(pref) + len(lbs[j]) l := 1 + len(pref)
pref = lbs[j] + "." + pref pref = s[lbs[j]:]
l += len(pref)
c[pref] = l
} }
} }