commit b00eb16: [Feature] Add maps query method

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 1 11:28:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-01 12:02:21 +0100
URL: https://github.com/rspamd/rspamd/commit/b00eb164fb661201e3a29a72522d911731f12f25

[Feature] Add maps query method

---
 rules/controller/maps.lua | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/rules/controller/maps.lua b/rules/controller/maps.lua
index 42d761172..ec2392d56 100644
--- a/rules/controller/maps.lua
+++ b/rules/controller/maps.lua
@@ -47,8 +47,23 @@ end
 local function handle_query_map(_, conn, req_params)
   maybe_fill_maps_cache()
   if req_params.value and req_params.value ~= '' then
+    local results = {}
+    for uri,m in pairs(maps_cache) do
+      local value = m:get_key(req_params.value)
 
-    conn:send_ucl({success = false and true})
+      if value then
+        local result = {
+          map = uri,
+          alias = uri:match('/([^/]+)$'),
+          value = value
+        }
+        table.insert(results, result)
+      end
+    end
+    conn:send_ucl{
+      success = (#results > 0),
+      results = results
+    }
   else
     conn:send_error(404, 'missing value')
   end


More information about the Commits mailing list