diff --git a/haproxy/haproxy.cfg b/haproxy/haproxy.cfg index d6a434d..9786428 100644 --- a/haproxy/haproxy.cfg +++ b/haproxy/haproxy.cfg @@ -184,11 +184,3 @@ backend bot_check_post_throttle backend count_qs_throttle stick-table type string size 100k expire 60s store http_req_rate(60s) - -backend hcaptcha - mode http - server hcaptcha hcaptcha.com:443 - -backend recaptcha - mode http - server recaptcha www.google.com:443 diff --git a/src/lua/scripts/bot-check.lua b/src/lua/scripts/bot-check.lua index 4cd70a0..1e37043 100644 --- a/src/lua/scripts/bot-check.lua +++ b/src/lua/scripts/bot-check.lua @@ -47,7 +47,6 @@ local ddos_default_config = { -- captcha variables local captcha_secret = os.getenv("HCAPTCHA_SECRET") or os.getenv("RECAPTCHA_SECRET") -local captcha_sitekey = os.getenv("HCAPTCHA_SITEKEY") or os.getenv("RECAPTCHA_SITEKEY") local captcha_cookie_secret = os.getenv("CAPTCHA_COOKIE_SECRET") local pow_cookie_secret = os.getenv("POW_COOKIE_SECRET") local hmac_cookie_secret = os.getenv("HMAC_COOKIE_SECRET") @@ -55,22 +54,13 @@ local ray_id = os.getenv("RAY_ID") -- load captcha map and set hcaptcha/recaptch based off env vars local ddos_map = Map.new("/etc/haproxy/map/ddos.map", Map._str); local captcha_provider_domain = "" -local captcha_classname = "" -local captcha_script_src = "" local captcha_siteverify_path = "" -local captcha_backend_name = "" if os.getenv("HCAPTCHA_SITEKEY") then captcha_provider_domain = "hcaptcha.com" - captcha_classname = "h-captcha" - captcha_script_src = "https://hcaptcha.com/1/api.js" captcha_siteverify_path = "/siteverify" - captcha_backend_name = "hcaptcha" else captcha_provider_domain = "www.google.com" - captcha_classname = "g-recaptcha" - captcha_script_src = "https://www.google.com/recaptcha/api.js" captcha_siteverify_path = "/recaptcha/api/siteverify" - captcha_backend_name = "recaptcha" end function _M.secondsToDate(seconds) @@ -185,10 +175,7 @@ function _M.view(applet) if captcha_enabled then captcha_body = string.format( templates.captcha_section, - ll["Please solve the captcha to continue."], - captcha_classname, - captcha_sitekey, - captcha_script_src + ll["Please solve the captcha to continue."] ) else pow_body = string.format( @@ -330,8 +317,6 @@ function _M.view(applet) -- format the url for verifying the captcha response local captcha_url = string.format( "https://%s%s", - --Seems this is no longer needed, captcha_provider_domain works since 2.7 - --core.backends[captcha_backend_name].servers[captcha_backend_name]:get_addr(), captcha_provider_domain, captcha_siteverify_path ) diff --git a/src/lua/scripts/templates.lua b/src/lua/scripts/templates.lua index 0e3d2d7..793f847 100644 --- a/src/lua/scripts/templates.lua +++ b/src/lua/scripts/templates.lua @@ -82,26 +82,27 @@ _M.pow_section = [[ ]] --- alternative, spinner animation --- .loader{display:inline-block;position:relative;width:80px;height:80px} --- .loader div{box-sizing:border-box;display:block;position:absolute;width:32px;height:32px;margin:10px;border:5px solid var(--text-color);border-radius:50%%;animation:loader 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;border-color:var(--text-color) transparent transparent transparent} --- .loader div:nth-child(1){animation-delay:-0.45s} --- .loader div:nth-child(2){animation-delay:-0.3s} --- .loader div:nth-child(3){animation-delay:-0.15s} --- @keyframes loader{0%%{transform:rotate(0deg)}100%%{transform:rotate(360deg)}} ---
+-- captcha section +local captcha_sitekey = os.getenv("HCAPTCHA_SITEKEY") or os.getenv("RECAPTCHA_SITEKEY") +local captcha_classname = "" +local captcha_script_src = "" +if os.getenv("HCAPTCHA_SITEKEY") then + captcha_classname = "h-captcha" + captcha_script_src = "https://hcaptcha.com/1/api.js" +else + captcha_classname = "g-recaptcha" + captcha_script_src = "https://www.google.com/recaptcha/api.js" +end +_M.captcha_section = string.format([[ + %s -
+