]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Use upstreams for external maps
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 6 Nov 2022 21:37:50 +0000 (21:37 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 19 Nov 2022 12:44:14 +0000 (12:44 +0000)
lualib/lua_maps.lua

index 5d55484b22159288697925a897d914520f45cbe3..bbc7c1d9eb7bf925857362b431a70abe520f4f20 100644 (file)
@@ -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)