Pull request: all: add srv handling to dnsrewrite filters

Closes #2498.
Updates #2533.

Squashed commit of the following:

commit 452e0e7d281c1f10bef069bf7a73205266b8f1e0
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Mar 12 19:33:18 2021 +0300

    all: add srv handling to dnsrewrite filters
This commit is contained in:
Ainar Garipov
2021-03-15 13:08:13 +03:00
parent 4c6bf68d4d
commit d970b79f2b
6 changed files with 72 additions and 77 deletions

View File

@@ -20,7 +20,8 @@ func (s *Server) filterDNSRewriteResponse(req *dns.Msg, rr rules.RRType, v rules
// the answer generation logic from the Server.
switch rr {
case dns.TypeA, dns.TypeAAAA:
case dns.TypeA,
dns.TypeAAAA:
ip, ok := v.(net.IP)
if !ok {
return nil, fmt.Errorf("value for rr type %d has type %T, not net.IP", rr, v)
@@ -62,6 +63,13 @@ func (s *Server) filterDNSRewriteResponse(req *dns.Msg, rr rules.RRType, v rules
}
return s.genAnswerSVCB(req, svcb), nil
case dns.TypeSRV:
srv, ok := v.(*rules.DNSSRV)
if !ok {
return nil, fmt.Errorf("value for rr type %d has type %T, not *rules.DNSSRV", rr, v)
}
return s.genAnswerSRV(req, srv), nil
default:
log.Debug("don't know how to handle dns rr type %d, skipping", rr)