[Minor] Maps: Export maps schema

This commit is contained in:
Vsevolod Stakhov 2019-08-27 11:28:38 +01:00
parent 50466eddf2
commit 9a2122307a
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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