mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
Optimizations, remove a call to string.format, remove an if in else/if for deciding pow and/or captcha check
This commit is contained in:
@ -152,7 +152,6 @@ function _M.view(applet)
|
|||||||
local combined_challenge = user_key .. "#" .. challenge_hash .. "#" .. expiry .. "#" .. signature
|
local combined_challenge = user_key .. "#" .. challenge_hash .. "#" .. expiry .. "#" .. signature
|
||||||
|
|
||||||
-- define body sections
|
-- define body sections
|
||||||
local site_name_body = ""
|
|
||||||
local captcha_body = ""
|
local captcha_body = ""
|
||||||
local pow_body = ""
|
local pow_body = ""
|
||||||
local noscript_extra_body = ""
|
local noscript_extra_body = ""
|
||||||
@ -183,10 +182,6 @@ function _M.view(applet)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- pow at least is always enabled when reaching bot-check page
|
-- pow at least is always enabled when reaching bot-check page
|
||||||
site_name_body = string.format(
|
|
||||||
templates.site_name_section,
|
|
||||||
string.format(ll["Verifying your connection to %s"], host)
|
|
||||||
)
|
|
||||||
if captcha_enabled then
|
if captcha_enabled then
|
||||||
captcha_body = string.format(
|
captcha_body = string.format(
|
||||||
templates.captcha_section,
|
templates.captcha_section,
|
||||||
@ -235,7 +230,7 @@ function _M.view(applet)
|
|||||||
argon_time,
|
argon_time,
|
||||||
argon_kb,
|
argon_kb,
|
||||||
ddos_config["pt"],
|
ddos_config["pt"],
|
||||||
site_name_body,
|
string.format(ll["Verifying your connection to %s"], host),
|
||||||
pow_body,
|
pow_body,
|
||||||
captcha_body,
|
captcha_body,
|
||||||
ll["JavaScript is required on this page."],
|
ll["JavaScript is required on this page."],
|
||||||
@ -485,11 +480,11 @@ function _M.decide_checks_necessary(txn)
|
|||||||
if ddos_map_json.m == 0
|
if ddos_map_json.m == 0
|
||||||
or (ddos_map_json.t == true and txn.sf:hdr("X-Country-Code") ~= "T1") then
|
or (ddos_map_json.t == true and txn.sf:hdr("X-Country-Code") ~= "T1") then
|
||||||
return
|
return
|
||||||
elseif ddos_map_json.m == 1 then
|
else
|
||||||
txn:set_var("txn.validate_pow", true)
|
txn:set_var("txn.validate_pow", true)
|
||||||
elseif ddos_map_json.m == 2 then
|
if ddos_map_json.m == 2 then
|
||||||
txn:set_var("txn.validate_pow", true)
|
txn:set_var("txn.validate_captcha", true)
|
||||||
txn:set_var("txn.validate_captcha", true)
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- no entry in the map
|
-- no entry in the map
|
||||||
|
@ -16,7 +16,10 @@ _M.body = [[
|
|||||||
<script src="/.basedflare/js/challenge.min.js"></script>
|
<script src="/.basedflare/js/challenge.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body data-pow="%s" data-diff="%s" data-time="%s" data-kb="%s" data-mode="%s">
|
<body data-pow="%s" data-diff="%s" data-time="%s" data-kb="%s" data-mode="%s">
|
||||||
%s
|
<h3 class="pt">
|
||||||
|
<img src="/.basedflare/pow-icon" width="64" height="64" alt=" ">
|
||||||
|
%s
|
||||||
|
</h3>
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
<noscript>
|
<noscript>
|
||||||
@ -69,14 +72,6 @@ _M.noscript_extra_sha256 = [[
|
|||||||
</details>
|
</details>
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- title with favicon and hostname
|
|
||||||
_M.site_name_section = [[
|
|
||||||
<h3 class="pt">
|
|
||||||
<img src="/.basedflare/pow-icon" width="64" height="64" alt=" ">
|
|
||||||
%s
|
|
||||||
</h3>
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- animation while waiting
|
-- animation while waiting
|
||||||
_M.pow_section = [[
|
_M.pow_section = [[
|
||||||
<span>
|
<span>
|
||||||
|
Reference in New Issue
Block a user