]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Clickhouse: support different masks for IPv4/IPv6 1172/head
authorAndrew Lewis <nerf@judo.za.org>
Thu, 24 Nov 2016 09:58:36 +0000 (11:58 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Thu, 24 Nov 2016 09:59:38 +0000 (11:59 +0200)
src/plugins/lua/clickhouse.lua

index aa39b47da1e6de5e9cafcf9b4bac258c363e2e42..045e4a1751b8b7897aa9542781cf85ac1a640495 100644 (file)
@@ -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