Skip to content

Commit

Permalink
dnsforward: fix disallowed domains case matching
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed May 11, 2021
1 parent e27525e commit cdd1de6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ and this project adheres to
## [v0.106.3] - 2021-05-17 (APPROX.)
-->

### Fixed

- Disallowed domains are now case-insesitive ([#3115]).

[#3115]: https://github.com/AdguardTeam/AdGuardHome/issues/3115



## [v0.106.2] - 2021-05-06
Expand Down
2 changes: 1 addition & 1 deletion internal/dnsforward/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newAccessCtx(allowedClients, disallowedClients, blockedHosts []string) (a *

b := &strings.Builder{}
for _, s := range blockedHosts {
aghstrings.WriteToBuilder(b, s, "\n")
aghstrings.WriteToBuilder(b, strings.ToLower(s), "\n")
}

listArray := []filterlist.RuleList{}
Expand Down
6 changes: 5 additions & 1 deletion internal/dnsforward/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func (s *Server) beforeRequestHandler(_ *proxy.Proxy, d *proxy.DNSContext) (bool
}

if len(d.Req.Question) == 1 {
host := strings.TrimSuffix(d.Req.Question[0].Name, ".")
// It's bringed to the lowercase here since this handler is
// called before any other one.
name := strings.ToLower(d.Req.Question[0].Name)
d.Req.Question[0].Name = name
host := strings.TrimSuffix(name, ".")
if s.access.IsBlockedDomain(host) {
log.Tracef("Domain %s is blocked by settings", host)
return false, nil
Expand Down

0 comments on commit cdd1de6

Please sign in to comment.