forked from no2key/nginx-lua-ds-waf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hevienz
committed
Jul 26, 2015
1 parent
2fdbbca
commit 2b1d0e3
Showing
8 changed files
with
322 additions
and
1,206 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
config = require("config") | ||
http = require("resty.http") | ||
uuid = require("resty.uuid") | ||
cjson = require("cjson") | ||
function ngxlog(...) | ||
ngx.log(ngx.ERR, "[NGINX-LUA-DS-WAF] ", ...) | ||
end | ||
|
||
local redis = require "resty.redis_iresty" | ||
red = redis:new() | ||
|
||
log_fd = io.open(config.log_pwd.."waf.log","ab") | ||
dymanic_block_ips_pool = ngx.shared.dymanic_block_ips_pool | ||
fd_log = io.open("/var/log/waf/waf.log","ab") | ||
|
||
function dslog(...) | ||
ngx.log(ngx.ERR, ...) | ||
function redis_get(key, default_value) | ||
local res, err = red:get(key) | ||
if not res then | ||
ngxlog("Can't get " .. key .. " from redis: ", err) | ||
return default_value | ||
else | ||
return res | ||
end | ||
end | ||
|
||
function split(str, sep) | ||
local fields = {} | ||
str:gsub("[^"..sep.."]+", function(c) fields[#fields+1] = c end) | ||
return fields | ||
function redis_smembers(key) | ||
local res, err = red:smembers(key) | ||
if not res then | ||
ngxlog("Can't get " .. key .. " from redis: ", err) | ||
else | ||
return res | ||
end | ||
end | ||
|
||
function dswaf_output() | ||
ngx.status = ngx.HTTP_FORBIDDEN | ||
ngx.say("You have been blocked by NGINX-LUA-DS-WAF.") | ||
ngx.exit(ngx.HTTP_FORBIDDEN) | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.