diff --git a/pkg/exprhelpers/crowdsec_cti.go b/pkg/exprhelpers/crowdsec_cti.go index 6440295c8..2aa0c534a 100644 --- a/pkg/exprhelpers/crowdsec_cti.go +++ b/pkg/exprhelpers/crowdsec_cti.go @@ -112,15 +112,16 @@ func CrowdsecCTI(params ...any) (any, error) { ctiResp, err := ctiClient.GetIPInfo(ip) ctiClient.Logger.Debugf("request for %s took %v", ip, time.Since(before)) if err != nil { - if err == cticlient.ErrUnauthorized { + switch err { + case cticlient.ErrUnauthorized: CTIApiEnabled = false ctiClient.Logger.Errorf("Invalid API key provided, disabling CTI API") return &cticlient.SmokeItem{}, cticlient.ErrUnauthorized - } else if err == cticlient.ErrLimit { + case cticlient.ErrLimit: CTIBackOffUntil = time.Now().Add(CTIBackOffDuration) ctiClient.Logger.Errorf("CTI API is throttled, will try again in %s", CTIBackOffDuration) return &cticlient.SmokeItem{}, cticlient.ErrLimit - } else { + default: ctiClient.Logger.Warnf("CTI API error : %s", err) return &cticlient.SmokeItem{}, fmt.Errorf("unexpected error : %v", err) }