MCPcopy
hub / github.com/evilsocket/opensnitch / SetLimits

Method SetLimits

daemon/statistics/stats.go:100–118  ·  view source on GitHub ↗

SetLimits configures the max events to keep in the backlog before sending the stats to the UI, or while the UI is not connected. if the backlog is full, it'll be shifted by one.

(config StatsConfig)

Source from the content-addressed store, hash-verified

98// the stats to the UI, or while the UI is not connected.
99// if the backlog is full, it'll be shifted by one.
100func (s *Statistics) SetLimits(config StatsConfig) {
101 s.cancel()
102 s.ctx, s.cancel = context.WithCancel(context.Background())
103 if config.MaxEvents > 0 {
104 s.maxEvents = config.MaxEvents
105 }
106 if config.MaxStats > 0 {
107 s.maxStats = config.MaxStats
108 }
109 s.maxWorkers = config.Workers
110 if s.maxWorkers == 0 {
111 s.maxWorkers = 6
112 }
113 log.Info("Stats, max events: %d, max stats: %d, max workers: %d", s.maxStats, s.maxEvents, s.maxWorkers)
114 for i := 0; i < s.maxWorkers; i++ {
115 go s.eventWorker(i, s.ctx.Done())
116 }
117
118}
119
120// OnConnectionEvent sends the details of a new connection throughout a channel,
121// in order to add the connection to the stats.

Callers 1

reloadConfigurationMethod · 0.80

Calls 2

eventWorkerMethod · 0.95
DoneMethod · 0.65

Tested by

no test coverage detected