all: imp code
This commit is contained in:
parent
0a001fffbe
commit
79272b299a
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue