Pull request 2376: 7708-fix-client-addr

Updates #7708.

Squashed commit of the following:

commit 4dd61516c683e3c7eea7beed7e001f37726cae75
Merge: b0763a90b 85e6bf54c
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 20 14:03:11 2025 +0300

    Merge branch 'master' into 7708-fix-client-addr

commit b0763a90b70d2f1da6d31e2c5215509d4010220b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 20 13:14:44 2025 +0300

    all: fix client rules
This commit is contained in:
Ainar Garipov
2025-03-20 15:50:04 +03:00
parent 85e6bf54c9
commit 1eb1b1108c
7 changed files with 36 additions and 35 deletions

View File

@@ -675,6 +675,7 @@ func (s *Storage) ClearUpstreamCache() {
// ApplyClientFiltering retrieves persistent client information using the
// ClientID or client IP address, and applies it to the filtering settings.
// setts must not be nil.
func (s *Storage) ApplyClientFiltering(id string, addr netip.Addr, setts *filtering.Settings) {
c, ok := s.index.findByClientID(id)
if !ok {
@@ -689,8 +690,6 @@ func (s *Storage) ApplyClientFiltering(id string, addr netip.Addr, setts *filter
s.logger.Debug("applying custom client filtering settings", "client_name", c.Name)
setts.ClientIP = addr
if c.UseOwnBlockedServices {
setts.BlockedServices = c.BlockedServices.Clone()
}

View File

@@ -634,8 +634,9 @@ func (d *DNSFilter) enableFiltersLocked(async bool) {
// ApplyAdditionalFiltering enhances the provided filtering settings with
// blocked services and client-specific configurations.
func (d *DNSFilter) ApplyAdditionalFiltering(cliAddr netip.Addr, clientID string, setts *Settings) {
d.ApplyBlockedServices(setts)
setts.ClientIP = cliAddr
d.ApplyBlockedServices(setts)
d.applyClientFiltering(clientID, cliAddr, setts)
if setts.BlockedServices != nil {
// TODO(e.burkov): Get rid of this crutch.

View File

@@ -932,10 +932,9 @@ func (d *DNSFilter) matchHost(
ufReq := &urlfilter.DNSRequest{
Hostname: host,
SortedClientTags: setts.ClientTags,
// TODO(e.burkov): Wait for urlfilter update to pass net.IP.
ClientIP: setts.ClientIP,
ClientName: setts.ClientName,
DNSType: rrtype,
ClientIP: setts.ClientIP,
ClientName: setts.ClientName,
DNSType: rrtype,
}
d.engineLock.RLock()

View File

@@ -459,7 +459,6 @@ func (d *DNSFilter) handleCheckHost(w http.ResponseWriter, r *http.Request) {
addr, err := netip.ParseAddr(cli)
if err == nil {
setts.ClientIP = addr
d.ApplyAdditionalFiltering(addr, "", setts)
} else if cli != "" {
// TODO(s.chzhen): Set [Settings.ClientName] once urlfilter supports