From 2011f60377d02e8480f57a4eada67b8956a591ad Mon Sep 17 00:00:00 2001 From: Thomas Lynch Date: Sun, 19 Jan 2025 00:23:23 +1100 Subject: [PATCH] Fix some variables to be local scope instead of globals --- src/lua/scripts/bot-check.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua/scripts/bot-check.lua b/src/lua/scripts/bot-check.lua index 2ae6e7b..a2c3ad4 100644 --- a/src/lua/scripts/bot-check.lua +++ b/src/lua/scripts/bot-check.lua @@ -157,7 +157,7 @@ function _M.view(applet) local ddos_map_lookup = ddos_map:lookup(host..path) or ddos_map:lookup(host) if ddos_map_lookup ~= nil then - ddos_map_json = json.decode(ddos_map_lookup) + local ddos_map_json = json.decode(ddos_map_lookup) if ddos_map_json.m == 2 then captcha_enabled = true end @@ -166,7 +166,7 @@ function _M.view(applet) -- return simple json if they send accept: application/json header local accept_header = applet.headers['accept'] if accept_header ~= nil and accept_header[0] == 'application/json' then - local_pow_combined = string.format('%s#%d#%s#%s', ddos_config["pt"], math.ceil(ddos_config["pd"]/8), argon_time, argon_kb) + local local_pow_combined = string.format('%s#%d#%s#%s', ddos_config["pt"], math.ceil(ddos_config["pd"]/8), argon_time, argon_kb) response_body = "{\"ch\":\""..combined_challenge.."\",\"ca\":"..(captcha_enabled and "true" or "false")..",\"pow\":\""..local_pow_combined.."\"}" applet:set_status(403) applet:add_header("content-type", "application/json; charset=utf-8") @@ -468,7 +468,7 @@ function _M.decide_checks_necessary(txn) local path = txn.sf:path(); local ddos_map_lookup = ddos_map:lookup(host..path) or ddos_map:lookup(host) if ddos_map_lookup ~= nil then - ddos_map_json = json.decode(ddos_map_lookup) + local ddos_map_json = json.decode(ddos_map_lookup) if ddos_map_json.m == 0 or (ddos_map_json.t == true and txn.sf:hdr("X-Country-Code") ~= "T1") then return