计算CC的时候不再跨时间范围累积

This commit is contained in:
刘祥超
2022-05-12 21:48:33 +08:00
parent 84a5d38b0b
commit 45620dcdb7
7 changed files with 13 additions and 11 deletions

View File

@@ -167,7 +167,7 @@ func (this *CaptchaValidator) validate(actionConfig *CaptchaAction, maxFails int
} else {
// 增加计数
if maxFails > 0 && failBlockTimeout > 0 {
var countFails = ttlcache.SharedCache.IncreaseInt64("CAPTCHA:FAILS:"+request.WAFRemoteIP(), 1, time.Now().Unix()+300)
var countFails = ttlcache.SharedCache.IncreaseInt64("CAPTCHA:FAILS:"+request.WAFRemoteIP(), 1, time.Now().Unix()+300, true)
if int(countFails) >= maxFails {
SharedIPBlackList.RecordIP(IPTypeAll, firewallconfigs.FirewallScopeService, request.WAFServerId(), request.WAFRemoteIP(), time.Now().Unix()+int64(failBlockTimeout), policyId, false, groupId, setId, "CAPTCHA验证连续失败")
return false