mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
Add the custom css map (for bot-check page so far)
This commit is contained in:
1
haproxy/map/css.map
Normal file
1
haproxy/map/css.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
localhost body%20%7B%0A%20%20%20%20position%3A%20relative%3B%0A%20%20%20%20font-size%3A%2020px%3B%0A%7D%0A%0Abody%3A%3Abefore%20%7B%0A%20%20%20%20content%3A%20%22%22%3B%0A%20%20%20%20position%3A%20absolute%3B%0A%20%20%20%20top%3A%200%3B%0A%20%20%20%20left%3A%200%3B%0A%20%20%20%20width%3A%20100%25%3B%0A%20%20%20%20height%3A%20100%25%3B%0A%20%20%20%20background-image%3A%20url(%22https%3A%2F%2Fbasedflare.com%2Ffavicon.ico%22)%3B%0A%20%20%20%20background-repeat%3A%20repeat%3B%0A%20%20%20%20background-size%3A%20auto%3B%0A%20%20%20%20opacity%3A%200.05%3B%0A%20%20%20%20z-index%3A%20-1%3B%0A%7D
|
@@ -63,6 +63,8 @@ else
|
|||||||
captcha_siteverify_path = "/recaptcha/api/siteverify"
|
captcha_siteverify_path = "/recaptcha/api/siteverify"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local css_map = Map.new("/etc/haproxy/map/css.map", Map._str);
|
||||||
|
|
||||||
function _M.secondsToDate(seconds)
|
function _M.secondsToDate(seconds)
|
||||||
local formattedDate = os.date("!%a, %d-%b-%y %H:%M:%S GMT", seconds)
|
local formattedDate = os.date("!%a, %d-%b-%y %H:%M:%S GMT", seconds)
|
||||||
return formattedDate
|
return formattedDate
|
||||||
@@ -125,6 +127,9 @@ function _M.view(applet)
|
|||||||
end
|
end
|
||||||
local ls = locales_strings[lang]
|
local ls = locales_strings[lang]
|
||||||
|
|
||||||
|
-- get any custom css
|
||||||
|
local css_val = css_map:lookup(host)
|
||||||
|
|
||||||
-- set response body and declare status code
|
-- set response body and declare status code
|
||||||
local response_body = ""
|
local response_body = ""
|
||||||
local response_status_code
|
local response_status_code
|
||||||
@@ -212,6 +217,7 @@ function _M.view(applet)
|
|||||||
lang,
|
lang,
|
||||||
ls,
|
ls,
|
||||||
ll["Hold on..."],
|
ll["Hold on..."],
|
||||||
|
css_val,
|
||||||
combined_challenge,
|
combined_challenge,
|
||||||
ddos_config["pd"],
|
ddos_config["pd"],
|
||||||
argon_time,
|
argon_time,
|
||||||
@@ -390,16 +396,6 @@ function _M.view(applet)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set lang json in var for use with json_query sf for using translations in template files without a lua view
|
|
||||||
function _M.set_lang_json(txn)
|
|
||||||
local lang = _M.get_first_language(txn, false)
|
|
||||||
local ls = locales_strings[lang]
|
|
||||||
if ls == nil then
|
|
||||||
ls = locales_strings[default_lang]
|
|
||||||
end
|
|
||||||
txn:set_var("txn.lang_json", ls)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set a variable if ip or subnet in blocked/whitelist map and list of usernames matches the one for the current domain
|
-- set a variable if ip or subnet in blocked/whitelist map and list of usernames matches the one for the current domain
|
||||||
local blockedip_map = Map.new("/etc/haproxy/map/blockedip.map", Map._ip);
|
local blockedip_map = Map.new("/etc/haproxy/map/blockedip.map", Map._ip);
|
||||||
local blockedasn_map = Map.new("/etc/haproxy/map/blockedasn.map", Map._str);
|
local blockedasn_map = Map.new("/etc/haproxy/map/blockedasn.map", Map._str);
|
||||||
@@ -428,6 +424,17 @@ local lookupvar_tbl = {
|
|||||||
return _txn:get_var("txn.xcn")
|
return _txn:get_var("txn.xcn")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- set lang json in var for use with json_query sf for using translations in template files without a lua view
|
||||||
|
function _M.set_lang_json(txn)
|
||||||
|
local lang = _M.get_first_language(txn, false)
|
||||||
|
local ls = locales_strings[lang]
|
||||||
|
if ls == nil then
|
||||||
|
ls = locales_strings[default_lang]
|
||||||
|
end
|
||||||
|
txn:set_var("txn.lang_json", ls)
|
||||||
|
end
|
||||||
|
|
||||||
function _M.set_ip_var(txn, map_name, set_variable, lookup_var)
|
function _M.set_ip_var(txn, map_name, set_variable, lookup_var)
|
||||||
-- get the host header and user ip
|
-- get the host header and user ip
|
||||||
local host = txn.sf:hdr("Host")
|
local host = txn.sf:hdr("Host")
|
||||||
|
@@ -28,6 +28,7 @@ _M.body = string.format([[
|
|||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
</style>
|
</style>
|
||||||
|
<link rel='stylesheet' href='data:text/css;charset=utf-8,%%s'>
|
||||||
<noscript>
|
<noscript>
|
||||||
<style>.jsonly{display:none}</style>
|
<style>.jsonly{display:none}</style>
|
||||||
</noscript>
|
</noscript>
|
||||||
|
Reference in New Issue
Block a user