Skip to content

Commit

Permalink
Pull request 1787: 5639-querylog-filter-fix
Browse files Browse the repository at this point in the history
Fixes #5639.

Squashed commit of the following:

commit 1aa02c8
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Sun Mar 26 13:39:29 2023 +0300

    querylog: fix filtered log filter
  • Loading branch information
ainar-g committed Mar 26, 2023
1 parent fb7b8bb commit 0df3260
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ In this release, the schema version has changed from 17 to 20.

### Fixed

- Query log not showing all filtered queries when the “Filtered” log filter is
selected ([#5639]).
- Panic in empty hostname in the filter's URL ([#5631]).
- Panic caused by empty top-level domain name label in `/etc/hosts` files
([#5584]).
Expand All @@ -133,6 +135,7 @@ In this release, the schema version has changed from 17 to 20.
[#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567
[#5584]: https://github.com/AdguardTeam/AdGuardHome/issues/5584
[#5631]: https://github.com/AdguardTeam/AdGuardHome/issues/5631
[#5639]: https://github.com/AdguardTeam/AdGuardHome/issues/5639

[rfc6761]: https://www.rfc-editor.org/rfc/rfc6761

Expand Down
16 changes: 7 additions & 9 deletions internal/querylog/searchcriterion.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,18 @@ func (c *searchCriterion) ctFilteringStatusCase(
switch c.value {
case filteringStatusAll:
return true
case filteringStatusFiltered:
return isFiltered || reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case
filteringStatusBlocked,
filteringStatusBlockedParental,
filteringStatusBlockedSafebrowsing,
filteringStatusBlockedService,
filteringStatusFiltered,
filteringStatusSafeSearch:
return isFiltered && c.isFilteredWithReason(reason)
case filteringStatusWhitelisted:
Expand Down Expand Up @@ -184,7 +190,6 @@ func (c *searchCriterion) ctFilteringStatusCase(
// - filteringStatusBlockedParental
// - filteringStatusBlockedSafebrowsing
// - filteringStatusBlockedService
// - filteringStatusFiltered
// - filteringStatusSafeSearch
func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched bool) {
switch c.value {
Expand All @@ -196,13 +201,6 @@ func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched
return reason == filtering.FilteredSafeBrowsing
case filteringStatusBlockedService:
return reason == filtering.FilteredBlockedService
case filteringStatusFiltered:
return reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case filteringStatusSafeSearch:
return reason == filtering.FilteredSafeSearch
default:
Expand Down

0 comments on commit 0df3260

Please sign in to comment.