From e338214ad56137774ba7fe918e0d7c1166802bd7 Mon Sep 17 00:00:00 2001 From: Stanislav Chzhen Date: Thu, 19 Sep 2024 20:01:16 +0300 Subject: [PATCH] Pull request 2279: AG-27492-clients-runtime-sources-dhcp Squashed commit of the following: commit 51fb3e3d07752a33310b05d99726b248d3897335 Author: Stanislav Chzhen Date: Thu Sep 19 17:01:03 2024 +0300 all: upd chlog commit 3ab945bb442c921ffbfa14c1dd2825f8ed307999 Author: Stanislav Chzhen Date: Thu Sep 19 16:49:00 2024 +0300 home: clients runtime sources dhcp --- CHANGELOG.md | 2 ++ internal/home/clients.go | 7 +++++-- internal/home/clientshttp.go | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88573283..efb04e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ NOTE: Add new changes BELOW THIS COMMENT. ### Fixed +- Property `clients.runtime_sources.dhcp` in the configuration file not taking + effect. - Update Google safe search domains list ([#7155]). - Enforce Bing safe search from Edge sidebar ([#7154]). - Text overflow on the query log page ([#7119]). diff --git a/internal/home/clients.go b/internal/home/clients.go index 819564bc..341064f4 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -619,8 +619,11 @@ func (clients *clientsContainer) addHostLocked( ) (ok bool) { rc := client.NewRuntime(ip) rc.SetInfo(src, []string{host}) - if dhcpHost := clients.dhcp.HostByIP(ip); dhcpHost != "" { - rc.SetInfo(client.SourceDHCP, []string{dhcpHost}) + + if config.Clients.Sources.DHCP { + if dhcpHost := clients.dhcp.HostByIP(ip); dhcpHost != "" { + rc.SetInfo(client.SourceDHCP, []string{dhcpHost}) + } } clients.storage.UpdateRuntime(rc) diff --git a/internal/home/clientshttp.go b/internal/home/clientshttp.go index eba22ddb..f5f061e4 100644 --- a/internal/home/clientshttp.go +++ b/internal/home/clientshttp.go @@ -117,15 +117,17 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http return true }) - for _, l := range clients.dhcp.Leases() { - cj := runtimeClientJSON{ - Name: l.Hostname, - Source: client.SourceDHCP, - IP: l.IP, - WHOIS: &whois.Info{}, - } + if config.Clients.Sources.DHCP { + for _, l := range clients.dhcp.Leases() { + cj := runtimeClientJSON{ + Name: l.Hostname, + Source: client.SourceDHCP, + IP: l.IP, + WHOIS: &whois.Info{}, + } - data.RuntimeClients = append(data.RuntimeClients, cj) + data.RuntimeClients = append(data.RuntimeClients, cj) + } } data.Tags = clientTags