commit fbac436: [Minor] Use upstreams for external maps

Vsevolod Stakhov vsevolod at rspamd.com
Sat Nov 19 20:28:09 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-06 21:37:50 +0000
URL: https://github.com/rspamd/rspamd/commit/fbac436579ecd04fe3f943d6e04de72f0745e0e9

[Minor] Use upstreams for external maps

---
 lualib/lua_maps.lua | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index 5d55484b2..bbc7c1d9e 100644
--- a/lualib/lua_maps.lua
+++ b/lualib/lua_maps.lua
@@ -307,14 +307,20 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback)
     else
       if opt.external then
         -- External map definition, missing fields are handled by schema
-        local parse_err
-        ret.__data,parse_err = external_map_schema(opt)
+        local parse_res,parse_err = external_map_schema(opt)
 
-        if ret then
-          ret.__external = true
-          setmetatable(ret, ret_mt)
+        if parse_res then
+          ret.__upstreams = lua_util.http_upstreams_by_url(rspamd_config:get_mempool(), opt.backend)
+          if ret.__upstreams then
+            ret.__data = opt
+            ret.__external = true
+            setmetatable(ret, ret_mt)
 
-          return ret
+            return ret
+          else
+            rspamd_logger.errx(rspamd_config, 'cannot parse external map upstreams: %s',
+                opt.backend)
+          end
         else
           rspamd_logger.errx(rspamd_config, 'cannot parse external map: %s',
               parse_err)


More information about the Commits mailing list