diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-10 18:16:34 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-10 18:16:34 +0100 |
commit | 11043c12801e027ad1352dc1f5da943cafb640eb (patch) | |
tree | f5e9720de934b38812793a4297fdfd848fb524dd /lualib | |
parent | cd994934d1f2bfd7ca484a5588c1d9911f140c35 (diff) | |
download | rspamd-11043c12801e027ad1352dc1f5da943cafb640eb.tar.gz rspamd-11043c12801e027ad1352dc1f5da943cafb640eb.zip |
[Feature] Use pure Lua debugm function
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_clickhouse.lua | 8 | ||||
-rw-r--r-- | lualib/lua_dkim_tools.lua | 44 | ||||
-rw-r--r-- | lualib/lua_meta.lua | 4 |
3 files changed, 28 insertions, 28 deletions
diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua index 01d1f0b2b..cf6e9d894 100644 --- a/lualib/lua_clickhouse.lua +++ b/lualib/lua_clickhouse.lua @@ -17,6 +17,7 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local rspamd_http = require "rspamd_http" +local lua_util = require "lua_util" local exports = {} local N = 'clickhouse' @@ -73,7 +74,6 @@ end -- Parses JSONEachRow reply from CH local function parse_clickhouse_response(params, data) - local lua_util = require "lua_util" local ucl = require "ucl" if data == nil then @@ -129,7 +129,7 @@ local function mk_http_select_cb(upstream, params, ok_cb, fail_cb) if ok_cb then ok_cb(params, rows) else - rspamd_logger.debugm(N, params.log_obj, + lua_util.debugm(N, params.log_obj, "http_select_cb ok: %s, %s, %s, %s", err_message, code, data:gsub('[\n%s]+', ' '), _) end @@ -170,7 +170,7 @@ local function mk_http_insert_cb(upstream, params, ok_cb, fail_cb) if ok_cb then ok_cb(params, data) else - rspamd_logger.debugm(N, params.log_obj, + lua_util.debugm(N, params.log_obj, "http_insert_cb ok: %s, %s, %s, %s", err_message, code, data:gsub('[\n%s]+', ' '), _) end @@ -214,7 +214,7 @@ exports.select = function (upstream, settings, params, query, ok_cb, fail_cb) http_params.body = query http_params.log_obj = params.task or params.config - rspamd_logger.debugm(N, http_params.log_obj, "clickhouse select request: %s", http_params.body) + lua_util.debugm(N, http_params.log_obj, "clickhouse select request: %s", http_params.body) if not http_params.url then local connect_prefix = "http://" diff --git a/lualib/lua_dkim_tools.lua b/lualib/lua_dkim_tools.lua index 3c9637f87..e6ba2ea0c 100644 --- a/lualib/lua_dkim_tools.lua +++ b/lualib/lua_dkim_tools.lua @@ -18,7 +18,7 @@ limitations under the License. local exports = {} local E = {} -local rspamd_logger = require "rspamd_logger" +local lua_util = require "lua_util" local rspamd_util = require "rspamd_util" local function prepare_dkim_signing(N, task, settings) @@ -31,29 +31,29 @@ local function prepare_dkim_signing(N, task, settings) end if settings.auth_only and auser then - rspamd_logger.debugm(N, task, 'user is authenticated') + lua_util.debugm(N, task, 'user is authenticated') elseif (settings.sign_networks and settings.sign_networks:get_key(ip)) then is_sign_networks = true - rspamd_logger.debugm(N, task, 'mail is from address in sign_networks') + lua_util.debugm(N, task, 'mail is from address in sign_networks') elseif settings.sign_local and is_local then - rspamd_logger.debugm(N, task, 'mail is from local address') + lua_util.debugm(N, task, 'mail is from local address') elseif settings.sign_inbound and not is_local and not auser then - rspamd_logger.debugm(N, task, 'mail was sent to us') + lua_util.debugm(N, task, 'mail was sent to us') else - rspamd_logger.debugm(N, task, 'ignoring unauthenticated mail') + lua_util.debugm(N, task, 'ignoring unauthenticated mail') return false,{} end local efrom = task:get_from('smtp') if not settings.allow_envfrom_empty and #(((efrom or E)[1] or E).addr or '') == 0 then - rspamd_logger.debugm(N, task, 'empty envelope from not allowed') + lua_util.debugm(N, task, 'empty envelope from not allowed') return false,{} end local hfrom = task:get_from('mime') if not settings.allow_hdrfrom_multiple and (hfrom or E)[2] then - rspamd_logger.debugm(N, task, 'multiple header from not allowed') + lua_util.debugm(N, task, 'multiple header from not allowed') return false,{} end @@ -92,24 +92,24 @@ local function prepare_dkim_signing(N, task, settings) if settings.use_domain_sign_networks and is_sign_networks then dkim_domain = get_dkim_domain('use_domain_sign_networks') - rspamd_logger.debugm(N, task, 'sign_networks: use domain(%s) for signature: %s', + lua_util.debugm(N, task, 'sign_networks: use domain(%s) for signature: %s', settings.use_domain_sign_networks, dkim_domain) elseif settings.use_domain_sign_local and is_local then dkim_domain = get_dkim_domain('use_domain_sign_local') - rspamd_logger.debugm(N, task, 'local: use domain(%s) for signature: %s', + lua_util.debugm(N, task, 'local: use domain(%s) for signature: %s', settings.use_domain_sign_local, dkim_domain) elseif settings.use_domain_sign_inbound and not is_local and not auser then dkim_domain = get_dkim_domain('use_domain_sign_inbound') - rspamd_logger.debugm(N, task, 'inbound: use domain(%s) for signature: %s', + lua_util.debugm(N, task, 'inbound: use domain(%s) for signature: %s', settings.use_domain_sign_inbound, dkim_domain) else dkim_domain = get_dkim_domain('use_domain') - rspamd_logger.debugm(N, task, 'use domain(%s) for signature: %s', + lua_util.debugm(N, task, 'use domain(%s) for signature: %s', settings.use_domain, dkim_domain) end if not dkim_domain then - rspamd_logger.debugm(N, task, 'could not extract dkim domain') + lua_util.debugm(N, task, 'could not extract dkim domain') return false,{} end @@ -123,29 +123,29 @@ local function prepare_dkim_signing(N, task, settings) end end - rspamd_logger.debugm(N, task, 'final DKIM domain: %s', dkim_domain) + lua_util.debugm(N, task, 'final DKIM domain: %s', dkim_domain) if edom and hdom and not settings.allow_hdrfrom_mismatch and hdom ~= edom then if settings.allow_hdrfrom_mismatch_local and is_local then - rspamd_logger.debugm(N, task, 'domain mismatch allowed for local IP: %1 != %2', hdom, edom) + lua_util.debugm(N, task, 'domain mismatch allowed for local IP: %1 != %2', hdom, edom) elseif settings.allow_hdrfrom_mismatch_sign_networks and is_sign_networks then - rspamd_logger.debugm(N, task, 'domain mismatch allowed for sign_networks: %1 != %2', hdom, edom) + lua_util.debugm(N, task, 'domain mismatch allowed for sign_networks: %1 != %2', hdom, edom) else - rspamd_logger.debugm(N, task, 'domain mismatch not allowed: %1 != %2', hdom, edom) + lua_util.debugm(N, task, 'domain mismatch not allowed: %1 != %2', hdom, edom) return false,{} end end if auser and not settings.allow_username_mismatch then if not udom then - rspamd_logger.debugm(N, task, 'couldnt find domain in username') + lua_util.debugm(N, task, 'couldnt find domain in username') return false,{} end if settings.use_esld then udom = rspamd_util.get_tld(udom) end if udom ~= dkim_domain then - rspamd_logger.debugm(N, task, 'user domain mismatch') + lua_util.debugm(N, task, 'user domain mismatch') return false,{} end end @@ -175,7 +175,7 @@ local function prepare_dkim_signing(N, task, settings) if (not p.key or not p.selector) and (not (settings.try_fallback or settings.use_redis or settings.selector_map or settings.path_map)) then - rspamd_logger.debugm(N, task, 'dkim unconfigured and fallback disabled') + lua_util.debugm(N, task, 'dkim unconfigured and fallback disabled') return false,{} end end @@ -185,7 +185,7 @@ local function prepare_dkim_signing(N, task, settings) if data then p.selector = data elseif not settings.try_fallback then - rspamd_logger.debugm(N, task, 'no selector for %s', dkim_domain) + lua_util.debugm(N, task, 'no selector for %s', dkim_domain) return false,{} end end @@ -195,7 +195,7 @@ local function prepare_dkim_signing(N, task, settings) if data then p.key = data elseif not settings.try_fallback then - rspamd_logger.debugm(N, task, 'no key for %s', dkim_domain) + lua_util.debugm(N, task, 'no key for %s', dkim_domain) return false,{} end end diff --git a/lualib/lua_meta.lua b/lualib/lua_meta.lua index 0161eb5c9..d81709dab 100644 --- a/lualib/lua_meta.lua +++ b/lualib/lua_meta.lua @@ -357,7 +357,7 @@ local metafunctions = { } local function rspamd_gen_metatokens(task) - local rspamd_logger = require "rspamd_logger" + local lua_util = require "lua_util" local ipairs = ipairs local metatokens = {} local cached = task:cache_get('metatokens') @@ -368,7 +368,7 @@ local function rspamd_gen_metatokens(task) for _,mt in ipairs(metafunctions) do local ct = mt.cb(task) for i,tok in ipairs(ct) do - rspamd_logger.debugm(N, task, "metatoken: %s = %s", mt.desc[i], tok) + lua_util.debugm(N, task, "metatoken: %s = %s", mt.desc[i], tok) table.insert(metatokens, tok) end end |