Skip to content

Commit

Permalink
Pull request: 3115 domain case
Browse files Browse the repository at this point in the history
Merge in DNS/adguard-home from 3115-domain-case to master

Updates AdguardTeam#3115.

Squashed commit of the following:

commit 02b6d27
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue May 11 19:56:06 2021 +0300

    all: fix typos

commit cdd1de6
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue May 11 19:37:37 2021 +0300

    dnsforward: fix disallowed domains case matching
  • Loading branch information
EugeneOne1 authored and heyxkhoa committed Mar 17, 2023
1 parent 7eaa550 commit e682dfa
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-insensitive ([#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 lowercased 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 e682dfa

Please sign in to comment.