diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-23 15:37:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-23 15:37:15 +0100 |
commit | 087e3318348d368c2b0639a44abff418f91ef94b (patch) | |
tree | 8a749cb0d25ca390e156999e0dbfaacdc7ab63f9 /src | |
parent | 77d0030eff22ebed1ab4b3a124142b8fff38fb4a (diff) | |
download | rspamd-087e3318348d368c2b0639a44abff418f91ef94b.tar.gz rspamd-087e3318348d368c2b0639a44abff418f91ef94b.zip |
[Minor] Clickhouse: Add exceptions logic
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/clickhouse.lua | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index ccaee3042..599164006 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -76,6 +76,7 @@ local settings = { no_ssl_verify = false, custom_rules = {}, enable_digest = false, + exceptions = nil, retention = { enable = false, method = 'detach', @@ -380,12 +381,27 @@ local function clickhouse_send_data(task, ev_base) end local function clickhouse_collect(task) - if task:has_flag('skip') then return end - if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then return end + if task:has_flag('skip') then + return + end + + if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then + return + end for _,sym in ipairs(settings.stop_symbols) do if task:has_symbol(sym) then - lua_util.debugm(N, task, 'skip collection as symbol %s has fired', sym) + rspamd_logger.infox(task, 'skip Clickhouse storage for message: symbol %s has fired', sym) + return + end + end + + if settings.exceptions then + local excepted,trace = settings.exceptions:process(task) + if excepted then + rspamd_logger.infox(task, 'skipped Clickhouse storage for message: excepted (%s)', + trace) + -- Excepted return end end @@ -1069,6 +1085,13 @@ if opts then return end + if settings.exceptions then + local maps_expressions = require "lua_maps_expressions" + + settings.exceptions = maps_expressions.create(rspamd_config, + settings.exceptions, N) + end + rspamd_config:register_symbol({ name = 'CLICKHOUSE_COLLECT', type = 'idempotent', |