diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-01 12:02:21 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-07-01 12:02:21 +0100 |
commit | b00eb164fb661201e3a29a72522d911731f12f25 (patch) | |
tree | a5726d07e6bd76735a6329b3d1451bdebc373aa2 /rules/controller | |
parent | f860d55ac4b9b678b0a1419e88bf014d9bca72f5 (diff) | |
download | rspamd-b00eb164fb661201e3a29a72522d911731f12f25.tar.gz rspamd-b00eb164fb661201e3a29a72522d911731f12f25.zip |
[Feature] Add maps query method
Diffstat (limited to 'rules/controller')
-rw-r--r-- | rules/controller/maps.lua | 17 |
1 files changed, 16 insertions, 1 deletions
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 |