pull/63/head
ibuler 2016-06-18 19:09:10 +08:00
parent 4787ba9060
commit 4d96926d19
1 changed files with 7 additions and 7 deletions

View File

@ -28,15 +28,15 @@ function log(method, url, data, tag)
if attack_log then if attack_log then
local realIp = getClientIp() local realIp = getClientIp()
local ua = ngx.var.http_user_agent local ua = ngx.var.http_user_agent
local servername=ngx.var.server_name local servername = ngx.var.server_name
local time=ngx.localtime() local time = ngx.localtime()
if ua then if ua then
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" \""..ua.."\" \""..tag.."\"\n" line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" \""..ua.."\" \""..tag.."\"\n"
else else
line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" - \""..tag.."\"\n" line = realIp.." ["..time.."] \""..method.." "..servername..url.."\" \""..data.."\" - \""..tag.."\"\n"
end end
local filename = logpath..'/'..servername.."_"..ngx.today().."_sec.log" local filename = logpath..'/'..servername.."_"..ngx.today().."_sec.log"
write(filename,line) write(filename, line)
end end
end end
@ -201,7 +201,7 @@ function denyCC(cc_rate, cc_deny_seconds)
if debug then if debug then
ngx.say('Deny by waf.') ngx.say('Deny by waf.')
ngx.exit('200') ngx.exit('200')
return false return true
else else
ngx.exit(404) ngx.exit(404)
end end
@ -211,7 +211,7 @@ function denyCC(cc_rate, cc_deny_seconds)
if req > cc_count then if req > cc_count then
limit:set(ip, 1, cc_deny_seconds) limit:set(ip, 1, cc_deny_seconds)
ngx.exit(404) ngx.exit(404)
return false return true
else else
limit:incr(token, 1) limit:incr(token, 1)
end end
@ -252,7 +252,7 @@ end
-- end -- end
function innet(ip, network) function innet(ip, network)
matched = string.match(ip, network) matched = string.match(network, ip)
if match then if match then
return true return true
else else