mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-09 01:00:14 +03:00
Pull request 2183: AG-27492-client-runtime-index
Squashed commit of the following:
commit d0b37e3de1552ea42d776461045a76ff0ae18128
Merge: 025c29bcd ee619b2db
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Apr 4 18:58:08 2024 +0300
Merge branch 'master' into AG-27492-client-runtime-index
commit 025c29bcd279b5448908df7c3a1a997a64095641
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Apr 1 17:20:15 2024 +0300
client: imp code
commit 548a15c000db3989b1398e68fa4c05a450e93ea0
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Mar 28 13:43:17 2024 +0300
all: add tests
commit c9015e732f1e0475ec8cf95487c9ec56cd69a395
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Mar 25 16:33:30 2024 +0300
all: imp docs
commit 81e8b944928176733b2971b2b6400b55496a7843
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Mar 25 15:33:17 2024 +0300
all: imp code
commit 1428d60bf72d7a0ffd9dc854403391646f82c6cc
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Mon Mar 25 14:45:01 2024 +0300
all: client runtime index
This commit is contained in:
parent
ee619b2dbd
commit
fd25dcacbd
6 changed files with 219 additions and 59 deletions
internal/home
|
@ -101,17 +101,19 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http
|
|||
data.Clients = append(data.Clients, cj)
|
||||
}
|
||||
|
||||
for ip, rc := range clients.ipToRC {
|
||||
clients.runtimeIndex.Range(func(rc *client.Runtime) (cont bool) {
|
||||
src, host := rc.Info()
|
||||
cj := runtimeClientJSON{
|
||||
WHOIS: whoisOrEmpty(rc),
|
||||
Name: host,
|
||||
Source: src,
|
||||
IP: ip,
|
||||
IP: rc.Addr(),
|
||||
}
|
||||
|
||||
data.RuntimeClients = append(data.RuntimeClients, cj)
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
for _, l := range clients.dhcp.Leases() {
|
||||
cj := runtimeClientJSON{
|
||||
|
@ -463,8 +465,8 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http
|
|||
// /etc/hosts tables, DHCP leases, or blocklists. cj is guaranteed to be
|
||||
// non-nil.
|
||||
func (clients *clientsContainer) findRuntime(ip netip.Addr, idStr string) (cj *clientJSON) {
|
||||
rc, ok := clients.findRuntimeClient(ip)
|
||||
if !ok {
|
||||
rc := clients.findRuntimeClient(ip)
|
||||
if rc == nil {
|
||||
// It is still possible that the IP used to be in the runtime clients
|
||||
// list, but then the server was reloaded. So, check the DNS server's
|
||||
// blocked IP list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue