From 41c37b9d1f77c9be6edeb3955218bb928fc203fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E5=AE=89=E7=A7=91=E6=8A=80?= Date: Fri, 23 Sep 2022 21:53:17 +0800 Subject: [PATCH 1/4] Update anti-cc.lua --- rules/anti-cc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/anti-cc.lua b/rules/anti-cc.lua index 502416b..309a676 100644 --- a/rules/anti-cc.lua +++ b/rules/anti-cc.lua @@ -20,7 +20,7 @@ if not c then sh:set(ccIp, 0, 60, 1) -- 设置1分钟也就是60秒访问计数时间 else if f == 2 then - return waf.block(true) + return true, ccIp, true end sh:incr(ccIp, 1) if c >= 360 then From b3907f2f28213f01bdaf8f02b3ffcf18510b4373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E5=AE=89=E7=A7=91=E6=8A=80?= Date: Fri, 23 Sep 2022 22:07:33 +0800 Subject: [PATCH 2/4] Update anti-cc.lua --- rules/anti-cc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rules/anti-cc.lua b/rules/anti-cc.lua index 309a676..d572bd5 100644 --- a/rules/anti-cc.lua +++ b/rules/anti-cc.lua @@ -17,13 +17,13 @@ local sh = ngx.shared.ipCache local ccIp = 'cc-' .. waf.ip local c, f = sh:get(ccIp) if not c then - sh:set(ccIp, 0, 60, 1) -- 设置1分钟也就是60秒访问计数时间 + sh:set(ccIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间 else if f == 2 then - return true, ccIp, true + return waf.block(true) end sh:incr(ccIp, 1) - if c >= 360 then + if c + 1 >= 360 then sh:set(ccIp, c, 300, 2) -- 设置5分钟也就是300秒拦截时间 end end From 88e7ff6e7be101fc6ba11ff694410aa416b3fa08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E5=AE=89=E7=A7=91=E6=8A=80?= Date: Fri, 23 Sep 2022 22:08:47 +0800 Subject: [PATCH 3/4] Update anti-cc.lua --- rules/anti-cc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/anti-cc.lua b/rules/anti-cc.lua index d572bd5..ff668d3 100644 --- a/rules/anti-cc.lua +++ b/rules/anti-cc.lua @@ -24,7 +24,7 @@ else end sh:incr(ccIp, 1) if c + 1 >= 360 then - sh:set(ccIp, c, 300, 2) -- 设置5分钟也就是300秒拦截时间 + sh:set(ccIp, c + 1, 300, 2) -- 设置5分钟也就是300秒拦截时间 end end From dc4c436b000dafa91fb1893c8c10bdd53a47468c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E5=AE=89=E7=A7=91=E6=8A=80?= Date: Fri, 23 Sep 2022 22:13:35 +0800 Subject: [PATCH 4/4] Update anti-cc.lua --- rules/anti-cc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/anti-cc.lua b/rules/anti-cc.lua index ff668d3..3ee10c6 100644 --- a/rules/anti-cc.lua +++ b/rules/anti-cc.lua @@ -20,11 +20,12 @@ if not c then sh:set(ccIp, 1, 60, 1) -- 设置1分钟也就是60秒访问计数时间 else if f == 2 then - return waf.block(true) + return waf.block(true) -- 重置TCP连接,不记录日志 end sh:incr(ccIp, 1) if c + 1 >= 360 then sh:set(ccIp, c + 1, 300, 2) -- 设置5分钟也就是300秒拦截时间 + return true, ccIp, true end end