pull/63/head
ibuler 2016-06-19 11:49:13 +08:00
parent e083a1a7da
commit 8e4fc1657f
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@ ip_black_list = {}
--------- Init project ----------------
require 'init'
--------- Access control limit --------
if ip_check and (whiteIP() or blackIP()) then
elseif cc_deny and denyCC() then
if ip_check and (whiteIP(ip_white_list) or blackIP(ip_black_list)) then
elseif cc_deny and denyCC(cc_rate, cc_deny_seconds) then
else return
end

View File

@ -62,7 +62,7 @@ end
-- cookie_rules = readRule('cookie')
function debugSay(msg)
function debugSay(msg, debug)
if debug then
ngx.header.content_type = "text/html"
ngx.status = ngx.HTTP_FORBIDDEN
@ -187,7 +187,7 @@ end
-- return false
-- end
function denyCC()
function denyCC(cc_rate, cc_deny_seconds)
local uri = ngx.var.uri
cc_count = tonumber(string.match(cc_rate, '(.*)/'))
cc_seconds = tonumber(string.match(cc_rate, '/(.*)'))
@ -281,7 +281,7 @@ function innet(ip, network)
end
end
function whiteIP()
function whiteIP(ip_white_list, debug)
if next(ip_white_list) ~= nil then
ip = getClientIp()
for _, wip in pairs(ip_white_list) do
@ -296,7 +296,7 @@ function whiteIP()
return false
end
function blackIP()
function blackIP(ip_black_list, debug)
if next(ip_black_list) ~= nil then
ip = getClientIp()
for _, bip in pairs(ip_black_list) do