]> source.dussan.org Git - rspamd.git/commitdiff
[Project] Unify cdb maps
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Feb 2020 17:28:41 +0000 (17:28 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 14 Feb 2020 17:28:41 +0000 (17:28 +0000)
lualib/lua_maps.lua
src/libserver/logger/logger_private.h
src/plugins/lua/multimap.lua

index f49d77f4ea1bdcd2b402bd34ea963460cccfc1fc..52e97fece98f05af3b163bf48a5d2dd6f730adb6 100644 (file)
@@ -67,7 +67,8 @@ local function maybe_adjust_type(data,mtype)
     {'ipnet;', 'radix'},
     {'set;', 'set'},
     {'hash;', 'hash'},
-    {'plain;', 'hash'}
+    {'plain;', 'hash'},
+    {'cdb;', 'cdb'},
   }
 
   for _,t in ipairs(known_types) do
index 4b0dbfef5abc055c9889468d846e0b07490818dc..5fc258914204c1190f9ad206dc3e0771fb4cb908 100644 (file)
@@ -16,6 +16,8 @@
 #ifndef RSPAMD_LOGGER_PRIVATE_H
 #define RSPAMD_LOGGER_PRIVATE_H
 
+#include "logger.h"
+
 /* How much message should be repeated before it is count to be repeated one */
 #define REPEATS_MIN 3
 #define REPEATS_MAX 300
index 3a53d24cb0fce6646a6695448a8aece181d79a1c..876e96dc15dad5edf9fc2104e0afb5e6511fbc53 100644 (file)
@@ -439,27 +439,7 @@ local function multimap_callback(task, rule)
 
     local ret = false
 
-    if r['cdb'] then
-      if type(r.cdb) == 'string' then
-        local rspamd_cdb = require "rspamd_cdb"
-        local cdb = rspamd_cdb.create(r.cdb, task:get_ev_base())
-
-        if not cdb then
-          rspamd_logger.infox(task, 'cannot open cdb file %s', r.cdb)
-
-          return false
-        else
-          r.cdb = cdb
-        end
-      end
-      local srch = value
-      if type(value) == 'userdata' then
-        if value.class == 'rspamd{ip}' then
-          srch = value:tostring()
-        end
-      end
-      ret = r.cdb:lookup(srch)
-    elseif r.redis_key then
+    if r.redis_key then
       -- Deal with hash name here: it can be either plain string or a selector
       if type(r.redis_key) == 'string' then
         ret = multimap_query_redis(r.redis_key, task, value, callback)
@@ -1094,11 +1074,7 @@ local function add_multimap_rule(key, newrule)
       newrule.selector = selector
     end
   end
-  -- Check cdb flag
-  if type(newrule['map']) == 'string' and string.find(newrule['map'], '^cdb://.*$') then
-    newrule['cdb'] = newrule['map']
-    ret = true
-  elseif type(newrule['map']) == 'string' and
+  if type(newrule['map']) == 'string' and
       string.find(newrule['map'], '^redis://.*$') then
     if not redis_params then
       rspamd_logger.infox(rspamd_config, 'no redis servers are specified, ' ..