pull/63/head
ibuler 2016-06-18 19:18:00 +08:00
parent 48335cb152
commit 73dc10d827
2 changed files with 4 additions and 4 deletions

View File

@ -7,7 +7,7 @@ cc_rate = '10/60'
--------- Init project ---------------- --------- Init project ----------------
require 'init' require 'init'
--------- Access control limit -------- --------- Access control limit --------
if cc_deny and denyCC(cc_rate, cc_deny_seconds) then if ip_check and (whiteIP() or blackIP()) then
elseif ip_check and (whiteIP() or blackIP()) then elseif cc_deny and denyCC() then
else return else return
end end

View File

@ -187,7 +187,7 @@ end
-- return false -- return false
-- end -- end
function denyCC(cc_rate, cc_deny_seconds) function denyCC()
local uri = ngx.var.uri local uri = ngx.var.uri
cc_count = tonumber(string.match(cc_rate, '(.*)/')) cc_count = tonumber(string.match(cc_rate, '(.*)/'))
cc_seconds = 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 ip == bip or ip == "0.0.0.0" or innet(ip, bip) then
if debug then if debug then
ngx.say(ip.."in black list <br/>") ngx.say(ip.."in black list <br/>")
end end
ngx.exit(403) ngx.exit(403)
return true return true
end end