plugin/cache: remove item.Autoritative (#2885)
* plugin/cache: remove item.Autoritative Confuses clients if not set; remove it. Signed-off-by: Miek Gieben <miek@miek.nl> * Add extra comments on why we do this Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
27ca097df4
commit
481dea50ad
2 changed files with 12 additions and 12 deletions
17
plugin/cache/cache_test.go
vendored
17
plugin/cache/cache_test.go
vendored
|
@ -17,7 +17,6 @@ type cacheTestCase struct {
|
||||||
test.Case
|
test.Case
|
||||||
in test.Case
|
in test.Case
|
||||||
AuthenticatedData bool
|
AuthenticatedData bool
|
||||||
Authoritative bool
|
|
||||||
RecursionAvailable bool
|
RecursionAvailable bool
|
||||||
Truncated bool
|
Truncated bool
|
||||||
shouldCache bool
|
shouldCache bool
|
||||||
|
@ -25,7 +24,7 @@ type cacheTestCase struct {
|
||||||
|
|
||||||
var cacheTestCases = []cacheTestCase{
|
var cacheTestCases = []cacheTestCase{
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, AuthenticatedData: true, Authoritative: true,
|
RecursionAvailable: true, AuthenticatedData: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Qname: "miek.nl.", Qtype: dns.TypeMX,
|
Qname: "miek.nl.", Qtype: dns.TypeMX,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
|
@ -43,7 +42,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: true,
|
shouldCache: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, AuthenticatedData: true, Authoritative: true,
|
RecursionAvailable: true, AuthenticatedData: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Qname: "mIEK.nL.", Qtype: dns.TypeMX,
|
Qname: "mIEK.nL.", Qtype: dns.TypeMX,
|
||||||
Answer: []dns.RR{
|
Answer: []dns.RR{
|
||||||
|
@ -70,7 +69,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: false,
|
shouldCache: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, Authoritative: true,
|
RecursionAvailable: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Rcode: dns.RcodeNameError,
|
Rcode: dns.RcodeNameError,
|
||||||
Qname: "example.org.", Qtype: dns.TypeA,
|
Qname: "example.org.", Qtype: dns.TypeA,
|
||||||
|
@ -88,7 +87,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: true,
|
shouldCache: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, Authoritative: false,
|
RecursionAvailable: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Rcode: dns.RcodeServerFailure,
|
Rcode: dns.RcodeServerFailure,
|
||||||
Qname: "example.org.", Qtype: dns.TypeA,
|
Qname: "example.org.", Qtype: dns.TypeA,
|
||||||
|
@ -102,7 +101,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: true,
|
shouldCache: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, Authoritative: false,
|
RecursionAvailable: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Rcode: dns.RcodeNotImplemented,
|
Rcode: dns.RcodeNotImplemented,
|
||||||
Qname: "example.org.", Qtype: dns.TypeA,
|
Qname: "example.org.", Qtype: dns.TypeA,
|
||||||
|
@ -116,7 +115,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: true,
|
shouldCache: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, Authoritative: true,
|
RecursionAvailable: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Qname: "miek.nl.", Qtype: dns.TypeMX,
|
Qname: "miek.nl.", Qtype: dns.TypeMX,
|
||||||
Do: true,
|
Do: true,
|
||||||
|
@ -138,7 +137,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
shouldCache: false,
|
shouldCache: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
RecursionAvailable: true, Authoritative: true,
|
RecursionAvailable: true,
|
||||||
Case: test.Case{
|
Case: test.Case{
|
||||||
Qname: "example.org.", Qtype: dns.TypeMX,
|
Qname: "example.org.", Qtype: dns.TypeMX,
|
||||||
Do: true,
|
Do: true,
|
||||||
|
@ -164,7 +163,7 @@ var cacheTestCases = []cacheTestCase{
|
||||||
func cacheMsg(m *dns.Msg, tc cacheTestCase) *dns.Msg {
|
func cacheMsg(m *dns.Msg, tc cacheTestCase) *dns.Msg {
|
||||||
m.RecursionAvailable = tc.RecursionAvailable
|
m.RecursionAvailable = tc.RecursionAvailable
|
||||||
m.AuthenticatedData = tc.AuthenticatedData
|
m.AuthenticatedData = tc.AuthenticatedData
|
||||||
m.Authoritative = tc.Authoritative
|
m.Authoritative = true
|
||||||
m.Rcode = tc.Rcode
|
m.Rcode = tc.Rcode
|
||||||
m.Truncated = tc.Truncated
|
m.Truncated = tc.Truncated
|
||||||
m.Answer = tc.in.Answer
|
m.Answer = tc.in.Answer
|
||||||
|
|
7
plugin/cache/item.go
vendored
7
plugin/cache/item.go
vendored
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
type item struct {
|
type item struct {
|
||||||
Rcode int
|
Rcode int
|
||||||
Authoritative bool
|
|
||||||
AuthenticatedData bool
|
AuthenticatedData bool
|
||||||
RecursionAvailable bool
|
RecursionAvailable bool
|
||||||
Answer []dns.RR
|
Answer []dns.RR
|
||||||
|
@ -25,7 +24,6 @@ type item struct {
|
||||||
func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
|
func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
|
||||||
i := new(item)
|
i := new(item)
|
||||||
i.Rcode = m.Rcode
|
i.Rcode = m.Rcode
|
||||||
i.Authoritative = m.Authoritative
|
|
||||||
i.AuthenticatedData = m.AuthenticatedData
|
i.AuthenticatedData = m.AuthenticatedData
|
||||||
i.RecursionAvailable = m.RecursionAvailable
|
i.RecursionAvailable = m.RecursionAvailable
|
||||||
i.Answer = m.Answer
|
i.Answer = m.Answer
|
||||||
|
@ -56,7 +54,10 @@ func (i *item) toMsg(m *dns.Msg, now time.Time) *dns.Msg {
|
||||||
m1 := new(dns.Msg)
|
m1 := new(dns.Msg)
|
||||||
m1.SetReply(m)
|
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.AuthenticatedData = i.AuthenticatedData
|
||||||
m1.RecursionAvailable = i.RecursionAvailable
|
m1.RecursionAvailable = i.RecursionAvailable
|
||||||
m1.Rcode = i.Rcode
|
m1.Rcode = i.Rcode
|
||||||
|
|
Loading…
Add table
Reference in a new issue