pull/63/head
parent
e083a1a7da
commit
8e4fc1657f
|
@ -12,7 +12,7 @@ ip_black_list = {}
|
||||||
--------- Init project ----------------
|
--------- Init project ----------------
|
||||||
require 'init'
|
require 'init'
|
||||||
--------- Access control limit --------
|
--------- Access control limit --------
|
||||||
if ip_check and (whiteIP() or blackIP()) then
|
if ip_check and (whiteIP(ip_white_list) or blackIP(ip_black_list)) then
|
||||||
elseif cc_deny and denyCC() then
|
elseif cc_deny and denyCC(cc_rate, cc_deny_seconds) then
|
||||||
else return
|
else return
|
||||||
end
|
end
|
||||||
|
|
8
init.lua
8
init.lua
|
@ -62,7 +62,7 @@ end
|
||||||
-- cookie_rules = readRule('cookie')
|
-- cookie_rules = readRule('cookie')
|
||||||
|
|
||||||
|
|
||||||
function debugSay(msg)
|
function debugSay(msg, debug)
|
||||||
if debug then
|
if debug then
|
||||||
ngx.header.content_type = "text/html"
|
ngx.header.content_type = "text/html"
|
||||||
ngx.status = ngx.HTTP_FORBIDDEN
|
ngx.status = ngx.HTTP_FORBIDDEN
|
||||||
|
@ -187,7 +187,7 @@ end
|
||||||
-- return false
|
-- return false
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
function denyCC()
|
function denyCC(cc_rate, cc_deny_seconds)
|
||||||
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, '/(.*)'))
|
||||||
|
@ -281,7 +281,7 @@ function innet(ip, network)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function whiteIP()
|
function whiteIP(ip_white_list, debug)
|
||||||
if next(ip_white_list) ~= nil then
|
if next(ip_white_list) ~= nil then
|
||||||
ip = getClientIp()
|
ip = getClientIp()
|
||||||
for _, wip in pairs(ip_white_list) do
|
for _, wip in pairs(ip_white_list) do
|
||||||
|
@ -296,7 +296,7 @@ function whiteIP()
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function blackIP()
|
function blackIP(ip_black_list, debug)
|
||||||
if next(ip_black_list) ~= nil then
|
if next(ip_black_list) ~= nil then
|
||||||
ip = getClientIp()
|
ip = getClientIp()
|
||||||
for _, bip in pairs(ip_black_list) do
|
for _, bip in pairs(ip_black_list) do
|
||||||
|
|
Loading…
Reference in New Issue