mirror of
https://github.com/coredns/coredns.git
synced 2026-07-12 10:40:10 -04:00
request/cache: bind responses and entries to QCLASS (#8272)
Signed-off-by: houyuwushang <liuluoqianqiu@outlook.com>
This commit is contained in:
@@ -340,8 +340,8 @@ func (r *Request) Clear() {
|
||||
r.do = false
|
||||
}
|
||||
|
||||
// Match checks if the reply matches the qname and qtype from the request, it returns
|
||||
// false when they don't match.
|
||||
// Match checks if the reply matches the qname, qtype and qclass from the request.
|
||||
// It returns false when they don't match.
|
||||
func (r *Request) Match(reply *dns.Msg) bool {
|
||||
if len(reply.Question) != 1 {
|
||||
return false
|
||||
@@ -359,5 +359,9 @@ func (r *Request) Match(reply *dns.Msg) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if reply.Question[0].Qclass != r.QClass() {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -310,6 +310,11 @@ func TestRequestMatch(t *testing.T) {
|
||||
t.Errorf("Failed to match %s %d, got %t, expected %t", "example.com.", dns.TypeA, b, true)
|
||||
}
|
||||
|
||||
reply.Question[0].Qclass = dns.ClassCHAOS
|
||||
if b := st.Match(reply); b {
|
||||
t.Errorf("Matched response class %d with request class %d", reply.Question[0].Qclass, st.QClass())
|
||||
}
|
||||
|
||||
reply.SetQuestion("example.org.", dns.TypeA)
|
||||
if b := st.Match(reply); b {
|
||||
t.Errorf("Failed to match %s %d, got %t, expected %t", "example.org.", dns.TypeA, b, false)
|
||||
|
||||
Reference in New Issue
Block a user