diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-26 17:24:15 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-26 17:24:15 +0000 |
commit | 625aec042ca53fc3d98200809c5fe9b3cf4b3117 (patch) | |
tree | c5264ca52fec97d05547916b63cb97e583c5af6f /src/plugins | |
parent | 9a6bd708e5d2de1ea31e2b01170fac7e072f6374 (diff) | |
download | rspamd-625aec042ca53fc3d98200809c5fe9b3cf4b3117.tar.gz rspamd-625aec042ca53fc3d98200809c5fe9b3cf4b3117.zip |
[Fix] Allow static maps
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/multimap.lua | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 7417a9fb3..b7043f466 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -674,7 +674,7 @@ local function add_multimap_rule(key, newrule) return nil end -- Check cdb flag - if string.find(newrule['map'], '^cdb://.*$') then + if type(newrule['map']) == 'string' and string.find(newrule['map'], '^cdb://.*$') then newrule['cdb'] = cdb.create(newrule['map']) if newrule['cdb'] then ret = true @@ -682,7 +682,7 @@ local function add_multimap_rule(key, newrule) rspamd_logger.warnx(rspamd_config, 'Cannot add rule: map doesn\'t exists: %1', newrule['map']) end - elseif string.find(newrule['map'], '^redis://.*$') then + elseif 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, ' .. 'cannot add redis map %s: %s', newrule['symbol'], newrule['map']) @@ -695,18 +695,21 @@ local function add_multimap_rule(key, newrule) ret = true end else - local map = urls[newrule['map']] - if map and map['type'] == newrule['type'] + if type(newrule['map']) == 'string' then + local map = urls[newrule['map']] + if map and map['type'] == newrule['type'] and map['regexp'] == newrule['regexp'] then - if newrule['type'] == 'ip' then - newrule['radix'] = map['map'] - else - newrule['hash'] = map['map'] + if newrule['type'] == 'ip' then + newrule['radix'] = map['map'] + else + newrule['hash'] = map['map'] + end + rspamd_logger.infox(rspamd_config, 'reuse url for %s: "%s"', + newrule['symbol'], newrule['map']) + ret = true end - rspamd_logger.infox(rspamd_config, 'reuse url for %s: "%s"', - newrule['symbol'], newrule['map']) - ret = true - else + end + if not ret then if newrule['type'] == 'ip' then newrule['radix'] = rspamd_config:add_map ({ url = newrule['map'], @@ -715,11 +718,13 @@ local function add_multimap_rule(key, newrule) }) if newrule['radix'] then ret = true - urls[newrule['map']] = { - type = 'ip', - map = newrule['radix'], - regexp = false - } + if type(newrule['map']) == 'string' then + urls[newrule['map']] = { + type = 'ip', + map = newrule['radix'], + regexp = false + } + end else rspamd_logger.warnx(rspamd_config, 'Cannot add rule: map doesn\'t exists: %1', newrule['map']) @@ -749,11 +754,13 @@ local function add_multimap_rule(key, newrule) end if newrule['hash'] then ret = true - urls[newrule['map']] = { - type = newrule['type'], - map = newrule['hash'], - regexp = newrule['regexp'] - } + if type(newrule['map']) == 'string' then + urls[newrule['map']] = { + type = newrule['type'], + map = newrule['hash'], + regexp = newrule['regexp'] + } + end else rspamd_logger.warnx(rspamd_config, 'Cannot add rule: map doesn\'t exists: %1', newrule['map']) |