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

@@ -136,7 +136,7 @@ func (s *Server) genAnswerCNAME(req *dns.Msg, cname string) (ans *dns.CNAME) {
func (s *Server) genAnswerMX(req *dns.Msg, mx *rules.DNSMX) (ans *dns.MX) {
return &dns.MX{
Hdr: s.hdr(req, dns.TypePTR),
Hdr: s.hdr(req, dns.TypeMX),
Preference: mx.Preference,
Mx: mx.Exchange,
}
@@ -149,6 +149,16 @@ func (s *Server) genAnswerPTR(req *dns.Msg, ptr string) (ans *dns.PTR) {
}
}
func (s *Server) genAnswerSRV(req *dns.Msg, srv *rules.DNSSRV) (ans *dns.SRV) {
return &dns.SRV{
Hdr: s.hdr(req, dns.TypeSRV),
Priority: srv.Priority,
Weight: srv.Weight,
Port: srv.Port,
Target: srv.Target,
}
}
func (s *Server) genAnswerTXT(req *dns.Msg, strs []string) (ans *dns.TXT) {
return &dns.TXT{
Hdr: s.hdr(req, dns.TypeTXT),