Update anti-cc.lua

pull/11/head
有安科技 2022-10-12 13:05:43 +08:00 committed by GitHub
parent 8972c59063
commit b442d2d045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -17,15 +17,15 @@ local sh = ngx.shared.ipCache
local ccIp = 'cc-' .. waf.ip
local c, f = sh:get(ccIp)
if not c then
sh:set(ccIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间
sh:set(ccIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间
else
if f == 2 then
return waf.block(true) -- 重置TCP连接不记录日志
return waf.block(true) -- 重置TCP连接不记录日志
end
sh:incr(ccIp, 1)
if c + 1 >= 360 then
if c + 1 >= 360 then -- 频率超过360次
sh:set(ccIp, c + 1, 300, 2) -- 设置5分钟也就是300秒拦截时间
return true, ccIp, true
return true, ccIp, true -- 返回参数第一个true为是否检测到第二个参数ccIp为日志记录内容第三个参数true表示拦截false表示只记录不拦截
end
end