From f5437632f486b7d0a0a181c58f113c86d032b02c Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 24 Apr 2017 20:11:36 -0400 Subject: Upgrading server dependancies (#6215) --- vendor/github.com/miekg/dns/README.md | 2 +- vendor/github.com/miekg/dns/dnssec.go | 2 +- vendor/github.com/miekg/dns/labels.go | 3 + vendor/github.com/miekg/dns/labels_test.go | 3 + vendor/github.com/miekg/dns/msg.go | 20 ++++- vendor/github.com/miekg/dns/msg_test.go | 124 ++++++++++++++++++++++++++++ vendor/github.com/miekg/dns/nsecx.go | 74 +++++++---------- vendor/github.com/miekg/dns/nsecx_test.go | 126 ++++++++++++++++++++++++++--- vendor/github.com/miekg/dns/parse_test.go | 18 +++++ vendor/github.com/miekg/dns/scan_rr.go | 13 +++ vendor/github.com/miekg/dns/types.go | 8 ++ vendor/github.com/miekg/dns/zcompress.go | 122 ++++++++++++++-------------- vendor/github.com/miekg/dns/zmsg.go | 32 ++++++++ vendor/github.com/miekg/dns/ztypes.go | 15 ++++ 14 files changed, 443 insertions(+), 119 deletions(-) create mode 100644 vendor/github.com/miekg/dns/msg_test.go (limited to 'vendor/github.com/miekg') diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md index e8b0ec6a5..cd5c1948e 100644 --- a/vendor/github.com/miekg/dns/README.md +++ b/vendor/github.com/miekg/dns/README.md @@ -19,7 +19,7 @@ two versions of Go, currently: 1.6 and 1.7. * KISS; * Fast; -* Small API, if its easy to code in Go, don't make a function for it. +* Small API. If it's easy to code in Go, don't make a function for it. # Users diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go index 07262011e..3bd55388d 100644 --- a/vendor/github.com/miekg/dns/dnssec.go +++ b/vendor/github.com/miekg/dns/dnssec.go @@ -515,7 +515,7 @@ func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey { } // Remainder expo += uint64(keybuf[keyoff]) - if expo > 2<<31 { + if expo > (2<<31)+1 { // Larger expo than supported. // println("dns: F5 primes (or larger) are not supported") return nil diff --git a/vendor/github.com/miekg/dns/labels.go b/vendor/github.com/miekg/dns/labels.go index fca5c7dd2..9538d9c3a 100644 --- a/vendor/github.com/miekg/dns/labels.go +++ b/vendor/github.com/miekg/dns/labels.go @@ -1,5 +1,7 @@ package dns +import "strings" + // Holds a bunch of helper functions for dealing with labels. // SplitDomainName splits a name string into it's labels. @@ -50,6 +52,7 @@ func SplitDomainName(s string) (labels []string) { // // s1 and s2 must be syntactically valid domain names. func CompareDomainName(s1, s2 string) (n int) { + s1, s2 = strings.ToLower(s1), strings.ToLower(s2) s1 = Fqdn(s1) s2 = Fqdn(s2) l1 := Split(s1) diff --git a/vendor/github.com/miekg/dns/labels_test.go b/vendor/github.com/miekg/dns/labels_test.go index 536757d52..9875d6cd9 100644 --- a/vendor/github.com/miekg/dns/labels_test.go +++ b/vendor/github.com/miekg/dns/labels_test.go @@ -33,6 +33,9 @@ func TestCompareDomainName(t *testing.T) { if CompareDomainName(".", ".") != 0 { t.Errorf("%s with %s should be %d", ".", ".", 0) } + if CompareDomainName("test.com.", "TEST.COM.") != 2 { + t.Errorf("test.com. and TEST.COM. should be an exact match") + } } func TestSplit(t *testing.T) { diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go index 57262a10c..a348f7c9d 100644 --- a/vendor/github.com/miekg/dns/msg.go +++ b/vendor/github.com/miekg/dns/msg.go @@ -14,13 +14,17 @@ package dns import ( crand "crypto/rand" "encoding/binary" + "fmt" "math/big" "math/rand" "strconv" "sync" ) -const maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer +const ( + maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer + maxDomainNameWireOctets = 255 // See RFC 1035 section 2.3.4 +) var ( ErrAlg error = &Error{err: "bad algorithm"} // ErrAlg indicates an error with the (DNSSEC) algorithm. @@ -33,6 +37,7 @@ var ( ErrKeyAlg error = &Error{err: "bad key algorithm"} // ErrKeyAlg indicates that the algorithm in the key is not valid. ErrKey error = &Error{err: "bad key"} ErrKeySize error = &Error{err: "bad key size"} + ErrLongDomain error = &Error{err: fmt.Sprintf("domain name exceeded %d wire-format octets", maxDomainNameWireOctets)} ErrNoSig error = &Error{err: "no signature found"} ErrPrivKey error = &Error{err: "bad private key"} ErrRcode error = &Error{err: "bad rcode"} @@ -329,6 +334,7 @@ func UnpackDomainName(msg []byte, off int) (string, int, error) { s := make([]byte, 0, 64) off1 := 0 lenmsg := len(msg) + maxLen := maxDomainNameWireOctets ptr := 0 // number of pointers followed Loop: for { @@ -353,8 +359,10 @@ Loop: fallthrough case '"', '\\': s = append(s, '\\', b) + // presentation-format \X escapes add an extra byte + maxLen += 1 default: - if b < 32 || b >= 127 { // unprintable use \DDD + if b < 32 || b >= 127 { // unprintable, use \DDD var buf [3]byte bufs := strconv.AppendInt(buf[:0], int64(b), 10) s = append(s, '\\') @@ -364,6 +372,8 @@ Loop: for _, r := range bufs { s = append(s, r) } + // presentation-format \DDD escapes add 3 extra bytes + maxLen += 3 } else { s = append(s, b) } @@ -388,6 +398,9 @@ Loop: if ptr++; ptr > 10 { return "", lenmsg, &Error{err: "too many compression pointers"} } + // pointer should guarantee that it advances and points forwards at least + // but the condition on previous three lines guarantees that it's + // at least loop-free off = (c^0xC0)<<8 | int(c1) default: // 0x80 and 0x40 are reserved @@ -399,6 +412,9 @@ Loop: } if len(s) == 0 { s = []byte(".") + } else if len(s) >= maxLen { + // error if the name is too long, but don't throw it away + return string(s), lenmsg, ErrLongDomain } return string(s), off1, nil } diff --git a/vendor/github.com/miekg/dns/msg_test.go b/vendor/github.com/miekg/dns/msg_test.go new file mode 100644 index 000000000..2dbef6260 --- /dev/null +++ b/vendor/github.com/miekg/dns/msg_test.go @@ -0,0 +1,124 @@ +package dns + +import ( + "fmt" + "regexp" + "strconv" + "strings" + "testing" +) + +const ( + maxPrintableLabel = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789x" + tooLongLabel = maxPrintableLabel + "x" +) + +var ( + longDomain = maxPrintableLabel[:53] + strings.TrimSuffix( + strings.Join([]string{".", ".", ".", ".", "."}, maxPrintableLabel[:49]), ".") + reChar = regexp.MustCompile(`.`) + i = -1 + maxUnprintableLabel = reChar.ReplaceAllStringFunc(maxPrintableLabel, func(ch string) string { + if i++; i >= 32 { + i = 0 + } + return fmt.Sprintf("\\%03d", i) + }) +) + +func TestUnpackDomainName(t *testing.T) { + var cases = []struct { + label string + input string + expectedOutput string + expectedError string + }{ + {"empty domain", + "\x00", + ".", + ""}, + {"long label", + string(63) + maxPrintableLabel + "\x00", + maxPrintableLabel + ".", + ""}, + {"unprintable label", + string(63) + regexp.MustCompile(`\\[0-9]+`).ReplaceAllStringFunc(maxUnprintableLabel, + func(escape string) string { + n, _ := strconv.ParseInt(escape[1:], 10, 8) + return string(n) + }) + "\x00", + maxUnprintableLabel + ".", + ""}, + {"long domain", + string(53) + strings.Replace(longDomain, ".", string(49), -1) + "\x00", + longDomain + ".", + ""}, + {"compression pointer", + // an unrealistic but functional test referencing an offset _inside_ a label + "\x03foo" + "\x05\x03com\x00" + "\x07example" + "\xC0\x05", + "foo.\\003com\\000.example.com.", + ""}, + + {"too long domain", + string(54) + "x" + strings.Replace(longDomain, ".", string(49), -1) + "\x00", + "x" + longDomain + ".", + ErrLongDomain.Error()}, + {"too long by pointer", + // a matryoshka doll name to get over 255 octets after expansion via internal pointers + string([]byte{ + // 11 length values, first to last + 40, 37, 34, 31, 28, 25, 22, 19, 16, 13, 0, + // 12 filler values + 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, + // 10 pointers, last to first + 192, 10, 192, 9, 192, 8, 192, 7, 192, 6, 192, 5, 192, 4, 192, 3, 192, 2, 192, 1, + }), + "", + ErrLongDomain.Error()}, + {"long by pointer", + // a matryoshka doll name _not_ exceeding 255 octets after expansion + string([]byte{ + // 11 length values, first to last + 37, 34, 31, 28, 25, 22, 19, 16, 13, 10, 0, + // 9 filler values + 120, 120, 120, 120, 120, 120, 120, 120, 120, + // 10 pointers, last to first + 192, 10, 192, 9, 192, 8, 192, 7, 192, 6, 192, 5, 192, 4, 192, 3, 192, 2, 192, 1, + }), + "" + + (`\"\031\028\025\022\019\016\013\010\000xxxxxxxxx` + + `\192\010\192\009\192\008\192\007\192\006\192\005\192\004\192\003\192\002.`) + + (`\031\028\025\022\019\016\013\010\000xxxxxxxxx` + + `\192\010\192\009\192\008\192\007\192\006\192\005\192\004\192\003.`) + + (`\028\025\022\019\016\013\010\000xxxxxxxxx` + + `\192\010\192\009\192\008\192\007\192\006\192\005\192\004.`) + + (`\025\022\019\016\013\010\000xxxxxxxxx` + + `\192\010\192\009\192\008\192\007\192\006\192\005.`) + + `\022\019\016\013\010\000xxxxxxxxx\192\010\192\009\192\008\192\007\192\006.` + + `\019\016\013\010\000xxxxxxxxx\192\010\192\009\192\008\192\007.` + + `\016\013\010\000xxxxxxxxx\192\010\192\009\192\008.` + + `\013\010\000xxxxxxxxx\192\010\192\009.` + + `\010\000xxxxxxxxx\192\010.` + + `\000xxxxxxxxx.`, + ""}, + {"truncated name", "\x07example\x03", "", "dns: buffer size too small"}, + {"non-absolute name", "\x07example\x03com", "", "dns: buffer size too small"}, + {"compression pointer cycle", + "\x03foo" + "\x03bar" + "\x07example" + "\xC0\x04", + "", + "dns: too many compression pointers"}, + {"reserved compression pointer 0b10", "\x07example\x80", "", "dns: bad rdata"}, + {"reserved compression pointer 0b01", "\x07example\x40", "", "dns: bad rdata"}, + } + for _, test := range cases { + output, idx, err := UnpackDomainName([]byte(test.input), 0) + if test.expectedOutput != "" && output != test.expectedOutput { + t.Errorf("%s: expected %s, got %s", test.label, test.expectedOutput, output) + } + if test.expectedError == "" && err != nil { + t.Errorf("%s: expected no error, got %d %v", test.label, idx, err) + } else if test.expectedError != "" && (err == nil || err.Error() != test.expectedError) { + t.Errorf("%s: expected error %s, got %d %v", test.label, test.expectedError, idx, err) + } + } +} diff --git a/vendor/github.com/miekg/dns/nsecx.go b/vendor/github.com/miekg/dns/nsecx.go index 51ce7f8b1..9b908c447 100644 --- a/vendor/github.com/miekg/dns/nsecx.go +++ b/vendor/github.com/miekg/dns/nsecx.go @@ -48,62 +48,50 @@ func HashName(label string, ha uint8, iter uint16, salt string) string { return toBase32(nsec3) } -// Denialer is an interface that should be implemented by types that are used to denial -// answers in DNSSEC. -type Denialer interface { - // Cover will check if the (unhashed) name is being covered by this NSEC or NSEC3. - Cover(name string) bool - // Match will check if the ownername matches the (unhashed) name for this NSEC3 or NSEC3. - Match(name string) bool -} - -// Cover implements the Denialer interface. -func (rr *NSEC) Cover(name string) bool { - return true -} - -// Match implements the Denialer interface. -func (rr *NSEC) Match(name string) bool { - return true -} - -// Cover implements the Denialer interface. +// Cover returns true if a name is covered by the NSEC3 record func (rr *NSEC3) Cover(name string) bool { - // FIXME(miek): check if the zones match - // FIXME(miek): check if we're not dealing with parent nsec3 - hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt) - labels := Split(rr.Hdr.Name) - if len(labels) < 2 { + nameHash := HashName(name, rr.Hash, rr.Iterations, rr.Salt) + owner := strings.ToUpper(rr.Hdr.Name) + labelIndices := Split(owner) + if len(labelIndices) < 2 { return false } - hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the dot - if hash == rr.NextDomain { - return false // empty interval - } - if hash > rr.NextDomain { // last name, points to apex - // hname > hash - // hname > rr.NextDomain - // TODO(miek) + ownerHash := owner[:labelIndices[1]-1] + ownerZone := owner[labelIndices[1]:] + if !IsSubDomain(ownerZone, strings.ToUpper(name)) { // name is outside owner zone + return false } - if hname <= hash { + + nextHash := rr.NextDomain + if ownerHash == nextHash { // empty interval return false } - if hname >= rr.NextDomain { + if ownerHash > nextHash { // end of zone + if nameHash > ownerHash { // covered since there is nothing after ownerHash + return true + } + return nameHash < nextHash // if nameHash is before beginning of zone it is covered + } + if nameHash < ownerHash { // nameHash is before ownerHash, not covered return false } - return true + return nameHash < nextHash // if nameHash is before nextHash is it covered (between ownerHash and nextHash) } -// Match implements the Denialer interface. +// Match returns true if a name matches the NSEC3 record func (rr *NSEC3) Match(name string) bool { - // FIXME(miek): Check if we are in the same zone - hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt) - labels := Split(rr.Hdr.Name) - if len(labels) < 2 { + nameHash := HashName(name, rr.Hash, rr.Iterations, rr.Salt) + owner := strings.ToUpper(rr.Hdr.Name) + labelIndices := Split(owner) + if len(labelIndices) < 2 { + return false + } + ownerHash := owner[:labelIndices[1]-1] + ownerZone := owner[labelIndices[1]:] + if !IsSubDomain(ownerZone, strings.ToUpper(name)) { // name is outside owner zone return false } - hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the . - if hash == hname { + if ownerHash == nameHash { return true } return false diff --git a/vendor/github.com/miekg/dns/nsecx_test.go b/vendor/github.com/miekg/dns/nsecx_test.go index 93e0c63fc..8d5f71797 100644 --- a/vendor/github.com/miekg/dns/nsecx_test.go +++ b/vendor/github.com/miekg/dns/nsecx_test.go @@ -1,8 +1,6 @@ package dns -import ( - "testing" -) +import "testing" func TestPackNsec3(t *testing.T) { nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD") @@ -17,13 +15,119 @@ func TestPackNsec3(t *testing.T) { } func TestNsec3(t *testing.T) { - // examples taken from .nl - nsec3, _ := NewRR("39p91242oslggest5e6a7cci4iaeqvnk.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6 NS DS RRSIG") - if !nsec3.(*NSEC3).Cover("snasajsksasasa.nl.") { // 39p94jrinub66hnpem8qdpstrec86pg3 - t.Error("39p94jrinub66hnpem8qdpstrec86pg3. should be covered by 39p91242oslggest5e6a7cci4iaeqvnk.nl. - 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6") - } - nsec3, _ = NewRR("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM") - if !nsec3.(*NSEC3).Match("nl.") { // sk4e8fj94u78smusb40o1n0oltbblu2r.nl. - t.Error("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.") + nsec3, _ := NewRR("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM") + if !nsec3.(*NSEC3).Match("nl.") { // name hash = sk4e8fj94u78smusb40o1n0oltbblu2r + t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.") + } + if !nsec3.(*NSEC3).Match("NL.") { // name hash = sk4e8fj94u78smusb40o1n0oltbblu2r + t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.NL. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.") + } + if nsec3.(*NSEC3).Match("com.") { // + t.Fatal("com. is not in the zone nl.") + } + if nsec3.(*NSEC3).Match("test.nl.") { // name hash = gd0ptr5bnfpimpu2d3v6gd4n0bai7s0q + t.Fatal("gd0ptr5bnfpimpu2d3v6gd4n0bai7s0q.nl. should not match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.") + } + nsec3, _ = NewRR("nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM") + if nsec3.(*NSEC3).Match("nl.") { + t.Fatal("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should not match a record without a owner hash") + } + + for _, tc := range []struct { + rr *NSEC3 + name string + covers bool + }{ + // positive tests + { // name hash between owner hash and next hash + rr: &NSEC3{ + Hdr: RR_Header{Name: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP.com."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "PT3RON8N7PM3A0OE989IB84OOSADP7O8", + }, + name: "bsd.com.", + covers: true, + }, + { // end of zone, name hash is after owner hash + rr: &NSEC3{ + Hdr: RR_Header{Name: "3v62ulr0nre83v0rja2vjgtlif9v6rab.com."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP", + }, + name: "csd.com.", + covers: true, + }, + { // end of zone, name hash is before beginning of zone + rr: &NSEC3{ + Hdr: RR_Header{Name: "PT3RON8N7PM3A0OE989IB84OOSADP7O8.com."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "3V62ULR0NRE83V0RJA2VJGTLIF9V6RAB", + }, + name: "asd.com.", + covers: true, + }, + // negative tests + { // too short owner name + rr: &NSEC3{ + Hdr: RR_Header{Name: "nl."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "39P99DCGG0MDLARTCRMCF6OFLLUL7PR6", + }, + name: "asd.com.", + covers: false, + }, + { // outside of zone + rr: &NSEC3{ + Hdr: RR_Header{Name: "39p91242oslggest5e6a7cci4iaeqvnk.nl."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "39P99DCGG0MDLARTCRMCF6OFLLUL7PR6", + }, + name: "asd.com.", + covers: false, + }, + { // empty interval + rr: &NSEC3{ + Hdr: RR_Header{Name: "2n1tb3vairuobl6rkdvii42n9tfmialp.com."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "2N1TB3VAIRUOBL6RKDVII42N9TFMIALP", + }, + name: "asd.com.", + covers: false, + }, + { // name hash is before owner hash, not covered + rr: &NSEC3{ + Hdr: RR_Header{Name: "3V62ULR0NRE83V0RJA2VJGTLIF9V6RAB.com."}, + Hash: 1, + Flags: 1, + Iterations: 5, + Salt: "F10E9F7EA83FC8F3", + NextDomain: "PT3RON8N7PM3A0OE989IB84OOSADP7O8", + }, + name: "asd.com.", + covers: false, + }, + } { + covers := tc.rr.Cover(tc.name) + if tc.covers != covers { + t.Fatalf("Cover failed for %s: expected %t, got %t [record: %s]", tc.name, tc.covers, covers, tc.rr) + } } } diff --git a/vendor/github.com/miekg/dns/parse_test.go b/vendor/github.com/miekg/dns/parse_test.go index c727c1301..2622318df 100644 --- a/vendor/github.com/miekg/dns/parse_test.go +++ b/vendor/github.com/miekg/dns/parse_test.go @@ -1509,3 +1509,21 @@ func TestParseURI(t *testing.T) { } } } + +func TestParseAVC(t *testing.T) { + avcs := map[string]string{ + `example.org. IN AVC "app-name:WOLFGANG|app-class:OAM|business=yes"`: `example.org. 3600 IN AVC "app-name:WOLFGANG|app-class:OAM|business=yes"`, + } + for avc, o := range avcs { + rr, err := NewRR(avc) + if err != nil { + t.Error("failed to parse RR: ", err) + continue + } + if rr.String() != o { + t.Errorf("`%s' should be equal to\n`%s', but is `%s'", avc, o, rr.String()) + } else { + t.Logf("RR is OK: `%s'", rr.String()) + } + } +} diff --git a/vendor/github.com/miekg/dns/scan_rr.go b/vendor/github.com/miekg/dns/scan_rr.go index f4c0d3767..b8b18fd77 100644 --- a/vendor/github.com/miekg/dns/scan_rr.go +++ b/vendor/github.com/miekg/dns/scan_rr.go @@ -1807,6 +1807,18 @@ func setSPF(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { return rr, nil, c1 } +func setAVC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { + rr := new(AVC) + rr.Hdr = h + + s, e, c1 := endingToTxtSlice(c, "bad AVC Txt", f) + if e != nil { + return nil, e, "" + } + rr.Txt = s + return rr, nil, c1 +} + func setTXT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { rr := new(TXT) rr.Hdr = h @@ -2158,6 +2170,7 @@ var typeToparserFunc = map[uint16]parserFunc{ TypeSMIMEA: {setSMIMEA, true}, TypeSOA: {setSOA, false}, TypeSPF: {setSPF, true}, + TypeAVC: {setAVC, true}, TypeSRV: {setSRV, false}, TypeSSHFP: {setSSHFP, true}, TypeTALINK: {setTALINK, false}, diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go index c17251cb6..53da4755c 100644 --- a/vendor/github.com/miekg/dns/types.go +++ b/vendor/github.com/miekg/dns/types.go @@ -91,6 +91,7 @@ const ( TypeEUI64 uint16 = 109 TypeURI uint16 = 256 TypeCAA uint16 = 257 + TypeAVC uint16 = 258 TypeTKEY uint16 = 249 TypeTSIG uint16 = 250 @@ -530,6 +531,13 @@ type SPF struct { func (rr *SPF) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } +type AVC struct { + Hdr RR_Header + Txt []string `dns:"txt"` +} + +func (rr *AVC) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } + type SRV struct { Hdr RR_Header Priority uint16 diff --git a/vendor/github.com/miekg/dns/zcompress.go b/vendor/github.com/miekg/dns/zcompress.go index 86a31a916..b277978b9 100644 --- a/vendor/github.com/miekg/dns/zcompress.go +++ b/vendor/github.com/miekg/dns/zcompress.go @@ -5,99 +5,95 @@ package dns func compressionLenHelperType(c map[string]int, r RR) { switch x := r.(type) { - case *KX: - compressionLenHelper(c, x.Exchanger) - case *MX: - compressionLenHelper(c, x.Mx) - case *NSEC: - compressionLenHelper(c, x.NextDomain) - case *DNAME: - compressionLenHelper(c, x.Target) + case *PTR: + compressionLenHelper(c, x.Ptr) + case *SOA: + compressionLenHelper(c, x.Ns) + compressionLenHelper(c, x.Mbox) + case *AFSDB: + compressionLenHelper(c, x.Hostname) case *HIP: for i := range x.RendezvousServers { compressionLenHelper(c, x.RendezvousServers[i]) } - case *CNAME: - compressionLenHelper(c, x.Target) - case *MR: - compressionLenHelper(c, x.Mr) - case *PX: - compressionLenHelper(c, x.Map822) - compressionLenHelper(c, x.Mapx400) - case *SIG: - compressionLenHelper(c, x.SignerName) - case *SRV: - compressionLenHelper(c, x.Target) - case *TALINK: - compressionLenHelper(c, x.PreviousName) - compressionLenHelper(c, x.NextName) case *LP: compressionLenHelper(c, x.Fqdn) - case *NAPTR: - compressionLenHelper(c, x.Replacement) - case *NS: - compressionLenHelper(c, x.Ns) + case *CNAME: + compressionLenHelper(c, x.Target) + case *MB: + compressionLenHelper(c, x.Mb) case *RP: compressionLenHelper(c, x.Mbox) compressionLenHelper(c, x.Txt) case *RRSIG: compressionLenHelper(c, x.SignerName) - case *TKEY: - compressionLenHelper(c, x.Algorithm) - case *TSIG: - compressionLenHelper(c, x.Algorithm) - case *AFSDB: - compressionLenHelper(c, x.Hostname) case *MF: compressionLenHelper(c, x.Mf) - case *RT: - compressionLenHelper(c, x.Host) case *MINFO: compressionLenHelper(c, x.Rmail) compressionLenHelper(c, x.Email) - case *PTR: + case *SIG: + compressionLenHelper(c, x.SignerName) + case *SRV: + compressionLenHelper(c, x.Target) + case *TSIG: + compressionLenHelper(c, x.Algorithm) + case *KX: + compressionLenHelper(c, x.Exchanger) + case *MG: + compressionLenHelper(c, x.Mg) + case *NSAPPTR: compressionLenHelper(c, x.Ptr) - case *SOA: - compressionLenHelper(c, x.Ns) - compressionLenHelper(c, x.Mbox) + case *PX: + compressionLenHelper(c, x.Map822) + compressionLenHelper(c, x.Mapx400) + case *DNAME: + compressionLenHelper(c, x.Target) + case *MR: + compressionLenHelper(c, x.Mr) + case *MX: + compressionLenHelper(c, x.Mx) + case *TKEY: + compressionLenHelper(c, x.Algorithm) + case *NSEC: + compressionLenHelper(c, x.NextDomain) + case *TALINK: + compressionLenHelper(c, x.PreviousName) + compressionLenHelper(c, x.NextName) case *MD: compressionLenHelper(c, x.Md) - case *NSAPPTR: - compressionLenHelper(c, x.Ptr) - case *MG: - compressionLenHelper(c, x.Mg) - case *MB: - compressionLenHelper(c, x.Mb) + case *NAPTR: + compressionLenHelper(c, x.Replacement) + case *NS: + compressionLenHelper(c, x.Ns) + case *RT: + compressionLenHelper(c, x.Host) } } func compressionLenSearchType(c map[string]int, r RR) (int, bool) { switch x := r.(type) { - case *MF: - k1, ok1 := compressionLenSearch(c, x.Mf) - return k1, ok1 case *MG: k1, ok1 := compressionLenSearch(c, x.Mg) return k1, ok1 - case *MINFO: - k1, ok1 := compressionLenSearch(c, x.Rmail) - k2, ok2 := compressionLenSearch(c, x.Email) - return k1 + k2, ok1 && ok2 - case *MR: - k1, ok1 := compressionLenSearch(c, x.Mr) - return k1, ok1 case *PTR: k1, ok1 := compressionLenSearch(c, x.Ptr) return k1, ok1 case *AFSDB: k1, ok1 := compressionLenSearch(c, x.Hostname) return k1, ok1 - case *CNAME: - k1, ok1 := compressionLenSearch(c, x.Target) + case *MB: + k1, ok1 := compressionLenSearch(c, x.Mb) return k1, ok1 case *MD: k1, ok1 := compressionLenSearch(c, x.Md) return k1, ok1 + case *MF: + k1, ok1 := compressionLenSearch(c, x.Mf) + return k1, ok1 + case *NS: + k1, ok1 := compressionLenSearch(c, x.Ns) + return k1, ok1 case *RT: k1, ok1 := compressionLenSearch(c, x.Host) return k1, ok1 @@ -105,15 +101,19 @@ func compressionLenSearchType(c map[string]int, r RR) (int, bool) { k1, ok1 := compressionLenSearch(c, x.Ns) k2, ok2 := compressionLenSearch(c, x.Mbox) return k1 + k2, ok1 && ok2 - case *MB: - k1, ok1 := compressionLenSearch(c, x.Mb) + case *CNAME: + k1, ok1 := compressionLenSearch(c, x.Target) + return k1, ok1 + case *MINFO: + k1, ok1 := compressionLenSearch(c, x.Rmail) + k2, ok2 := compressionLenSearch(c, x.Email) + return k1 + k2, ok1 && ok2 + case *MR: + k1, ok1 := compressionLenSearch(c, x.Mr) return k1, ok1 case *MX: k1, ok1 := compressionLenSearch(c, x.Mx) return k1, ok1 - case *NS: - k1, ok1 := compressionLenSearch(c, x.Ns) - return k1, ok1 } return 0, false } diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go index 9b98e1bb2..418fb1fe3 100644 --- a/vendor/github.com/miekg/dns/zmsg.go +++ b/vendor/github.com/miekg/dns/zmsg.go @@ -61,6 +61,20 @@ func (rr *ANY) pack(msg []byte, off int, compression map[string]int, compress bo return off, nil } +func (rr *AVC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { + off, err := rr.Hdr.pack(msg, off, compression, compress) + if err != nil { + return off, err + } + headerEnd := off + off, err = packStringTxt(rr.Txt, msg, off) + if err != nil { + return off, err + } + rr.Header().Rdlength = uint16(off - headerEnd) + return off, nil +} + func (rr *CAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { off, err := rr.Hdr.pack(msg, off, compression, compress) if err != nil { @@ -1528,6 +1542,23 @@ func unpackANY(h RR_Header, msg []byte, off int) (RR, int, error) { return rr, off, err } +func unpackAVC(h RR_Header, msg []byte, off int) (RR, int, error) { + rr := new(AVC) + rr.Hdr = h + if noRdata(h) { + return rr, off, nil + } + var err error + rdStart := off + _ = rdStart + + rr.Txt, off, err = unpackStringTxt(msg, off) + if err != nil { + return rr, off, err + } + return rr, off, err +} + func unpackCAA(h RR_Header, msg []byte, off int) (RR, int, error) { rr := new(CAA) rr.Hdr = h @@ -3467,6 +3498,7 @@ var typeToUnpack = map[uint16]func(RR_Header, []byte, int) (RR, int, error){ TypeAAAA: unpackAAAA, TypeAFSDB: unpackAFSDB, TypeANY: unpackANY, + TypeAVC: unpackAVC, TypeCAA: unpackCAA, TypeCDNSKEY: unpackCDNSKEY, TypeCDS: unpackCDS, diff --git a/vendor/github.com/miekg/dns/ztypes.go b/vendor/github.com/miekg/dns/ztypes.go index 311b8243b..3e534f12e 100644 --- a/vendor/github.com/miekg/dns/ztypes.go +++ b/vendor/github.com/miekg/dns/ztypes.go @@ -14,6 +14,7 @@ var TypeToRR = map[uint16]func() RR{ TypeAAAA: func() RR { return new(AAAA) }, TypeAFSDB: func() RR { return new(AFSDB) }, TypeANY: func() RR { return new(ANY) }, + TypeAVC: func() RR { return new(AVC) }, TypeCAA: func() RR { return new(CAA) }, TypeCDNSKEY: func() RR { return new(CDNSKEY) }, TypeCDS: func() RR { return new(CDS) }, @@ -86,6 +87,7 @@ var TypeToString = map[uint16]string{ TypeAFSDB: "AFSDB", TypeANY: "ANY", TypeATMA: "ATMA", + TypeAVC: "AVC", TypeAXFR: "AXFR", TypeCAA: "CAA", TypeCDNSKEY: "CDNSKEY", @@ -166,6 +168,7 @@ func (rr *A) Header() *RR_Header { return &rr.Hdr } func (rr *AAAA) Header() *RR_Header { return &rr.Hdr } func (rr *AFSDB) Header() *RR_Header { return &rr.Hdr } func (rr *ANY) Header() *RR_Header { return &rr.Hdr } +func (rr *AVC) Header() *RR_Header { return &rr.Hdr } func (rr *CAA) Header() *RR_Header { return &rr.Hdr } func (rr *CDNSKEY) Header() *RR_Header { return &rr.Hdr } func (rr *CDS) Header() *RR_Header { return &rr.Hdr } @@ -252,6 +255,13 @@ func (rr *ANY) len() int { l := rr.Hdr.len() return l } +func (rr *AVC) len() int { + l := rr.Hdr.len() + for _, x := range rr.Txt { + l += len(x) + 1 + } + return l +} func (rr *CAA) len() int { l := rr.Hdr.len() l++ // Flag @@ -649,6 +659,11 @@ func (rr *AFSDB) copy() RR { func (rr *ANY) copy() RR { return &ANY{*rr.Hdr.copyHeader()} } +func (rr *AVC) copy() RR { + Txt := make([]string, len(rr.Txt)) + copy(Txt, rr.Txt) + return &AVC{*rr.Hdr.copyHeader(), Txt} +} func (rr *CAA) copy() RR { return &CAA{*rr.Hdr.copyHeader(), rr.Flag, rr.Tag, rr.Value} } -- cgit v1.2.3-1-g7c22