mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
up
This commit is contained in:
@@ -505,9 +505,9 @@ function _M.write_log(self, name, rule)
|
||||
|
||||
local count, _ = ngx.shared.waf_drop_ip:get(ip)
|
||||
if count then
|
||||
ngx.shared.waf_drop_ip:incr(ip,1)
|
||||
ngx.shared.waf_drop_ip:incr(ip, 1)
|
||||
else
|
||||
ngx.shared.waf_drop_ip:set(ip,1,retry_cycle)
|
||||
ngx.shared.waf_drop_ip:set(ip, 1, retry_cycle)
|
||||
end
|
||||
|
||||
if config['log'] ~= true or self:is_site_config('log') ~= true then return false end
|
||||
@@ -596,16 +596,6 @@ function _M.split_bylog_debug(self, str,reps)
|
||||
return resultStrList
|
||||
end
|
||||
|
||||
|
||||
function _M.split_bylog(self, str,reps)
|
||||
local resultStrList = {}
|
||||
string.gsub(str,'[^'..reps..']+', function(w)
|
||||
table.insert(resultStrList,w)
|
||||
end)
|
||||
return resultStrList
|
||||
end
|
||||
|
||||
|
||||
function _M.get_real_ip(self, server_name)
|
||||
local client_ip = "unknown"
|
||||
local site_config = self.site_config
|
||||
|
||||
@@ -231,7 +231,6 @@ local function waf_cc()
|
||||
local waf_limit = config['cc']['limit']
|
||||
local cycle = config['cc']['cycle']
|
||||
if count then
|
||||
|
||||
if count > waf_limit then
|
||||
|
||||
local safe_count, _ = ngx.shared.waf_drop_sum:get(ip)
|
||||
@@ -245,17 +244,17 @@ local function waf_cc()
|
||||
if lock_time > 86400 then lock_time = 86400 end
|
||||
|
||||
-- lock_time = 10
|
||||
ngx.shared.waf_drop_ip:set(ip,1,lock_time)
|
||||
ngx.shared.waf_drop_ip:set(ip, 1, lock_time)
|
||||
|
||||
C:write_log('cc',cycle..'秒内累计超过'..waf_limit..'次请求,封锁' .. lock_time .. '秒')
|
||||
C:write_drop_ip('cc',lock_time)
|
||||
ngx.exit(config['cc']['status'])
|
||||
return true
|
||||
else
|
||||
ngx.shared.waf_limit:incr(token,1)
|
||||
ngx.shared.waf_limit:incr(token, 1)
|
||||
end
|
||||
else
|
||||
ngx.shared.waf_drop_sum:set(ip,1,86400)
|
||||
ngx.shared.waf_drop_sum:set(ip, 1, 86400)
|
||||
ngx.shared.waf_limit:set(token, 1, cycle)
|
||||
end
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user