diff --git a/lib/plugins/crowdsec/ban.lua b/lib/plugins/crowdsec/ban.lua index d0afd69..75001c8 100644 --- a/lib/plugins/crowdsec/ban.lua +++ b/lib/plugins/crowdsec/ban.lua @@ -22,8 +22,8 @@ function M.new(template_path, redirect_location, ret_code) end end - if ret_code_ok == false then - ngx.log(ngx.ERR, "RET_CODE '" .. ret_code .. "' is not supported") + if ret_code_ok == false and ret_code ~= 0 and ret_code ~= "" then + ngx.log(ngx.ERR, "RET_CODE '" .. ret_code .. "' is not supported, using default HTTP code " .. M.ret_code) end template_file_ok = false diff --git a/lib/plugins/crowdsec/config.lua b/lib/plugins/crowdsec/config.lua index a852a41..ac0f9c2 100644 --- a/lib/plugins/crowdsec/config.lua +++ b/lib/plugins/crowdsec/config.lua @@ -30,6 +30,11 @@ local function starts_with(str, start) return str:sub(1, #start) == start end +local function trim(s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + + function config.loadConfig(file) if not config.file_exists(file) then return nil, "File ".. file .." doesn't exist" @@ -55,6 +60,9 @@ function config.loadConfig(file) if starts_with(line, "#") then isOk = true end + if trim(line) == "" then + isOk = true + end if not isOk then local s = split(line, "=") for k, v in pairs(s) do