Fix live query mode when IP is good
This commit is contained in:
parent
f8eac632a9
commit
2cd7200544
1 changed files with 11 additions and 9 deletions
|
@ -268,7 +268,8 @@ function live_query(ip)
|
||||||
end
|
end
|
||||||
if body == "null" then -- no result from API, no decision for this IP
|
if body == "null" then -- no result from API, no decision for this IP
|
||||||
-- set ip in cache and DON'T block it
|
-- set ip in cache and DON'T block it
|
||||||
local succ, err, forcible = runtime.cache:set(ip, true,runtime.conf["CACHE_EXPIRATION"])
|
local key = item_to_string(decision.value, "ip")
|
||||||
|
local succ, err, forcible = runtime.cache:set(key, true, runtime.conf["CACHE_EXPIRATION"], 1)
|
||||||
if not succ then
|
if not succ then
|
||||||
ngx.log(ngx.ERR, "failed to add ip '" .. ip .. "' in cache: "..err)
|
ngx.log(ngx.ERR, "failed to add ip '" .. ip .. "' in cache: "..err)
|
||||||
end
|
end
|
||||||
|
@ -305,11 +306,7 @@ function csmod.GetCaptchaTemplate()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function csmod.allowIp(ip)
|
function csmod.SetupStream()
|
||||||
if runtime.conf == nil then
|
|
||||||
return true, nil, "Configuration is bad, cannot run properly"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if it stream mode and startup start timer
|
-- if it stream mode and startup start timer
|
||||||
if runtime.cache:get("first_run") == true and runtime.conf["MODE"] == "stream" then
|
if runtime.cache:get("first_run") == true and runtime.conf["MODE"] == "stream" then
|
||||||
local ok, err
|
local ok, err
|
||||||
|
@ -337,6 +334,14 @@ function csmod.allowIp(ip)
|
||||||
end
|
end
|
||||||
ngx.log(ngx.DEBUG, "Timer launched")
|
ngx.log(ngx.DEBUG, "Timer launched")
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function csmod.allowIp(ip)
|
||||||
|
if runtime.conf == nil then
|
||||||
|
return true, nil, "Configuration is bad, cannot run properly"
|
||||||
|
end
|
||||||
|
|
||||||
|
csmod.SetupStream()
|
||||||
|
|
||||||
local key = item_to_string(ip, "ip")
|
local key = item_to_string(ip, "ip")
|
||||||
local key_parts = {}
|
local key_parts = {}
|
||||||
|
@ -378,9 +383,6 @@ function csmod.allowIp(ip)
|
||||||
return true, nil, nil
|
return true, nil, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function csmod.Allow(ip)
|
function csmod.Allow(ip)
|
||||||
if utils.table_len(runtime.conf["EXCLUDE_LOCATION"]) > 0 then
|
if utils.table_len(runtime.conf["EXCLUDE_LOCATION"]) > 0 then
|
||||||
for k, v in pairs(runtime.conf["EXCLUDE_LOCATION"]) do
|
for k, v in pairs(runtime.conf["EXCLUDE_LOCATION"]) do
|
||||||
|
|
Loading…
Add table
Reference in a new issue