mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
allow to configure GC percentage
Added config option to set how often the garbage collector runs. For example: "Internal": { "GCPercent": 75 }, If this option is not specified in the config file, or the value is 0, then the GC percentage is not configured. More info: https://pkg.go.dev/runtime/debug#SetGCPercent
This commit is contained in:
parent
a389707eb6
commit
dc43d5913c
2 changed files with 16 additions and 3 deletions
|
@ -59,25 +59,31 @@ type (
|
|||
ebpfOptions struct {
|
||||
ModulesPath string `json:"ModulesPath"`
|
||||
}
|
||||
|
||||
internalOptions struct {
|
||||
GCPercent int `json:"GCPercent"`
|
||||
}
|
||||
)
|
||||
|
||||
// Config holds the values loaded from configFile
|
||||
type Config struct {
|
||||
LogLevel *int32 `json:"LogLevel"`
|
||||
FwOptions fwOptions `json:"FwOptions"`
|
||||
Firewall string `json:"Firewall"`
|
||||
Ebpf ebpfOptions `json:"Ebpf"`
|
||||
DefaultAction string `json:"DefaultAction"`
|
||||
DefaultDuration string `json:"DefaultDuration"`
|
||||
ProcMonitorMethod string `json:"ProcMonitorMethod"`
|
||||
FwOptions fwOptions `json:"FwOptions"`
|
||||
Ebpf ebpfOptions `json:"Ebpf"`
|
||||
Server serverConfig `json:"Server"`
|
||||
Rules rulesOptions `json:"Rules"`
|
||||
Stats statistics.StatsConfig `json:"Stats"`
|
||||
sync.RWMutex
|
||||
Internal internalOptions `json:"Internal"`
|
||||
|
||||
InterceptUnknown bool `json:"InterceptUnknown"`
|
||||
LogUTC bool `json:"LogUTC"`
|
||||
LogMicro bool `json:"LogMicro"`
|
||||
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
// Parse determines if the given configuration is ok.
|
||||
|
|
|
@ -4,6 +4,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/evilsocket/opensnitch/daemon/firewall"
|
||||
"github.com/evilsocket/opensnitch/daemon/log"
|
||||
"github.com/evilsocket/opensnitch/daemon/procmon/monitor"
|
||||
|
@ -123,6 +125,11 @@ func (c *Client) loadConfiguration(rawConfig []byte) bool {
|
|||
}
|
||||
}
|
||||
|
||||
if clientConfig.Internal.GCPercent > 0 {
|
||||
oldgcpercent := debug.SetGCPercent(clientConfig.Internal.GCPercent)
|
||||
log.Info("GC percent set to %d, previously was %d", clientConfig.Internal.GCPercent, oldgcpercent)
|
||||
}
|
||||
|
||||
c.rules.EnableChecksums(clientConfig.Rules.EnableChecksums)
|
||||
// TODO:
|
||||
//c.stats.SetLimits(clientConfig.Stats)
|
||||
|
|
Loading…
Add table
Reference in a new issue