From 6ab8ccb9db04e374770f902622ebec9fb00f4ff7 Mon Sep 17 00:00:00 2001 From: Max Lerebourg Date: Thu, 29 Sep 2022 10:02:58 +0200 Subject: [PATCH] fix lint --- bouncer.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bouncer.go b/bouncer.go index 8bbd8ee..92245af 100644 --- a/bouncer.go +++ b/bouncer.go @@ -256,12 +256,12 @@ func contains(source []string, target string) bool { // Get Decision check in the cache if the IP has the banned / not banned value. // Otherwise return with an error to add the IP in cache if we are on. func getDecision(clientIP string) (bool, error) { - isBanned, ok := cache.Get(clientIP) - banned, err := isBanned.(string) - if ok && err == nil && len(banned) > 0 { - return isBanned == cacheNoBannedValue, nil + banned, isCached := cache.Get(clientIP) + bannedString, isValid := banned.(string) + if isCached && !isValid && len(bannedString) > 0 { + return bannedString == cacheNoBannedValue, nil } - return false, fmt.Errorf("no data") + return false, fmt.Errorf("no cache data") } func setDecision(clientIP string, isBanned bool, duration int64) {