all: imp code
This commit is contained in:
parent
0a001fffbe
commit
79272b299a
|
@ -17,8 +17,8 @@ import (
|
||||||
"github.com/AdguardTeam/golibs/log"
|
"github.com/AdguardTeam/golibs/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Tags is the list of available client tags.
|
// allowedTags is the list of available client tags.
|
||||||
var Tags = []string{
|
var allowedTags = []string{
|
||||||
"device_audio",
|
"device_audio",
|
||||||
"device_camera",
|
"device_camera",
|
||||||
"device_gameconsole",
|
"device_gameconsole",
|
||||||
|
@ -144,7 +144,7 @@ type Storage struct {
|
||||||
// NewStorage returns initialized client storage. conf must not be nil.
|
// NewStorage returns initialized client storage. conf must not be nil.
|
||||||
func NewStorage(conf *StorageConfig) (s *Storage, err error) {
|
func NewStorage(conf *StorageConfig) (s *Storage, err error) {
|
||||||
s = &Storage{
|
s = &Storage{
|
||||||
allowedTags: container.NewMapSet(Tags...),
|
allowedTags: container.NewMapSet(allowedTags...),
|
||||||
mu: &sync.Mutex{},
|
mu: &sync.Mutex{},
|
||||||
index: newIndex(),
|
index: newIndex(),
|
||||||
runtimeIndex: newRuntimeIndex(),
|
runtimeIndex: newRuntimeIndex(),
|
||||||
|
@ -575,3 +575,8 @@ func (s *Storage) RangeRuntime(f func(rc *Runtime) (cont bool)) {
|
||||||
|
|
||||||
s.runtimeIndex.rangeClients(f)
|
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
|
// TODO(e.burkov): The option should probably be returned, since hosts file
|
||||||
// currently used not only for clients' information enrichment, but also in
|
// currently used not only for clients' information enrichment, but also in
|
||||||
// the filtering module and upstream addresses resolution.
|
// the filtering module and upstream addresses resolution.
|
||||||
var EtcHosts client.HostsContainer = etcHosts
|
var hosts client.HostsContainer = etcHosts
|
||||||
if !config.Clients.Sources.HostsFile {
|
if !config.Clients.Sources.HostsFile {
|
||||||
EtcHosts = nil
|
hosts = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
clients.storage, err = client.NewStorage(&client.StorageConfig{
|
clients.storage, err = client.NewStorage(&client.StorageConfig{
|
||||||
InitialClients: confClients,
|
InitialClients: confClients,
|
||||||
DHCP: dhcpServer,
|
DHCP: dhcpServer,
|
||||||
EtcHosts: EtcHosts,
|
EtcHosts: hosts,
|
||||||
ARPDB: arpDB,
|
ARPDB: arpDB,
|
||||||
ARPClientsUpdatePeriod: arpClientsUpdatePeriod,
|
ARPClientsUpdatePeriod: arpClientsUpdatePeriod,
|
||||||
RuntimeSourceDHCP: config.Clients.Sources.DHCP,
|
RuntimeSourceDHCP: config.Clients.Sources.DHCP,
|
||||||
|
|
|
@ -119,7 +119,7 @@ func (clients *clientsContainer) handleGetClients(w http.ResponseWriter, r *http
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
data.Tags = client.Tags
|
data.Tags = clients.storage.AllowedTags()
|
||||||
|
|
||||||
aghhttp.WriteJSONResponseOK(w, r, data)
|
aghhttp.WriteJSONResponseOK(w, r, data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,6 +460,7 @@ func startDNSServer() error {
|
||||||
|
|
||||||
Context.filters.EnableFilters(false)
|
Context.filters.EnableFilters(false)
|
||||||
|
|
||||||
|
// TODO(s.chzhen): Pass context.
|
||||||
err := Context.clients.Start(context.TODO())
|
err := Context.clients.Start(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("starting clients container: %w", err)
|
return fmt.Errorf("starting clients container: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue