summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-24 10:53:42 +0000
committerGitHub <noreply@github.com>2016-11-24 10:53:42 +0000
commit30d8bbafc550e8f57a0d220afa7cfb220d310adb (patch)
treea2d2bb3d951c6983d072a900c2359cf48269bcd3 /src
parentb63a76e6a5ebb476248a4261a8062008a526fd37 (diff)
parentaed5dec62bbc44e173cd2de62297a44dad8fb126 (diff)
downloadrspamd-30d8bbafc550e8f57a0d220afa7cfb220d310adb.tar.gz
rspamd-30d8bbafc550e8f57a0d220afa7cfb220d310adb.zip
Merge pull request #1172 from fatalbanana/f
Clickhouse plugin
Diffstat (limited to 'src')
-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