mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
ui client: fixed setting daemon config
- Fixed setting daemon config. - Removed unused code.
This commit is contained in:
parent
edc9b17010
commit
97703b65db
1 changed files with 11 additions and 20 deletions
|
@ -3,7 +3,6 @@ package ui
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/opensnitch/daemon/log"
|
"github.com/evilsocket/opensnitch/daemon/log"
|
||||||
|
@ -63,16 +62,18 @@ func (c *Client) loadDiskConfiguration(reload bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) loadConfiguration(rawConfig []byte) bool {
|
func (c *Client) loadConfiguration(rawConfig []byte) bool {
|
||||||
clientConfig.Lock()
|
var err error
|
||||||
defer clientConfig.Unlock()
|
clientConfig, err = config.Parse(rawConfig)
|
||||||
|
|
||||||
clientConfig, err := config.Parse(rawConfig)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("Error parsing configuration %s: %s", configFile, err)
|
msg := fmt.Sprintf("Error parsing configuration %s: %s", configFile, err)
|
||||||
log.Error(msg)
|
log.Error(msg)
|
||||||
c.SendWarningAlert(msg)
|
c.SendWarningAlert(msg)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientConfig.Lock()
|
||||||
|
defer clientConfig.Unlock()
|
||||||
|
|
||||||
// firstly load config level, to detect further errors if any
|
// firstly load config level, to detect further errors if any
|
||||||
if clientConfig.LogLevel != nil {
|
if clientConfig.LogLevel != nil {
|
||||||
log.SetLogLevel(int(*clientConfig.LogLevel))
|
log.SetLogLevel(int(*clientConfig.LogLevel))
|
||||||
|
@ -110,20 +111,10 @@ func (c *Client) loadConfiguration(rawConfig []byte) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
//c.stats.SetLimits(clientConfig.Stats)
|
||||||
|
//loggers.Load(clientConfig.Server.Loggers, clientConfig.Stats.Workers)
|
||||||
|
//stats.SetLoggers(loggers)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) saveConfiguration(rawConfig string) (err error) {
|
|
||||||
if _, err = config.Parse(rawConfig); err != nil {
|
|
||||||
return fmt.Errorf("Error parsing configuration %s: %s", rawConfig, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = os.Chmod(configFile, 0600); err != nil {
|
|
||||||
log.Warning("unable to set permissions to default config: %s", err)
|
|
||||||
}
|
|
||||||
if err = ioutil.WriteFile(configFile, []byte(rawConfig), 0644); err != nil {
|
|
||||||
log.Error("writing configuration to disk: %s", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue