"ddos challenge" style script #4
2 changed files with 13 additions and 0 deletions
|
|
@ -539,12 +539,19 @@ local function challengeCallback(cfg, state)
|
|||
|
||||
-- Check for valid token cookie
|
||||
local headers = ngx.req.get_headers()
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers type = " .. type(headers))
|
||||
if headers then
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers.Cookie = " .. tostring(headers["Cookie"]))
|
||||
ngx.log(ngx.DEBUG, "DEBUG: headers.cookie = " .. tostring(headers["cookie"]))
|
||||
end
|
||||
local cookie_header = headers["Cookie"]
|
||||
local token = getCookieValue(cookie_header, cfg.cookie_name)
|
||||
ngx.log(ngx.DEBUG, "DEBUG: token extracted = " .. tostring(token))
|
||||
|
||||
if token then
|
||||
-- Verify token is still valid in shared dict
|
||||
local is_valid = state.tokens_dict:get(token)
|
||||
ngx.log(ngx.DEBUG, "DEBUG: token is_valid = " .. tostring(is_valid))
|
||||
if is_valid then
|
||||
-- Token is valid, allow request through
|
||||
return nil
|
||||
|
|
|
|||
6
test.lua
6
test.lua
|
|
@ -20,6 +20,12 @@ function createNgx()
|
|||
print(msg)
|
||||
end
|
||||
|
||||
-- Log level constants
|
||||
ngx.DEBUG = 7
|
||||
ngx.INFO = 6
|
||||
ngx.WARN = 4
|
||||
ngx.ERR = 3
|
||||
|
||||
-- only hold data here
|
||||
ngx.var = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue