aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/clickhouse.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/lua/clickhouse.lua')
-rw-r--r--src/plugins/lua/clickhouse.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index 0d6420195..045e4a175 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -40,6 +40,7 @@ local settings = {
attachments_table = 'rspamd_attachments',
urls_table = 'rspamd_urls',
ipmask = 19,
+ ipmask6 = 48,
full_urls = false,
from_tables = nil
}
@@ -177,7 +178,7 @@ end
local function clickhouse_send_data(task)
local function http_cb(err_message, code, _, _)
if code ~= 200 or err_message then
- rspamd_logger.errx(task, "cannot send data to clickhouse server %s: %d:%s",
+ rspamd_logger.errx(task, "cannot send data to clickhouse server %s: %s:%s",
settings['server'], code, err_message)
else
rspamd_logger.infox(task, "sent %s rows to clickhouse server %s",
@@ -288,7 +289,12 @@ local function clickhouse_collect(task)
local ip_str = 'undefined'
local ip = task:get_from_ip()
if ip and ip:is_valid() then
- local ipnet = ip:apply_mask(settings['ipmask'])
+ local ipnet
+ if ip:get_version() == 4 then
+ ipnet = ip:apply_mask(settings['ipmask'])
+ else
+ ipnet = ip:apply_mask(settings['ipmask6'])
+ end
ip_str = ipnet:to_string()
end