Skip to content

Commit

Permalink
all: safesearch cnames
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Dec 8, 2023
1 parent 061a6de commit 8f23ade
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/dnsforward/msg.go
Expand Up @@ -75,9 +75,14 @@ func (s *Server) genDNSFilterMessage(
// genFltSafeSearch generates a filtered response to req for safe search filter.
// Adds a CNAME record if cname if provided.
func (s *Server) genFltSafeSearch(req *dns.Msg, ips []netip.Addr, cname string) (resp *dns.Msg) {
originalName := req.Question[0].Name

var ans []dns.RR
if cname != "" {
ans = append(ans, s.genAnswerCNAME(req, cname))

// The given IPs actually are resolved for this cname.
req.Question[0].Name = dns.Fqdn(cname)
}

switch req.Question[0].Qtype {
Expand All @@ -93,6 +98,8 @@ func (s *Server) genFltSafeSearch(req *dns.Msg, ips []netip.Addr, cname string)
// Go on and return an empty response.
}

req.Question[0].Name = originalName

resp = s.makeResponse(req)
resp.Answer = ans

Expand Down

0 comments on commit 8f23ade

Please sign in to comment.