diff --git a/internal/client/storage.go b/internal/client/storage.go index 4d65de48..ccd6b15f 100644 --- a/internal/client/storage.go +++ b/internal/client/storage.go @@ -17,8 +17,8 @@ import ( "github.com/AdguardTeam/golibs/log" ) -// Tags is the list of available client tags. -var Tags = []string{ +// allowedTags is the list of available client tags. +var allowedTags = []string{ "device_audio", "device_camera", "device_gameconsole", @@ -144,7 +144,7 @@ type Storage struct { // NewStorage returns initialized client storage. conf must not be nil. func NewStorage(conf *StorageConfig) (s *Storage, err error) { s = &Storage{ - allowedTags: container.NewMapSet(Tags...), + allowedTags: container.NewMapSet(allowedTags...), mu: &sync.Mutex{}, index: newIndex(), runtimeIndex: newRuntimeIndex(), @@ -575,3 +575,8 @@ func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) { s.runtimeIndex.rangeClients(f) } + +// AllowedTags returns the list of available client tags. +func (s *Storage) AllowedTags() (tags []string) { + return allowedTags +} diff --git a/internal/home/clients.go b/internal/home/clients.go index 63f30dd4..66a44a62 100644 --- a/internal/home/clients.go +++ b/internal/home/clients.go @@ -89,15 +89,15 @@ func (clients *clientsContainer) Init( // TODO(e.burkov): The option should probably be returned, since hosts file // currently used not only for clients' information enrichment, but also in // the filtering module and upstream addresses resolution. - var EtcHosts client.HostsContainer = etcHosts + var hosts client.HostsContainer = etcHosts if !config.Clients.Sources.HostsFile { - EtcHosts = nil + hosts = nil } clients.storage, err = client.NewStorage(&client.StorageConfig{ InitialClients: confClients, DHCP: dhcpServer, - EtcHosts: EtcHosts, + EtcHosts: hosts, ARPDB: arpDB, ARPClientsUpdatePeriod: arpClientsUpdatePeriod, RuntimeSourceDHCP: config.Clients.Sources.DHCP, diff --git a/internal/home/clientshttp.go b/internal/home/clientshttp.go index a977acc0..73259d29 100644 --- a/internal/home/clientshttp.go +++ b/internal/home/clientshttp.go @@ -119,7 +119,7 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http return true }) - data.Tags = client.Tags + data.Tags = clients.storage.AllowedTags() aghhttp.WriteJSONResponseOK(w, r, data) } diff --git a/internal/home/dns.go b/internal/home/dns.go index f1a23517..9dd711f5 100644 --- a/internal/home/dns.go +++ b/internal/home/dns.go @@ -460,6 +460,7 @@ func startDNSServer() error { Context.filters.EnableFilters(false) + // TODO(s.chzhen): Pass context. err := Context.clients.Start(context.TODO()) if err != nil { return fmt.Errorf("starting clients container: %w", err)