From 0df32601bb9ee9ea4c03bec1d61de7e9a3a59dc4 Mon Sep 17 00:00:00 2001 From: Ainar Garipov Date: Sun, 26 Mar 2023 14:19:19 +0300 Subject: [PATCH] Pull request 1787: 5639-querylog-filter-fix Fixes #5639. Squashed commit of the following: commit 1aa02c8fa2b858f9c9a41c5dd6746d4d2e3de654 Author: Ainar Garipov Date: Sun Mar 26 13:39:29 2023 +0300 querylog: fix filtered log filter --- CHANGELOG.md | 3 +++ internal/querylog/searchcriterion.go | 16 +++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 697ecfcf..20ffa2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]). @@ -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 diff --git a/internal/querylog/searchcriterion.go b/internal/querylog/searchcriterion.go index d5363451..a8942a83 100644 --- a/internal/querylog/searchcriterion.go +++ b/internal/querylog/searchcriterion.go @@ -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: @@ -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 { @@ -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: