diff --git a/entry.lua b/entry.lua index 9c4c026..333f9d9 100644 --- a/entry.lua +++ b/entry.lua @@ -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 diff --git a/init.lua b/init.lua index e216ecc..d5a400c 100644 --- a/init.lua +++ b/init.lua @@ -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