all: resync with master

This commit is contained in:
Eugene Burkov
2025-03-17 20:56:05 +03:00
parent 2fc1e258ed
commit a829adad10
69 changed files with 1126 additions and 434 deletions

View File

@@ -12,6 +12,7 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/arpdb"
"github.com/AdguardTeam/AdGuardHome/internal/dhcpsvc"
"github.com/AdguardTeam/AdGuardHome/internal/filtering"
"github.com/AdguardTeam/AdGuardHome/internal/whois"
"github.com/AdguardTeam/dnsproxy/proxy"
"github.com/AdguardTeam/golibs/errors"
@@ -671,3 +672,38 @@ func (s *Storage) ClearUpstreamCache() {
s.upstreamManager.clearUpstreamCache()
}
// ApplyClientFiltering retrieves persistent client information using the
// ClientID or client IP address, and applies it to the filtering settings.
func (s *Storage) ApplyClientFiltering(id string, addr netip.Addr, setts *filtering.Settings) {
c, ok := s.index.findByClientID(id)
if !ok {
c, ok = s.index.findByIP(addr)
}
if !ok {
s.logger.Debug("no client filtering settings found", "clientid", id, "addr", addr)
return
}
s.logger.Debug("applying custom client filtering settings", "client_name", c.Name)
setts.ClientIP = addr
if c.UseOwnBlockedServices {
setts.BlockedServices = c.BlockedServices.Clone()
}
setts.ClientName = c.Name
setts.ClientTags = slices.Clone(c.Tags)
if !c.UseOwnSettings {
return
}
setts.FilteringEnabled = c.FilteringEnabled
setts.SafeSearchEnabled = c.SafeSearchConf.Enabled
setts.ClientSafeSearch = c.SafeSearch
setts.SafeBrowsingEnabled = c.SafeBrowsingEnabled
setts.ParentalEnabled = c.ParentalEnabled
}

View File

@@ -153,7 +153,9 @@ func (m *upstreamManager) isConfigChanged(cliConf *customUpstreamConfig) (ok boo
// upstream configuration.
func (m *upstreamManager) clearUpstreamCache() {
for _, c := range m.uidToCustomConf {
c.proxyConf.ClearCache()
if c.proxyConf != nil {
c.proxyConf.ClearCache()
}
}
}