From: Vsevolod Stakhov Date: Tue, 27 Aug 2019 10:28:38 +0000 (+0100) Subject: [Minor] Maps: Export maps schema X-Git-Tag: 2.0~336 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9a2122307a5f776a03def8198da5045a0818bc94;p=rspamd.git [Minor] Maps: Export maps schema --- diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 6b478ded8..094494dca 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -20,6 +20,7 @@ limitations under the License. ]]-- local rspamd_logger = require "rspamd_logger" +local ts = require("tableshape").types local exports = {} @@ -315,4 +316,24 @@ end exports.rspamd_maybe_check_map = rspamd_maybe_check_map +exports.map_schema = ts.one_of{ + ts.string, -- 'http://some_map' + ts.array_of(ts.string), -- ['foo', 'bar'] + ts.shape{ -- complex object + name = ts.string:is_optional(), + description = ts.string:is_optional(), + timeout = ts.number, + data = ts.array_of(ts.string):is_optional(), + -- Tableshape has no options support for something like key1 or key2? + upstreams = ts.one_of{ + ts.string, + ts.array_of(ts.string), + }:is_optional(), + url = ts.one_of{ + ts.string, + ts.array_of(ts.string), + }:is_optional(), + } +} + return exports diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 00a35e1d7..e0439e93b 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -27,6 +27,7 @@ local lua_util = require 'lua_util' local ts = require("tableshape").types local selectors = require "lua_selectors" local bit = require 'bit' +local lua_maps = require "lua_maps" -- This plugin implements various types of RBL checks -- Documentation can be found here: @@ -799,7 +800,7 @@ local default_options = { opts = lua_util.override_defaults(default_options, opts) if(opts['local_exclude_ip_map'] ~= nil) then - local_exclusions = rspamd_map_add(N, 'local_exclude_ip_map', 'radix', + local_exclusions = lua_maps.map_add(N, 'local_exclude_ip_map', 'radix', 'RBL exclusions map') end