From d7e15fe4438b87e1b180213d0d30adfa44ec1621 Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Mon, 7 Nov 2016 17:19:49 +0200 Subject: [PATCH] [Minor] Remove handful more globals --- src/plugins/lua/hfilter.lua | 5 +++-- src/plugins/lua/ratelimit.lua | 7 ++++--- src/plugins/lua/trie.lua | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index 61595c253..ea4830c67 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -299,7 +299,7 @@ local function hfilter(task) --No more checks for auth user or local network local rip = task:get_from_ip() - if ((not check_user and task:get_user()) or + if ((not check_authed and task:get_user()) or (not check_local and rip and rip:is_local())) then return false end @@ -312,8 +312,9 @@ local function hfilter(task) -- Check's HELO local weight_helo = 0 + local helo if config['helo_enabled'] then - local helo = task:get_helo() + helo = task:get_helo() if helo then if helo ~= rspamc_local_helo then helo = string.gsub(helo, '[%[%]]', '') diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 001f3caa1..d6a2e7987 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -376,7 +376,7 @@ local function set_limits(task, args) conn:add_cmd('setex', v) end, fun.drop_n(1, values)) else - rspamd_logger.infox(task, 'got error while connecting to redis: %1', addr) + rspamd_logger.infox(task, 'got error while connecting to redis: %1', upstream:get_addr()) upstream:fail() end end @@ -482,8 +482,8 @@ local function parse_limit(str) local key_keywords = rspamd_str_split(params[1], '_') for _, k in ipairs(key_keywords) do - if (custom_keywords[v] and type(custom_keywords[v]['get_value']) == 'function') or - (keywords[v] and type(keywords[v]['get_value']) == 'function') then + if (custom_keywords[k] and type(custom_keywords[k]['get_value']) == 'function') or + (keywords[k] and type(keywords[k]['get_value']) == 'function') then set_limit(settings[params[1]], params[2], params[3]) else rspamd_logger.errx(rspamd_config, 'invalid limit type: ' .. params[1]) @@ -588,6 +588,7 @@ if opts then priority = 10, }) else + local symbol if not ratelimit_symbol then symbol = 'RATELIMIT_CHECK' else diff --git a/src/plugins/lua/trie.lua b/src/plugins/lua/trie.lua index ebc4e2a7e..a0ac862a5 100644 --- a/src/plugins/lua/trie.lua +++ b/src/plugins/lua/trie.lua @@ -95,7 +95,7 @@ local function process_single_pattern(pat, symbol, cf) end local function process_trie_file(symbol, cf) - file = io.open(cf['file']) + local file = io.open(cf['file']) if not file then rspamd_logger.errx(rspamd_config, 'Cannot open trie file %1', cf['file']) -- 2.39.5