vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2018-01-16 13:20:59 +00:00
parent 8e83fb6fb9
commit 7d3a17725d
4878 changed files with 1974213 additions and 201199 deletions
+11 -7
View File
@@ -13,7 +13,7 @@ import (
"errors"
)
// Packet formats
// Message formats
// A Type is a type of DNS request and response.
type Type uint16
@@ -789,6 +789,12 @@ func (m *Message) Unpack(msg []byte) error {
// Pack packs a full Message.
func (m *Message) Pack() ([]byte, error) {
return m.AppendPack(make([]byte, 0, packStartingCap))
}
// AppendPack is like Pack but appends the full Message to b and returns the
// extended buffer.
func (m *Message) AppendPack(b []byte) ([]byte, error) {
// Validate the lengths. It is very unlikely that anyone will try to
// pack more than 65535 of any particular type, but it is possible and
// we should fail gracefully.
@@ -813,17 +819,15 @@ func (m *Message) Pack() ([]byte, error) {
h.authorities = uint16(len(m.Authorities))
h.additionals = uint16(len(m.Additionals))
msg := make([]byte, 0, packStartingCap)
msg = h.pack(msg)
msg := h.pack(b)
// RFC 1035 allows (but does not require) compression for packing. RFC
// 1035 requires unpacking implementations to support compression, so
// unconditionally enabling it is fine.
//
// DNS lookups are typically done over UDP, and RFC 1035 states that UDP
// DNS packets can be a maximum of 512 bytes long. Without compression,
// many DNS response packets are over this limit, so enabling
// DNS messages can be a maximum of 512 bytes long. Without compression,
// many DNS response messages are over this limit, so enabling
// compression will help ensure compliance.
compression := map[string]int{}
@@ -1203,7 +1207,7 @@ func (b *Builder) AAAAResource(h ResourceHeader, r AAAAResource) error {
return nil
}
// Finish ends message building and generates a binary packet.
// Finish ends message building and generates a binary message.
func (b *Builder) Finish() ([]byte, error) {
if b.section < sectionHeader {
return nil, ErrNotStarted
+25
View File
@@ -852,6 +852,31 @@ func smallTestMsg() Message {
}
}
func BenchmarkPack(b *testing.B) {
msg := largeTestMsg()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := msg.Pack(); err != nil {
b.Fatal(err)
}
}
}
func BenchmarkAppendPack(b *testing.B) {
msg := largeTestMsg()
buf := make([]byte, 0, packStartingCap)
b.ReportAllocs()
for i := 0; i < b.N; i++ {
if _, err := msg.AppendPack(buf[:0]); err != nil {
b.Fatal(err)
}
}
}
func largeTestMsg() Message {
name := mustNewName("foo.bar.example.com.")
return Message{