From 5e626306d1d02661d0574ae031e8ff194013c87a Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Mon, 3 Oct 2022 00:02:35 +0530 Subject: [PATCH 1/3] bugfix: Fixed bug which was causing clients to continue following global service blocks even when user opted to not do that --- internal/home/dns.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/home/dns.go b/internal/home/dns.go index 06c38bcc..c533807e 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -335,8 +335,6 @@ func applyAdditionalFiltering(clientIP net.IP, clientID string, setts *filtering // pref is a prefix for logging messages around the scope. const pref = "applying filters" - Context.filters.ApplyBlockedServices(setts, nil) - log.Debug("%s: looking for client with ip %s and clientid %q", pref, clientIP, clientID) if clientIP == nil { @@ -359,6 +357,8 @@ func applyAdditionalFiltering(clientIP net.IP, clientID string, setts *filtering if c.UseOwnBlockedServices { Context.filters.ApplyBlockedServices(setts, c.BlockedServices) + } else { + Context.filters.ApplyBlockedServices(setts, nil) } setts.ClientName = c.Name From 27032ef79e3013f439b11c2d22c1dba9bde0c858 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 3 Oct 2022 17:30:03 +0300 Subject: [PATCH 2/3] home: fix empty svcs --- internal/home/clients.go | 4 ---- internal/home/dns.go | 12 +++++++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/home/clients.go b/internal/home/clients.go index 61802831..7396e8c6 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -244,10 +244,6 @@ func (clients *clientsContainer) addFromConfig(objects []*clientObject) { } } - if cli.BlockedServices == nil && cli.UseOwnBlockedServices { - cli.BlockedServices = []string{} - } - for _, t := range o.Tags { if clients.allTags.Has(t) { cli.Tags = append(cli.Tags, t) diff --git a/internal/home/dns.go b/internal/home/dns.go index c533807e..79901c27 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -335,6 +335,8 @@ func applyAdditionalFiltering(clientIP net.IP, clientID string, setts *filtering // pref is a prefix for logging messages around the scope. const pref = "applying filters" + Context.filters.ApplyBlockedServices(setts, nil) + log.Debug("%s: looking for client with ip %s and clientid %q", pref, clientIP, clientID) if clientIP == nil { @@ -356,9 +358,13 @@ func applyAdditionalFiltering(clientIP net.IP, clientID string, setts *filtering log.Debug("%s: using settings for client %q (%s; %q)", pref, c.Name, clientIP, clientID) if c.UseOwnBlockedServices { - Context.filters.ApplyBlockedServices(setts, c.BlockedServices) - } else { - Context.filters.ApplyBlockedServices(setts, nil) + // TODO(e.burkov): Get rid of this crutch. + svcs := c.BlockedServices + if svcs == nil { + svcs = []string{} + } + Context.filters.ApplyBlockedServices(setts, svcs) + log.Debug("services set: %v", setts.ServicesRules) } setts.ClientName = c.Name From 739e0098ec127045197ea697bae78acb2bd2c729 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Mon, 3 Oct 2022 17:48:11 +0300 Subject: [PATCH 3/3] all: imp code, wording --- CHANGELOG.md | 6 +++++- internal/home/dns.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a75ffcc3..1f537699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,8 @@ and this project adheres to ### Fixed -- User-specific blocked services not applying correctly. +- User-specific blocked services not applying correctly ([#4945], [#4982], + [#4983]). - `only application/json is allowed` errors in various APIs ([#4970]). [#4970]: https://github.com/AdguardTeam/AdGuardHome/issues/4970 @@ -96,6 +97,9 @@ All JSON APIs that expect a body now check if the request actually has [#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993 [#4927]: https://github.com/AdguardTeam/AdGuardHome/issues/4927 [#4930]: https://github.com/AdguardTeam/AdGuardHome/issues/4930 +[#4945]: https://github.com/AdguardTeam/AdGuardHome/issues/4945 +[#4982]: https://github.com/AdguardTeam/AdGuardHome/issues/4982 +[#4983]: https://github.com/AdguardTeam/AdGuardHome/issues/4983 [ms-v0.107.14]: https://github.com/AdguardTeam/AdGuardHome/milestone/50?closed=1 diff --git a/internal/home/dns.go b/internal/home/dns.go index 79901c27..c304f6cc 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -364,7 +364,7 @@ func applyAdditionalFiltering(clientIP net.IP, clientID string, setts *filtering svcs = []string{} } Context.filters.ApplyBlockedServices(setts, svcs) - log.Debug("services set: %v", setts.ServicesRules) + log.Debug("%s: services for client %q set: %s", pref, c.Name, svcs) } setts.ClientName = c.Name