From c1be2bab4d3d93bcef638cdd59096fefdc125b94 Mon Sep 17 00:00:00 2001 From: Dimitry Kolyshev Date: Mon, 9 Jan 2023 18:51:05 +0700 Subject: [PATCH] rewrite: imp code --- internal/filtering/rewrite/storage.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/filtering/rewrite/storage.go b/internal/filtering/rewrite/storage.go index c819935a..65c5ee55 100644 --- a/internal/filtering/rewrite/storage.go +++ b/internal/filtering/rewrite/storage.go @@ -217,17 +217,14 @@ func (s *DefaultStorage) resetRules() (err error) { // matchesQType returns true if dnsrewrite matches the question type qt. func matchesQType(dnsrr *rules.DNSRewrite, qt uint16) (ok bool) { - // Accept types other than A and AAAA. - if qt != dns.TypeA && qt != dns.TypeAAAA { + switch qt { + case dns.TypeA: + return dnsrr.RRType != dns.TypeAAAA + case dns.TypeAAAA: + return dnsrr.RRType != dns.TypeA + default: return true } - - // Add CNAMEs, since they match for all types requests. - if dnsrr.RRType == dns.TypeCNAME || dnsrr.NewCNAME != "" { - return true - } - - return dnsrr.RRType == qt } // isWildcard returns true if pat is a wildcard domain pattern.