]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Rework] Use new maps add function
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Nov 2016 11:58:32 +0000 (11:58 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 24 Nov 2016 11:58:32 +0000 (11:58 +0000)
src/plugins/lua/clickhouse.lua
src/plugins/lua/greylist.lua
src/plugins/lua/ip_score.lua
src/plugins/lua/mid.lua
src/plugins/lua/mime_types.lua
src/plugins/lua/once_received.lua
src/plugins/lua/ratelimit.lua
src/plugins/lua/rbl.lua

index 045e4a1751b8b7897aa9542781cf85ac1a640495..09e634b276a7503916e7e95e52e190f18fe4ed04 100644 (file)
@@ -493,13 +493,8 @@ if opts then
     if not settings['server'] then
       rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
     else
-      if settings['from_tables'] then
-        settings['from_map'] = rspamd_config:add_map({
-          url = settings['from_tables'],
-          description = 'clickhouse specific domains',
-          type = 'regexp'
-        })
-      end
+      settings['from_map'] = rspamd_map_add('clickhouse', 'from_tables',
+        'regexp', 'clickhouse specific domains')
       clickhouse_first_row()
       rspamd_config:register_symbol({
         name = 'CLICKHOUSE_COLLECT',
index 3d946fcf5d53cbe3f9c728dd32ce6a58e9cb2400..c3e0e88695acbe21a767f37052b39ce01adcf090 100644 (file)
@@ -359,17 +359,10 @@ if opts then
       settings[k] = v
     end
   end
-  if settings['whitelisted_ip'] then
-    whitelisted_ip = rspamd_config:add_radix_map(settings['whitelisted_ip'],
-      'Greylist whitelist ip map')
-  end
-  if settings['whitelist_domains_url'] and #settings['whitelist_domains_url'] > 0 then
-    whitelist_domains_map = rspamd_config:add_map ({
-      url = settings['whitelist_domains_url'],
-      type = 'map',
-      description = 'Greylist whitelist domains map'
-    })
-  end
+  whitelisted_ip = rspamd_map_add('greylist', 'whitelisted_ip', 'radix',
+    'Greylist whitelist ip map')
+  whitelist_domains_map = rspamd_map_add('greylist', 'whitelist_domains_url',
+    'map', 'Greylist whitelist domains map')
 
   redis_params = rspamd_parse_redis_server('greylist')
   if not redis_params then
index e352bdafff8e8aff0813279c638c7c25dfd8d83d..50775a37d2ecc8d64fce2c218c49ffb05c5e1d44 100644 (file)
@@ -346,12 +346,10 @@ local configure_ip_score_module = function()
     rspamd_logger.infox(rspamd_config, 'no servers are specified')
     return
   end
-  if options['whitelist'] then
-    whitelist = rspamd_config:add_radix_map(opts['whitelist'])
-  end
-  if options['asn_cc_whitelist'] then
-    asn_cc_whitelist = rspamd_config:add_hash_map(opts['asn_cc_whitelist'])
-  end
+  whitelist = rspamd_map_add('ip_score', 'asn_cc_whitelist', 'map',
+    'IP score whitelisted ips')
+  asn_cc_whitelist = rspamd_map_add('ip_score', 'whitelist', 'radix',
+    'IP score whitelisted ASNs/countries')
   return true
 end
 
index 5c29f5ab47c7226c5eefff40b4cf7170f87d2180..aad626fe6a292d54ebe8a58b23726a72d8509b42 100644 (file)
@@ -66,13 +66,8 @@ if opts then
     settings[k] = v
   end
 
-  if settings['url'] and #settings['url'] > 0 then
-    map = rspamd_config:add_map ({
-      url = settings['url'],
-      type = 'map',
-      description = 'Message-IDs map'
-    })
-
+  map = rspamd_map_add('mid', 'url', 'map', 'Message-IDs map')
+  if map then
     local id = rspamd_config:register_symbol({
       name = 'KNOWN_MID_CALLBACK',
       type = 'callback',
index a33bd28b966114149dabfe6eab699f0def92effb..5415674b159ec3b5358039771386ed2ec169640e 100644 (file)
@@ -202,21 +202,11 @@ if opts then
     settings[k] = v
   end
 
-  if settings['file'] and #settings['file'] > 0 then
-
-    if settings['regexp'] then
-      map = rspamd_config:add_map ({
-        url = settings['file'],
-        type = 'regexp',
-        description = 'mime types map (regexps)'
-      })
-    else
-      map = rspamd_config:add_map ({
-        url = settings['file'],
-        type = 'map',
-        description = 'mime types map (plain)'
-      })
-    end
+  local type = 'map'
+  if settings['regexp'] then type = 'regexp' end
+  map = rspamd_map_add('mime_types', 'file', type,
+    'mime types map')
+  if map then
     local id = rspamd_config:register_symbol({
       callback = check_mime_type,
       type = 'callback'
index 8c7ed0777bf457ef6ecd82173c4ed43b9ea62e26..65e6127c9a3288cd15fc1e7104edd9ecb51f49eb 100644 (file)
@@ -177,7 +177,8 @@ if opts then
           good_hosts = v
         end
       elseif n == 'whitelist' then
-        whitelist = rspamd_config:add_radix_map (v, 'once received whitelist')
+        whitelist = rspamd_map_add('once_received', 'whitelist', 'radix',
+          'once received whitelist')
       end
     end
 
index a05ebc2e9d8fb39c53de2e388978e65722a81fe2..32b2ba2d4719aea7b216a2d5f64e4c1d0d6d8e6a 100644 (file)
@@ -528,15 +528,13 @@ if opts then
   end
 
   if opts['whitelisted_ip'] then
-    whitelisted_ip = rspamd_config:add_radix_map(opts['whitelisted_ip'], 'Ratelimit whitelist ip map')
+    whitelisted_ip = rspamd_map_add('ratelimit', 'whitelisted_ip', 'radix',
+      'Ratelimit whitelist ip map')
   end
 
   if opts['whitelisted_user'] then
-    whitelisted_user = rspamd_config:add_map({
-      ['url'] = opts['whitelisted_user'],
-      ['description'] = 'Ratelimit whitelist user map',
-      ['type'] = 'set'
-    })
+    whitelisted_ip = rspamd_map_add('ratelimit', 'whitelisted_user', 'set',
+      'Ratelimit whitelist user map')
   end
 
   if opts['symbol'] then
index b1d35afc40aa3c04633a189e8e46d8fe09340cda..74eb5e64b80cc8e410b6696303dee40ba2447aab 100644 (file)
@@ -418,7 +418,8 @@ for default, default_v in pairs(default_defaults) do
 end
 
 if(opts['local_exclude_ip_map'] ~= nil) then
-  local_exclusions = rspamd_config:add_radix_map(opts['local_exclude_ip_map'])
+  local_exclusions = rspamd_map_add('rbl', 'local_exclude_ip_map', 'radix',
+    'RBL exclusions map')
 end
 
 local white_symbols = {}