mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
fix invalid session error handling and remove debug log in whitelist
This commit is contained in:
parent
e55912b34d
commit
a372ffd521
3 changed files with 7 additions and 17 deletions
|
|
@ -439,7 +439,7 @@ utils.get_session = function()
|
|||
local _session, err, exists, refreshed = session.start()
|
||||
ngx.ctx.bw.session_err = nil
|
||||
if err and err ~= "missing session cookie" and err ~= "no session" then
|
||||
logger:log(ngx.ERR, "can't start session : " .. err)
|
||||
logger:log(ngx.WARN, "can't start session : " .. err)
|
||||
ngx.ctx.bw.session_err = err
|
||||
end
|
||||
ngx.ctx.bw.session = _session
|
||||
|
|
@ -455,7 +455,7 @@ end
|
|||
|
||||
utils.save_session = function()
|
||||
-- Check if save is needed
|
||||
if ngx.ctx.bw.session and not ngx.ctx.bw.session_err and not ngx.ctx.bw.session_saved then
|
||||
if ngx.ctx.bw.session and not ngx.ctx.bw.session_saved then
|
||||
ngx.ctx.bw.session:set_data(ngx.ctx.bw.session_data)
|
||||
local ok, err = ngx.ctx.bw.session:save()
|
||||
if err then
|
||||
|
|
@ -472,7 +472,7 @@ end
|
|||
|
||||
utils.set_session_var = function(key, value)
|
||||
-- Set new data
|
||||
if ngx.ctx.bw.session and not ngx.ctx.bw.session_err then
|
||||
if ngx.ctx.bw.session then
|
||||
ngx.ctx.bw.session_data[key] = value
|
||||
return true, "value set"
|
||||
end
|
||||
|
|
@ -481,7 +481,7 @@ end
|
|||
|
||||
utils.get_session_var = function(key)
|
||||
-- Get data
|
||||
if ngx.ctx.bw.session and not ngx.ctx.bw.session_err then
|
||||
if ngx.ctx.bw.session then
|
||||
if ngx.ctx.bw.session_data[key] then
|
||||
return true, "data present", ngx.ctx.bw.session_data[key]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -93,9 +93,7 @@ end
|
|||
|
||||
function antibot:challenge_resolved()
|
||||
local session, err, exists, refreshed = utils.get_session()
|
||||
if err then
|
||||
return nil, "session error : " .. err
|
||||
elseif not exists then
|
||||
if not exists then
|
||||
return false, "no session set"
|
||||
end
|
||||
local ok, err, raw_data = utils.get_session_var("antibot")
|
||||
|
|
@ -111,9 +109,6 @@ end
|
|||
|
||||
function antibot:prepare_challenge()
|
||||
local session, err, exists, refreshed = utils.get_session()
|
||||
if err then
|
||||
return false, "session error : " .. err
|
||||
end
|
||||
local set_needed = false
|
||||
local data = nil
|
||||
if exists then
|
||||
|
|
@ -158,9 +153,7 @@ end
|
|||
function antibot:display_challenge()
|
||||
-- Open session
|
||||
local session, err, exists, refreshed = utils.get_session()
|
||||
if err then
|
||||
return false, "can't open session : " .. err
|
||||
elseif not exists then
|
||||
if not exists then
|
||||
return false, "no session set"
|
||||
end
|
||||
|
||||
|
|
@ -210,9 +203,7 @@ end
|
|||
function antibot:check_challenge()
|
||||
-- Open session
|
||||
local session, err, exists, refreshed = utils.get_session()
|
||||
if err then
|
||||
return nil, "can't open session : " .. err, nil
|
||||
elseif not exists then
|
||||
if not exists then
|
||||
return false, "no session set"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ function whitelist:initialize()
|
|||
}
|
||||
for kind, _ in pairs(kinds) do
|
||||
for data in self.variables["WHITELIST_" .. kind]:gmatch("%S+") do
|
||||
self.logger:log(ngx.ERR, data)
|
||||
table.insert(self.lists[kind], data)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue