convert ifelseif to switch (#2529)
This commit is contained in:
parent
9ae8bd79c5
commit
0dd22e8b93
1 changed files with 4 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue