mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
request: add match function (#1615)
This commit is contained in:
@@ -361,6 +361,24 @@ func (r *Request) Clear() {
|
||||
r.name = ""
|
||||
}
|
||||
|
||||
// Match checks if the reply matches the qname and qtype 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
|
||||
}
|
||||
|
||||
if strings.ToLower(reply.Question[0].Name) != r.Name() {
|
||||
return false
|
||||
}
|
||||
|
||||
if reply.Question[0].Qtype != r.QType() {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const (
|
||||
// TODO(miek): make this less awkward.
|
||||
doTrue = 1
|
||||
|
||||
Reference in New Issue
Block a user