Skip to content

Commit

Permalink
dnsforward: imp code, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Sep 2, 2022
1 parent a1b95fd commit b874088
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions internal/dnsforward/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ func (s *Server) handleDNSRequest(_ *proxy.Proxy, pctx *proxy.DNSContext) error
}

if pctx.Res != nil {
pctx.Res.Compress = true // some devices require DNS message compression
// Some devices require DNS message compression.
pctx.Res.Compress = true
}

return nil
}

Expand All @@ -151,25 +153,29 @@ func (s *Server) processRecursion(dctx *dnsContext) (rc resultCode) {
// TODO(e.burkov): Decompose into less general processors.
func (s *Server) processInitial(dctx *dnsContext) (rc resultCode) {
pctx := dctx.proxyCtx
if s.conf.AAAADisabled && pctx.Req.Question[0].Qtype == dns.TypeAAAA {
q := pctx.Req.Question[0]
qt := q.Qtype
if s.conf.AAAADisabled && qt == dns.TypeAAAA {
_ = proxy.CheckDisabledAAAARequest(pctx, true)

return resultCodeFinish
}

if s.conf.OnDNSRequest != nil {
s.conf.OnDNSRequest(pctx)
}

// disable Mozilla DoH
// https://support.mozilla.org/en-US/kb/canary-domain-use-application-dnsnet
if (pctx.Req.Question[0].Qtype == dns.TypeA || pctx.Req.Question[0].Qtype == dns.TypeAAAA) &&
pctx.Req.Question[0].Name == "use-application-dns.net." {
// Disable Mozilla DoH.
//
// See https://support.mozilla.org/en-US/kb/canary-domain-use-application-dnsnet.
if (qt == dns.TypeA || qt == dns.TypeAAAA) && q.Name == "use-application-dns.net." {
pctx.Res = s.genNXDomain(pctx.Req)

return resultCodeFinish
}

// Get the client's ID if any. It should be performed before getting
// client-specific filtering settings.
// Get the ClientID, if any, before getting client-specific filtering
// settings.
var key [8]byte
binary.BigEndian.PutUint64(key[:], pctx.RequestID)
dctx.clientID = string(s.clientIDCache.Get(key[:]))
Expand Down Expand Up @@ -251,15 +257,15 @@ func (s *Server) onDHCPLeaseChanged(flags int) {
// See https://www.ietf.org/archive/id/draft-ietf-add-ddr-06.html.
func (s *Server) processDDRQuery(dctx *dnsContext) (rc resultCode) {
pctx := dctx.proxyCtx
question := pctx.Req.Question[0]
q := pctx.Req.Question[0]

if !s.conf.HandleDDR {
return resultCodeSuccess
}

if question.Name == ddrHostFQDN {
if q.Name == ddrHostFQDN {
if s.dnsProxy.TLSListenAddr == nil && s.conf.HTTPSListenAddrs == nil &&
s.dnsProxy.QUICListenAddr == nil || question.Qtype != dns.TypeSVCB {
s.dnsProxy.QUICListenAddr == nil || q.Qtype != dns.TypeSVCB {
pctx.Res = s.makeResponse(pctx.Req)

return resultCodeFinish
Expand Down

0 comments on commit b874088

Please sign in to comment.