rewrite: imp code

This commit is contained in:
Dimitry Kolyshev 2023-01-09 18:51:05 +07:00
parent 53cd9b7a1a
commit c1be2bab4d

View file

@ -217,17 +217,14 @@ func (s *DefaultStorage) resetRules() (err error) {
// matchesQType returns true if dnsrewrite matches the question type qt. // matchesQType returns true if dnsrewrite matches the question type qt.
func matchesQType(dnsrr *rules.DNSRewrite, qt uint16) (ok bool) { func matchesQType(dnsrr *rules.DNSRewrite, qt uint16) (ok bool) {
// Accept types other than A and AAAA. switch qt {
if qt != dns.TypeA && qt != dns.TypeAAAA { case dns.TypeA:
return dnsrr.RRType != dns.TypeAAAA
case dns.TypeAAAA:
return dnsrr.RRType != dns.TypeA
default:
return true 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. // isWildcard returns true if pat is a wildcard domain pattern.