* clients: move container object to "config"

Now the functions use parameter, not a global object.
This commit is contained in:
Simon Zolin
2019-07-09 18:19:50 +03:00
parent 1973901802
commit d51f43e27a
5 changed files with 81 additions and 78 deletions

View File

@@ -52,6 +52,7 @@ type configuration struct {
runningAsService bool
disableUpdate bool // If set, don't check for updates
appSignalChannel chan os.Signal
clients clientsContainer
BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
@@ -233,7 +234,7 @@ func parseConfig() error {
SafeSearchEnabled: cy.SafeSearchEnabled,
SafeBrowsingEnabled: cy.SafeBrowsingEnabled,
}
_, err = clientAdd(cli)
_, err = config.clients.Add(cli)
if err != nil {
log.Tracef("clientAdd: %s", err)
}
@@ -268,7 +269,7 @@ func (c *configuration) write() error {
c.Lock()
defer c.Unlock()
clientsList := clientsGetList()
clientsList := config.clients.GetList()
for _, cli := range clientsList {
ip := cli.IP
if len(cli.MAC) != 0 {