From 942915ae8a60f1e3791e266ce49629a3a0240090 Mon Sep 17 00:00:00 2001 From: C0nw0nk Date: Fri, 15 Nov 2019 18:32:04 +0000 Subject: [PATCH] Update anti_ddos_challenge.lua Add Enable/disable script this feature allows you to turn on or off this script so you can leave this file in your nginx configuration permamently. This way you don't have to remove `access_by_lua_file anti_ddos_challenge.lua;` to stop protecting your websites :) you can set up your nginx config and use this feature to enable or disable protection. --- lua/anti_ddos_challenge.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/anti_ddos_challenge.lua b/lua/anti_ddos_challenge.lua index 6a3c06a..ed71445 100644 --- a/lua/anti_ddos_challenge.lua +++ b/lua/anti_ddos_challenge.lua @@ -208,6 +208,16 @@ Charset output of HTML page and scripts ]] local default_charset = "utf-8" +--[[ +Enable/disable script this feature allows you to turn on or off this script so you can leave this file in your nginx configuration permamently. + +This way you don't have to remove access_by_lua_file anti_ddos_challenge.lua; to stop protecting your websites :) you can set up your nginx config and use this feature to enable or disable protection + +1 = enabled +2 = disabled +]] +local master_switch = 1 --enabled by default + --[[ End Configuration @@ -225,6 +235,15 @@ This is where things get very complex. ;) Begin Required Functions ]] +--master switch check +local function check_master_switch() + if master_switch == 2 then --script disabled + local output = ngx.exit(ngx.OK) --Go to content + return output + end +end +check_master_switch() + --function to check if ip address is whitelisted to bypass our auth local function check_ip_whitelist(ip_table) for key,value in pairs(ip_table) do