Fix fallback remediation

This commit is contained in:
alteredCoder 2022-03-09 15:18:13 +01:00
parent e7aae5afa5
commit 300b448990
2 changed files with 11 additions and 3 deletions

View file

@ -223,7 +223,7 @@ function stream_query()
end
local remediation_id = get_remediation_id(decision.type)
if remediation_id == nil then
remediation_id = 1
remediation_id = get_remediation_id(runtime.fallback)
end
local key = item_to_string(decision.value, decision.scope)
local succ, err, forcible = runtime.cache:set(key, false, ttl, remediation_id)
@ -286,7 +286,7 @@ function live_query(ip)
if runtime.conf["BOUNCING_ON_TYPE"] == decision.type or runtime.conf["BOUNCING_ON_TYPE"] == "all" then
local remediation_id = get_remediation_id(decision.type)
if remediation_id == nil then
remediation_id = 1
remediation_id = get_remediation_id(runtime.fallback)
end
local key = item_to_string(decision.value, decision.scope)
local succ, err, forcible = runtime.cache:set(key, false, runtime.conf["CACHE_EXPIRATION"], remediation_id)

View file

@ -92,7 +92,15 @@ function config.loadConfig(file)
conf[v] = exclude_location
break
end
if v == "FALLBACK_REMEDIATION" then
local value = s[2]
if not has_value({'captcha', 'ban'}, s[2]) then
ngx.log(ngx.ERR, "unsupported value '" .. s[2] .. "' for variable '" .. v .. "'. Using default value 'ban' instead")
local n = next(s, k)
conf[v] = "ban"
break
end
end
local n = next(s, k)
conf[v] = s[n]
break