From ac52cb4dff848d290291f15a16b6f64b41d1d592 Mon Sep 17 00:00:00 2001 From: C0nw0nk Date: Fri, 15 Nov 2019 18:09:55 +0000 Subject: [PATCH] Update anti_ddos_challenge.lua Make charset customisable value for those who wish to translate this script into their own native languages. https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/issues/8 --- lua/anti_ddos_challenge.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lua/anti_ddos_challenge.lua b/lua/anti_ddos_challenge.lua index c40683e..f764231 100644 --- a/lua/anti_ddos_challenge.lua +++ b/lua/anti_ddos_challenge.lua @@ -203,6 +203,11 @@ TODO: Google ReCaptcha ]] +--[[ +Charset output of HTML page and scripts +]] +local default_charset = "utf-8" + --[[ End Configuration @@ -293,13 +298,13 @@ local function encrypt_javascript(string1, type, defer_async, num_encrypt, encry if type == 1 or type == nil then --No encryption if defer_async == "0" or defer_async == nil then --Browser default loading / execution order - output = "" + output = "" end if defer_async == "1" then --Defer - output = "" + output = "" end if defer_async == "2" then --Async - output = "" + output = "" end end @@ -315,13 +320,13 @@ local function encrypt_javascript(string1, type, defer_async, num_encrypt, encry end if defer_async == "0" or defer_async == nil then --Browser default loading / execution order - output = "" + output = "" end if defer_async == "1" then --Defer - output = "" + output = "" end if defer_async == "2" then --Async - output = "" + output = "" end end @@ -358,7 +363,7 @@ local function encrypt_javascript(string1, type, defer_async, num_encrypt, encry end --https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent - output = "" + output = "" end if type == 4 then --Base64 javascript decode @@ -371,13 +376,13 @@ local function encrypt_javascript(string1, type, defer_async, num_encrypt, encry end if defer_async == "0" or defer_async == nil then --Browser default loading / execution order - output = "" + output = "" end if defer_async == "1" then --Defer - output = "" + output = "" end if defer_async == "2" then --Defer - output = "" + output = "" end end @@ -613,7 +618,7 @@ local javascript_anti_ddos = [[ encrypt/obfuscate the javascript output ]] if encrypt_javascript_output == 1 then --No encryption/Obfuscation of Javascript so show Javascript in plain text -javascript_anti_ddos = [[]] else --some form of obfuscation has been specified so obfuscate the javascript output @@ -685,8 +690,8 @@ local anti_ddos_html_output = [[ - - + + @@ -742,7 +747,7 @@ ngx.header["Cache-Control"] = "public, max-age=0 no-store, no-cache, must-revali ngx.header["Pragma"] = "no-cache" ngx.header["Expires"] = "0" ngx.header["X-Anti-DDoS"] = "Conor McKnight | facebook.com/C0nw0nk" -ngx.header.content_type = "text/html; charset=UTF-8" +ngx.header.content_type = "text/html; charset=" .. default_charset ngx.status = expected_header_status ngx.say(anti_ddos_html_output) ngx.exit(ngx.HTTP_OK)