diff --git a/entry.lua b/entry.lua index 7516e43..58d5392 100644 --- a/entry.lua +++ b/entry.lua @@ -7,7 +7,7 @@ cc_rate = '10/60' --------- Init project ---------------- require 'init' --------- Access control limit -------- -if cc_deny and denyCC(cc_rate, cc_deny_seconds) then -elseif ip_check and (whiteIP() or blackIP()) then +if ip_check and (whiteIP() or blackIP()) then +elseif cc_deny and denyCC() then else return end diff --git a/init.lua b/init.lua index c747509..dc85d9b 100644 --- a/init.lua +++ b/init.lua @@ -187,7 +187,7 @@ end -- return false -- end -function denyCC(cc_rate, cc_deny_seconds) +function denyCC() local uri = ngx.var.uri cc_count = tonumber(string.match(cc_rate, '(.*)/')) cc_seconds = tonumber(string.match(cc_rate, '/(.*)')) @@ -282,7 +282,7 @@ function blackIP() if ip == bip or ip == "0.0.0.0" or innet(ip, bip) then if debug then ngx.say(ip.."in black list
") - end + end ngx.exit(403) return true end