MCPcopy
hub / github.com/crowdsecurity/crowdsec / initAPIC

Method initAPIC

pkg/apiserver/apiserver.go:287–330  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

285}
286
287func (s *APIServer) initAPIC(ctx context.Context) {
288 s.apic.pushTomb.Go(func() error {
289 defer trace.ReportPanic()
290 return s.apicPush(ctx)
291 })
292 s.apic.pullTomb.Go(func() error {
293 defer trace.ReportPanic()
294 return s.apicPull(ctx)
295 })
296
297 if s.apic.apiClient.IsEnrolled() {
298 if s.papi != nil {
299 if s.papi.URL != "" {
300 log.Info("Starting PAPI decision receiver")
301 s.papi.pullTomb.Go(func() error {
302 defer trace.ReportPanic()
303 return s.papiPull(ctx)
304 })
305 s.papi.syncTomb.Go(func() error {
306 defer trace.ReportPanic()
307 return s.papiSync(ctx)
308 })
309 } else {
310 log.Warnf("papi_url is not set in online_api_credentials.yaml, can't synchronize with the console. Run cscli console enable console_management to add it.")
311 }
312 } else {
313 log.Warningf("Machine is not allowed to synchronize decisions, you can enable it with `cscli console enable console_management`")
314 }
315 }
316
317 s.apic.metricsTomb.Go(func() error {
318 defer trace.ReportPanic()
319 s.apic.SendMetrics(ctx, make(chan bool))
320 return nil
321 })
322
323 if !s.cfg.DisableUsageMetricsExport {
324 s.apic.metricsTomb.Go(func() error {
325 defer trace.ReportPanic()
326 s.apic.SendUsageMetrics(ctx)
327 return nil
328 })
329 }
330}
331
332func (s *APIServer) Run(ctx context.Context, apiReady chan bool) error {
333 tlsCfg, err := s.cfg.TLS.GetTLSConfig()

Callers 1

RunMethod · 0.95

Calls 8

apicPushMethod · 0.95
apicPullMethod · 0.95
papiPullMethod · 0.95
papiSyncMethod · 0.95
IsEnrolledMethod · 0.80
SendMetricsMethod · 0.80
SendUsageMetricsMethod · 0.80
InfoMethod · 0.45

Tested by

no test coverage detected