From: Andrew Lewis Date: Thu, 24 Nov 2016 09:58:36 +0000 (+0200) Subject: [Feature] Clickhouse: support different masks for IPv4/IPv6 X-Git-Tag: 1.4.1~85^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F1172%2Fhead;p=rspamd.git [Feature] Clickhouse: support different masks for IPv4/IPv6 --- diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index aa39b47da..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 } @@ -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