From e570b1ed57b333c78b24277b9eb04c2d9eea4987 Mon Sep 17 00:00:00 2001 From: C0nw0nk Date: Mon, 27 Jan 2020 16:53:26 +0000 Subject: [PATCH] Update anti_ddos_challenge.lua Fix for Javascript refreshing the page before the browser has a chance to set the cookies in response. Fix to stop Firefox browsers message "firefox prevented this page from automatically reloading" Remove un-used junk code. --- lua/anti_ddos_challenge.lua | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lua/anti_ddos_challenge.lua b/lua/anti_ddos_challenge.lua index 20840f0..e3b7845 100644 --- a/lua/anti_ddos_challenge.lua +++ b/lua/anti_ddos_challenge.lua @@ -456,13 +456,6 @@ local user_agent = ngx.var.http_user_agent --user agent of browser local expected_header_status = 200 local authentication_page_status_output = 503 -local domain = "" -if host == nil then - domain = host:match("[%w%.]*%.(%w+%.%w+)") --Remove subdomains from the server_name (host) to output .domain.com -else - domain = "localhost" -end - local answer = calculate_signature(remote_addr) --create our encrypted unique identification for the user visiting the website. if x_auth_header == 2 then --if x-auth-header is dynamic @@ -634,8 +627,10 @@ local javascript_anti_ddos = [[ //end javascript puzzle var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { - document.getElementById("status").innerHTML = "Refresh your page."; - location.reload(true); + if (xhttp.readyState === 4) { + document.getElementById("status").innerHTML = "Refresh your page."; + location.reload(true); + } }; xhttp.open("]] .. javascript_REQUEST_TYPE .. [[", "]] .. request_uri .. [[", true); ]] .. javascript_REQUEST_headers .. [[ @@ -733,7 +728,6 @@ local anti_ddos_html_output = [[ - ]] .. title .. [[