Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hevienz committed Jul 26, 2015
1 parent 2fdbbca commit 2b1d0e3
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 1,206 deletions.
71 changes: 0 additions & 71 deletions config.lua

This file was deleted.

39 changes: 27 additions & 12 deletions init.lua
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
8 changes: 0 additions & 8 deletions monitor.lua

This file was deleted.

Loading

0 comments on commit 2b1d0e3

Please sign in to comment.