Skip to content

Commit

Permalink
fix logic - don't do DNS response check for Rewrite rules
Browse files Browse the repository at this point in the history
  • Loading branch information
szolin committed Mar 19, 2020
1 parent 6cfabc0 commit 9e5ed49
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dnsforward/dnsforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,11 @@ func processFilteringAfterResponse(ctx *dnsContext) int {
res := ctx.result
var err error

if res.Reason == dnsfilter.ReasonRewrite && len(res.CanonName) != 0 {
switch res.Reason {
case dnsfilter.ReasonRewrite:
if len(res.CanonName) == 0 {
break
}
d.Req.Question[0] = ctx.origQuestion
d.Res.Question[0] = ctx.origQuestion

Expand All @@ -676,7 +680,14 @@ func processFilteringAfterResponse(ctx *dnsContext) int {
d.Res.Answer = answer
}

} else if res.Reason != dnsfilter.NotFilteredWhiteList && ctx.protectionEnabled {
case dnsfilter.ReasonRewriteAuto:
case dnsfilter.NotFilteredWhiteList:
// nothing

default:
if !ctx.protectionEnabled {
break
}
origResp2 := d.Res
ctx.result, err = s.filterDNSResponse(ctx)
if err != nil {
Expand Down

0 comments on commit 9e5ed49

Please sign in to comment.