Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin/cache: remove item.Autoritative #2885

Merged
merged 2 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions plugin/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ type cacheTestCase struct {
test.Case
in test.Case
AuthenticatedData bool
Authoritative bool
RecursionAvailable bool
Truncated bool
shouldCache bool
}

var cacheTestCases = []cacheTestCase{
{
RecursionAvailable: true, AuthenticatedData: true, Authoritative: true,
RecursionAvailable: true, AuthenticatedData: true,
Case: test.Case{
Qname: "miek.nl.", Qtype: dns.TypeMX,
Answer: []dns.RR{
Expand All @@ -43,7 +42,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: true,
},
{
RecursionAvailable: true, AuthenticatedData: true, Authoritative: true,
RecursionAvailable: true, AuthenticatedData: true,
Case: test.Case{
Qname: "mIEK.nL.", Qtype: dns.TypeMX,
Answer: []dns.RR{
Expand All @@ -70,7 +69,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: false,
},
{
RecursionAvailable: true, Authoritative: true,
RecursionAvailable: true,
Case: test.Case{
Rcode: dns.RcodeNameError,
Qname: "example.org.", Qtype: dns.TypeA,
Expand All @@ -88,7 +87,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: true,
},
{
RecursionAvailable: true, Authoritative: false,
RecursionAvailable: true,
Case: test.Case{
Rcode: dns.RcodeServerFailure,
Qname: "example.org.", Qtype: dns.TypeA,
Expand All @@ -102,7 +101,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: true,
},
{
RecursionAvailable: true, Authoritative: false,
RecursionAvailable: true,
Case: test.Case{
Rcode: dns.RcodeNotImplemented,
Qname: "example.org.", Qtype: dns.TypeA,
Expand All @@ -116,7 +115,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: true,
},
{
RecursionAvailable: true, Authoritative: true,
RecursionAvailable: true,
Case: test.Case{
Qname: "miek.nl.", Qtype: dns.TypeMX,
Do: true,
Expand All @@ -138,7 +137,7 @@ var cacheTestCases = []cacheTestCase{
shouldCache: false,
},
{
RecursionAvailable: true, Authoritative: true,
RecursionAvailable: true,
Case: test.Case{
Qname: "example.org.", Qtype: dns.TypeMX,
Do: true,
Expand All @@ -164,7 +163,7 @@ var cacheTestCases = []cacheTestCase{
func cacheMsg(m *dns.Msg, tc cacheTestCase) *dns.Msg {
m.RecursionAvailable = tc.RecursionAvailable
m.AuthenticatedData = tc.AuthenticatedData
m.Authoritative = tc.Authoritative
m.Authoritative = true
m.Rcode = tc.Rcode
m.Truncated = tc.Truncated
m.Answer = tc.in.Answer
Expand Down
7 changes: 4 additions & 3 deletions plugin/cache/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

type item struct {
Rcode int
Authoritative bool
AuthenticatedData bool
RecursionAvailable bool
Answer []dns.RR
Expand All @@ -25,7 +24,6 @@ type item struct {
func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
i := new(item)
i.Rcode = m.Rcode
i.Authoritative = m.Authoritative
i.AuthenticatedData = m.AuthenticatedData
i.RecursionAvailable = m.RecursionAvailable
i.Answer = m.Answer
Expand Down Expand Up @@ -56,7 +54,10 @@ func (i *item) toMsg(m *dns.Msg, now time.Time) *dns.Msg {
m1 := new(dns.Msg)
m1.SetReply(m)

m1.Authoritative = false
// Set this to true as some DNS clients disgard the *entire* packet when it's non-authoritative.
// This is probably not according to spec, but the bit itself is not super useful as this point, so
// just set it to true.
m1.Authoritative = true
m1.AuthenticatedData = i.AuthenticatedData
m1.RecursionAvailable = i.RecursionAvailable
m1.Rcode = i.Rcode
Expand Down