mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-10-26 18:20:14 +03:00
home: imp naming
This commit is contained in:
parent
4e4aa5802c
commit
76469ac594
@ -56,8 +56,9 @@ type clientsContainer struct {
|
|||||||
// dhcp is the DHCP service implementation.
|
// dhcp is the DHCP service implementation.
|
||||||
dhcp DHCP
|
dhcp DHCP
|
||||||
|
|
||||||
// dnsServer is used for checking clients IP status access list status
|
// clientChecker checks if a client is blocked by the current access
|
||||||
dnsServer BlockedClientChecker
|
// settings.
|
||||||
|
clientChecker BlockedClientChecker
|
||||||
|
|
||||||
// etcHosts contains list of rewrite rules taken from the operating system's
|
// etcHosts contains list of rewrite rules taken from the operating system's
|
||||||
// hosts database.
|
// hosts database.
|
||||||
@ -408,7 +409,7 @@ func (clients *clientsContainer) clientOrArtificial(
|
|||||||
id string,
|
id string,
|
||||||
) (c *querylog.Client, art bool) {
|
) (c *querylog.Client, art bool) {
|
||||||
defer func() {
|
defer func() {
|
||||||
c.Disallowed, c.DisallowedRule = clients.dnsServer.IsBlockedClient(ip, id)
|
c.Disallowed, c.DisallowedRule = clients.clientChecker.IsBlockedClient(ip, id)
|
||||||
if c.WHOIS == nil {
|
if c.WHOIS == nil {
|
||||||
c.WHOIS = &whois.Info{}
|
c.WHOIS = &whois.Info{}
|
||||||
}
|
}
|
||||||
@ -543,12 +544,7 @@ func (clients *clientsContainer) findDHCP(ip netip.Addr) (c *client.Persistent,
|
|||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
c, found := clients.clientIndex.FindByMAC(foundMAC)
|
return clients.clientIndex.FindByMAC(foundMAC)
|
||||||
if found {
|
|
||||||
return c, true
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// runtimeClient returns a runtime client from internal index. Note that it
|
// runtimeClient returns a runtime client from internal index. Note that it
|
||||||
|
@ -451,7 +451,7 @@ func (clients *clientsContainer) handleFindClient(w http.ResponseWriter, r *http
|
|||||||
cj = clients.findRuntime(ip, idStr)
|
cj = clients.findRuntime(ip, idStr)
|
||||||
} else {
|
} else {
|
||||||
cj = clientToJSON(c)
|
cj = clientToJSON(c)
|
||||||
disallowed, rule := clients.dnsServer.IsBlockedClient(ip, idStr)
|
disallowed, rule := clients.clientChecker.IsBlockedClient(ip, idStr)
|
||||||
cj.Disallowed, cj.DisallowedRule = &disallowed, &rule
|
cj.Disallowed, cj.DisallowedRule = &disallowed, &rule
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ func (clients *clientsContainer) findRuntime(ip netip.Addr, idStr string) (cj *c
|
|||||||
// blocked IP list.
|
// blocked IP list.
|
||||||
//
|
//
|
||||||
// See https://github.com/AdguardTeam/AdGuardHome/issues/2428.
|
// See https://github.com/AdguardTeam/AdGuardHome/issues/2428.
|
||||||
disallowed, rule := clients.dnsServer.IsBlockedClient(ip, idStr)
|
disallowed, rule := clients.clientChecker.IsBlockedClient(ip, idStr)
|
||||||
cj = &clientJSON{
|
cj = &clientJSON{
|
||||||
IDs: []string{idStr},
|
IDs: []string{idStr},
|
||||||
Disallowed: &disallowed,
|
Disallowed: &disallowed,
|
||||||
@ -492,7 +492,7 @@ func (clients *clientsContainer) findRuntime(ip netip.Addr, idStr string) (cj *c
|
|||||||
WHOIS: whoisOrEmpty(rc),
|
WHOIS: whoisOrEmpty(rc),
|
||||||
}
|
}
|
||||||
|
|
||||||
disallowed, rule := clients.dnsServer.IsBlockedClient(ip, idStr)
|
disallowed, rule := clients.clientChecker.IsBlockedClient(ip, idStr)
|
||||||
cj.Disallowed, cj.DisallowedRule = &disallowed, &rule
|
cj.Disallowed, cj.DisallowedRule = &disallowed, &rule
|
||||||
|
|
||||||
return cj
|
return cj
|
||||||
|
@ -70,7 +70,7 @@ func newPersistentClientWithIDs(tb testing.TB, name string, ids []string) (c *cl
|
|||||||
func assertClients(tb testing.TB, want, got []*client.Persistent) {
|
func assertClients(tb testing.TB, want, got []*client.Persistent) {
|
||||||
tb.Helper()
|
tb.Helper()
|
||||||
|
|
||||||
require.Len(tb, want, len(got))
|
require.Len(tb, got, len(want))
|
||||||
|
|
||||||
sortFunc := func(a, b *client.Persistent) (n int) {
|
sortFunc := func(a, b *client.Persistent) (n int) {
|
||||||
return cmp.Compare(a.Name, b.Name)
|
return cmp.Compare(a.Name, b.Name)
|
||||||
@ -335,7 +335,7 @@ func TestClientsContainer_HandleUpdateClient(t *testing.T) {
|
|||||||
|
|
||||||
func TestClientsContainer_HandleFindClient(t *testing.T) {
|
func TestClientsContainer_HandleFindClient(t *testing.T) {
|
||||||
clients := newClientsContainer(t)
|
clients := newClientsContainer(t)
|
||||||
clients.dnsServer = &testBlockedClientChecker{
|
clients.clientChecker = &testBlockedClientChecker{
|
||||||
onIsBlockedClient: func(ip netip.Addr, clientID string) (ok bool, rule string) {
|
onIsBlockedClient: func(ip netip.Addr, clientID string) (ok bool, rule string) {
|
||||||
return false, ""
|
return false, ""
|
||||||
},
|
},
|
||||||
|
@ -149,7 +149,7 @@ func initDNSServer(
|
|||||||
return fmt.Errorf("dnsforward.NewServer: %w", err)
|
return fmt.Errorf("dnsforward.NewServer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Context.clients.dnsServer = Context.dnsServer
|
Context.clients.clientChecker = Context.dnsServer
|
||||||
|
|
||||||
dnsConf, err := newServerConfig(&config.DNS, config.Clients.Sources, tlsConf, httpReg)
|
dnsConf, err := newServerConfig(&config.DNS, config.Clients.Sources, tlsConf, httpReg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user