commit 9a21223: [Minor] Maps: Export maps schema
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Aug 27 17:49:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-08-27 11:28:38 +0100
URL: https://github.com/rspamd/rspamd/commit/9a2122307a5f776a03def8198da5045a0818bc94
[Minor] Maps: Export maps schema
---
lualib/lua_maps.lua | 21 +++++++++++++++++++++
src/plugins/lua/rbl.lua | 3 ++-
2 files changed, 23 insertions(+), 1 deletion(-)
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
More information about the Commits
mailing list