package bufsize import ( "context" "testing" "github.com/coredns/coredns/plugin/test" "github.com/coredns/coredns/plugin/whoami" "github.com/miekg/dns" ) func TestBufsize(t *testing.T) { const maxBufSize = 1024 setUpWithRequestBufsz := func(bufferSize uint16) (Bufsize, *dns.Msg) { p := Bufsize{ Size: maxBufSize, Next: whoami.Whoami{}, } r := new(dns.Msg) r.SetQuestion(dns.Fqdn("."), dns.TypeA) r.Question[0].Qclass = dns.ClassINET if bufferSize > 0 { r.SetEdns0(bufferSize, false) } return p, r } t.Run("Limit response buffer size", func(t *testing.T) { // GIVEN // plugin initialized with maximum buffer size // request has larger buffer size than allowed p, r := setUpWithRequestBufsz(maxBufSize + 128) // WHEN // request is processed _, err := p.ServeDNS(context.Background(), &test.ResponseWriter{}, r) // THEN // no error // OPT RR present // request buffer size is limited if err != nil { t.Errorf("unexpected error %s", err) } option := r.IsEdns0() if option == nil { t.Errorf("OPT RR not present") } if option.UDPSize() != maxBufSize { t.Errorf("buffer size not limited") } }) t.Run("Do not increase response buffer size", func(t *testing.T) { // GIVEN // plugin initialized with maximum buffer size // request has smaller buffer size than allowed const smallerBufferSize = maxBufSize - 128 p, r := setUpWithRequestBufsz(smallerBufferSize) // WHEN // request is processed _, err := p.ServeDNS(context.Background(), &test.ResponseWriter{}, r) // THEN // no error // request buffer size is not expanded if err != nil { t.Errorf("unexpected error %s", err) } option := r.IsEdns0() if option == nil { t.Errorf("OPT RR not present") } if option.UDPSize() != smallerBufferSize { t.Errorf("buffer size should not be increased") } }) t.Run("Buffer size should not be set", func(t *testing.T) { // GIVEN // plugin initialized with maximum buffer size // request has no EDNS0 option set p, r := setUpWithRequestBufsz(0) // WHEN // request is processed _, err := p.ServeDNS(context.Background(), &test.ResponseWriter{}, r) // THEN // no error // OPT RR is not appended if err != nil { t.Errorf("unexpected error %s", err) } if r.IsEdns0() != nil { t.Errorf("EDNS0 enabled for incoming request") } }) } egory_test.go?h=2.0.22&follow=1'>Collapse)AuthorFilesLines 2020-06-18Fix inverted entry sorting in the Italian translationGravatar WasabiPizza 2-5/+5 2020-06-17Revert "Always align action items to the right even when the window is small "Gravatar Frédéric Guillot 2-16/+12 This reverts commit c9618458cb2ad42c2a588c34f2c870d93df032d5. 2020-06-16Fix regression: the entire hstore field is replaced when updating settingsGravatar Frédéric Guillot 2-2/+2 2020-06-15Bump github.com/lib/pq from 1.6.0 to 1.7.0Gravatar dependabot[bot] 2-1/+3 Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.6.0 to 1.7.0. - [Release notes](https://github.com/lib/pq/releases) - [Commits](https://github.com/lib/pq/compare/v1.6.0...v1.7.0) Signed-off-by: dependabot[bot] <support@github.com> 2020-06-14Add icons to feeds and categories listGravatar Frédéric Guillot 18-46/+149 2020-06-11Change feed title to a link to original websiteGravatar Shizun Ge 6-15/+33 2020-06-10Replace link to categories by a link to the list of entries in "Category > ↵Gravatar Shizun Ge 2-3/+3 Feeds" page Solves #659 2020-06-10Always align action items to the right even when the window is small Gravatar Shizun Ge 2-12/+16 2020-06-10Added scraper rule for dilbert.com and turnoff.usGravatar Manuel Müller 1-0/+2 2020-06-06Fix typo in German translationGravatar schlich 2-3/+3 2020-06-05Add feed option to ignore HTTP cacheGravatar Frédéric Guillot 23-52/+105 2020-06-02Update Docker image to Alpine 3.12Gravatar Frédéric Guillot 1-1/+1 2020-06-02Bump github.com/lib/pq from 1.4.0 to 1.6.0Gravatar dependabot[bot] 2-2/+29 Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.4.0 to 1.6.0. - [Release notes](https://github.com/lib/pq/releases) - [Commits](https://github.com/lib/pq/compare/v1.4.0...v1.6.0) Signed-off-by: dependabot[bot] <support@github.com> 2020-06-02Move dependabot.yml to .github folderGravatar Frédéric Guillot 1-0/+0