fix wrong log in access

This commit is contained in:
bunkerity 2023-04-18 14:26:30 +02:00
parent 8e22b1f219
commit a83254bf20
2 changed files with 26 additions and 1 deletions

View File

@ -84,4 +84,29 @@ helpers.call_plugin = function(plugin, method)
return true, ret
end
helpers.fill_ctx = function()
-- Check if ctx is already filled
if ngx.ctx.bw then
return true, "already filled"
end
-- Return errors as table
local errors = {}
-- Instantiate bw table
local data = {}
-- Common vars
data.ip = ngx.var.remote_addr
data.uri = ngx.var.uri
data.original_uri = ngx.var.original_uri
data.user_agent = ngx.var.http_user_agent
-- Global IP
local ip_is_global, err = utils.ip_is_global(data.ip)
if ip_is_global == nil then
table.insert(errors, "can't check if IP is global : " .. err)
else
data.ip_is_global = ip_is_global
end
-- ctx filled
return true, "ctx filled", errors
end
return helpers

View File

@ -78,7 +78,7 @@ for i, plugin in ipairs(plugins) do
ngx.ctx.reason = plugin.id
logger:log(ngx.WARN, "denied access from " .. plugin.id .. " : " .. err)
else
logger:log(ngx.NOTICE, plugin.id .. " returned status " .. tostring(ret.status) .. " : " .. err)
logger:log(ngx.NOTICE, plugin.id .. " returned status " .. tostring(ret.status))
end
ngx.ctx.status = ret.status
break