mirror of
https://github.com/bunkerity/bunkerized-nginx
synced 2023-12-13 21:30:18 +01:00
lua - fix missing multisite variables in LRU
This commit is contained in:
parent
fdd3367a65
commit
9adb209a81
4 changed files with 11 additions and 5 deletions
|
@ -195,6 +195,14 @@ api.global.GET["^/bans$"] = function(self)
|
|||
return self:response(ngx.HTTP_OK, "success", data)
|
||||
end
|
||||
|
||||
api.global.GET["^/variables$"] = function(self)
|
||||
local variables, err = datastore:get('variables', true)
|
||||
if not variables then
|
||||
return self:response(ngx.HTTP_INTERNAL_SERVER_ERROR, "error", "can't access variables from datastore : " .. err)
|
||||
end
|
||||
return self:response(ngx.HTTP_OK, "success", variables)
|
||||
end
|
||||
|
||||
function api:is_allowed_ip()
|
||||
if utils.is_ip_in_networks(self.ctx.bw.remote_addr, self.ips) then
|
||||
return true, "ok"
|
||||
|
|
|
@ -2,7 +2,7 @@ local class = require "middleclass"
|
|||
local lrucache = require "resty.lrucache"
|
||||
local datastore = class("datastore")
|
||||
|
||||
local lru, err = lrucache.new(10000)
|
||||
local lru, err = lrucache.new(100000)
|
||||
if not lru then
|
||||
require "bunkerweb.logger":new("DATASTORE"):log(ngx.ERR,
|
||||
"failed to instantiate LRU cache : " .. (err or "unknown error"))
|
||||
|
|
|
@ -159,6 +159,7 @@ helpers.fill_ctx = function()
|
|||
data.kind = "stream"
|
||||
end
|
||||
data.remote_addr = ngx.var.remote_addr
|
||||
data.server_name = ngx.var.server_name
|
||||
if data.kind == "http" then
|
||||
data.uri = ngx.var.uri
|
||||
data.request_uri = ngx.var.request_uri
|
||||
|
@ -239,7 +240,6 @@ function helpers.load_variables(all_variables, plugins)
|
|||
local key = server_name .. "_" .. setting
|
||||
if all_variables[key] then
|
||||
variables[server_name][setting] = all_variables[key]
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -249,10 +249,8 @@ function helpers.load_variables(all_variables, plugins)
|
|||
if found then
|
||||
if multisite and prefix and prefix ~= "" then
|
||||
variables[prefix][variable] = value
|
||||
break
|
||||
end
|
||||
variables["global"][variable] = value
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ utils.get_variable = function(var, site_search)
|
|||
-- Get global value
|
||||
local variables, err = datastore:get('variables', true)
|
||||
if not variables then
|
||||
return nil, "can't access variables " .. var .. " from datastore : " .. err
|
||||
return nil, "can't access variables from datastore : " .. err
|
||||
end
|
||||
local value = variables["global"][var]
|
||||
-- Site search case
|
||||
|
|
Loading…
Reference in a new issue