"ddos challenge" style script #4

Open
luna wants to merge 20 commits from claude/ddos-protection-challenge-01CMAtrK6Dt24x9Q3v6Gz9fS into mistress
2 changed files with 13 additions and 0 deletions
Showing only changes of commit d8b1b861ab - Show all commits

View file

@ -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

View file

@ -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 = {}