Update miekg/dns to v1.0.5

This commit is contained in:
Frank Denis 2018-04-02 00:10:55 +02:00
parent e210fc537e
commit b71e04c64e
23 changed files with 293 additions and 2861 deletions

69
vendor/github.com/miekg/dns/msg.go generated vendored
View file

@ -595,6 +595,13 @@ func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) {
if err != nil {
return nil, len(msg), err
}
return UnpackRRWithHeader(h, msg, off)
}
// UnpackRRWithHeader unpacks the record type specific payload given an existing
// RR_Header.
func UnpackRRWithHeader(h RR_Header, msg []byte, off int) (rr RR, off1 int, err error) {
end := off + int(h.Rdlength)
if fn, known := typeToUnpack[h.Rrtype]; !known {
@ -926,49 +933,65 @@ func compressedLen(dns *Msg, compress bool) int {
l += r.len()
compressionLenHelper(compression, r.Name)
}
l += compressionLenSlice(compression, dns.Answer)
l += compressionLenSlice(compression, dns.Ns)
l += compressionLenSlice(compression, dns.Extra)
} else {
for _, r := range dns.Question {
l += compressionLenSlice(l, compression, dns.Answer)
l += compressionLenSlice(l, compression, dns.Ns)
l += compressionLenSlice(l, compression, dns.Extra)
return l
}
for _, r := range dns.Question {
l += r.len()
}
for _, r := range dns.Answer {
if r != nil {
l += r.len()
}
for _, r := range dns.Answer {
if r != nil {
l += r.len()
}
}
for _, r := range dns.Ns {
if r != nil {
l += r.len()
}
}
for _, r := range dns.Extra {
if r != nil {
l += r.len()
}
}
for _, r := range dns.Ns {
if r != nil {
l += r.len()
}
}
for _, r := range dns.Extra {
if r != nil {
l += r.len()
}
}
return l
}
func compressionLenSlice(c map[string]int, rs []RR) int {
func compressionLenSlice(len int, c map[string]int, rs []RR) int {
var l int
for _, r := range rs {
if r == nil {
continue
}
l += r.len()
// track this length, and the global length in len, while taking compression into account for both.
x := r.len()
l += x
len += x
k, ok := compressionLenSearch(c, r.Header().Name)
if ok {
l += 1 - k
len += 1 - k
}
compressionLenHelper(c, r.Header().Name)
if len < maxCompressionOffset {
compressionLenHelper(c, r.Header().Name)
}
k, ok = compressionLenSearchType(c, r)
if ok {
l += 1 - k
len += 1 - k
}
if len < maxCompressionOffset {
compressionLenHelperType(c, r)
}
compressionLenHelperType(c, r)
}
return l
}