diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/rspamc.cxx | 6 | ||||
-rw-r--r-- | src/libmime/lang_detection_fasttext.cxx | 4 | ||||
-rw-r--r-- | src/libserver/backtrace.cxx | 4 | ||||
-rw-r--r-- | src/libserver/cfg_rcl.cxx | 4 | ||||
-rw-r--r-- | src/libserver/cfg_utils.cxx | 4 | ||||
-rw-r--r-- | src/libserver/css/css_parser.cxx | 4 | ||||
-rw-r--r-- | src/libserver/css/css_selector.cxx | 4 | ||||
-rw-r--r-- | src/libserver/css/css_value.cxx | 4 | ||||
-rw-r--r-- | src/libserver/html/html.cxx | 12 | ||||
-rw-r--r-- | src/libserver/html/html_tests.cxx | 4 | ||||
-rw-r--r-- | src/libserver/hyperscan_tools.cxx | 4 | ||||
-rw-r--r-- | src/libserver/maps/map.c | 31 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_impl.cxx | 4 | ||||
-rw-r--r-- | src/libserver/symcache/symcache_item.cxx | 4 | ||||
-rw-r--r-- | src/libstat/backends/cdb_backend.cxx | 4 | ||||
-rw-r--r-- | src/libstat/backends/redis_backend.cxx | 4 | ||||
-rw-r--r-- | src/libutil/cxx/file_util.cxx | 4 | ||||
-rw-r--r-- | src/lua/lua_shingles.cxx | 2 | ||||
-rw-r--r-- | src/plugins/lua/gpt.lua | 62 | ||||
-rw-r--r-- | src/plugins/lua/settings.lua | 150 |
20 files changed, 155 insertions, 164 deletions
diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx index 31a4aaf24..404359877 100644 --- a/src/client/rspamc.cxx +++ b/src/client/rspamc.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ #include "frozen/string.h" #include "frozen/unordered_map.h" -#include "fmt/format.h" -#include "fmt/color.h" +#include "contrib/fmt/include/fmt/format.h" +#include "contrib/fmt/include/fmt/color.h" #include "libutil/cxx/file_util.hxx" #include "libutil/cxx/util.hxx" diff --git a/src/libmime/lang_detection_fasttext.cxx b/src/libmime/lang_detection_fasttext.cxx index 89916151f..8ea2706e6 100644 --- a/src/libmime/lang_detection_fasttext.cxx +++ b/src/libmime/lang_detection_fasttext.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "fasttext/fasttext.h" #include "libserver/cfg_file.h" #include "libserver/logger.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "stat_api.h" #include <exception> #include <string_view> diff --git a/src/libserver/backtrace.cxx b/src/libserver/backtrace.cxx index c24e61936..5ebde677e 100644 --- a/src/libserver/backtrace.cxx +++ b/src/libserver/backtrace.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #ifdef BACKWARD_ENABLE #include "contrib/backward-cpp/backward.hpp" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "logger.h" namespace rspamd { diff --git a/src/libserver/cfg_rcl.cxx b/src/libserver/cfg_rcl.cxx index 6ea8945ab..f38366908 100644 --- a/src/libserver/cfg_rcl.cxx +++ b/src/libserver/cfg_rcl.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ #include <algorithm>// for std::transform #include <memory> #include "contrib/ankerl/unordered_dense.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "libutil/cxx/util.hxx" #include "libutil/cxx/file_util.hxx" #include "frozen/unordered_set.h" diff --git a/src/libserver/cfg_utils.cxx b/src/libserver/cfg_utils.cxx index 9612cdae4..dfbdc6bee 100644 --- a/src/libserver/cfg_utils.cxx +++ b/src/libserver/cfg_utils.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ #include <string> #include <string_view> #include <vector> -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "cxx/util.hxx" #include "frozen/unordered_map.h" #include "frozen/string.h" diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx index 11fa830f0..ade499ba4 100644 --- a/src/libserver/css/css_parser.cxx +++ b/src/libserver/css/css_parser.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "css_rule.hxx" #include "css_util.hxx" #include "css.hxx" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include <vector> #include <unicode/utf8.h> diff --git a/src/libserver/css/css_selector.cxx b/src/libserver/css/css_selector.cxx index d2ae093cb..527b12377 100644 --- a/src/libserver/css/css_selector.cxx +++ b/src/libserver/css/css_selector.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include "css_selector.hxx" #include "css.hxx" #include "libserver/html/html.hxx" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL #include "doctest/doctest.h" diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx index f2ff55363..52a61d3b6 100644 --- a/src/libserver/css/css_value.cxx +++ b/src/libserver/css/css_value.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ #include "frozen/string.h" #include "libutil/util.h" #include "contrib/ankerl/unordered_dense.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL #include "doctest/doctest.h" diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 0fe31c2a3..93d1fdf91 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1,11 +1,11 @@ -/*- - * Copyright 2021 Vsevolod Stakhov +/* + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -35,9 +35,9 @@ #include "html_tag.hxx" #include "html_url.hxx" -#include <frozen/unordered_map.h> -#include <frozen/string.h> -#include <fmt/core.h> +#include "contrib/frozen/include/frozen/unordered_map.h" +#include "contrib/frozen/include/frozen/string.h" +#include "contrib/fmt/include/fmt/core.h" #include <unicode/uversion.h> diff --git a/src/libserver/html/html_tests.cxx b/src/libserver/html/html_tests.cxx index 00595feaa..3be836a2d 100644 --- a/src/libserver/html/html_tests.cxx +++ b/src/libserver/html/html_tests.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include "libserver/task.h" #include <vector> -#include <fmt/core.h> +#include "contrib/fmt/include/fmt/core.h" #define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL diff --git a/src/libserver/hyperscan_tools.cxx b/src/libserver/hyperscan_tools.cxx index 5035bee2c..75863bf39 100644 --- a/src/libserver/hyperscan_tools.cxx +++ b/src/libserver/hyperscan_tools.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include <filesystem> #include "contrib/ankerl/unordered_dense.h" #include "contrib/ankerl/svector.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "libutil/cxx/file_util.hxx" #include "libutil/cxx/error.hxx" #include "hs.h" diff --git a/src/libserver/maps/map.c b/src/libserver/maps/map.c index 43a9d5d86..97130ad7c 100644 --- a/src/libserver/maps/map.c +++ b/src/libserver/maps/map.c @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -295,6 +295,23 @@ rspamd_map_cache_cb(struct ev_loop *loop, ev_timer *w, int revents) } } +static inline time_t +rspamd_http_map_process_next_check(time_t now, time_t expires, time_t map_check_interval) +{ + static const time_t interval_mult = 16; + /* By default use expires header */ + time_t next_check = expires; + + if (expires < now) { + return now; + } + else if (expires - now > map_check_interval * interval_mult) { + next_check = now + map_check_interval * interval_mult; + } + + return next_check; +} + static int http_map_finish(struct rspamd_http_connection *conn, struct rspamd_http_message *msg) @@ -371,10 +388,9 @@ http_map_finish(struct rspamd_http_connection *conn, hdate = rspamd_http_parse_date(expires_hdr->begin, expires_hdr->len); if (hdate != (time_t) -1 && hdate > msg->date) { - cached_timeout = map->next_check - msg->date + - map->poll_timeout * 2; - - map->next_check = hdate; + map->next_check = rspamd_http_map_process_next_check(msg->date, hdate, + (time_t) map->poll_timeout); + cached_timeout = map->next_check - msg->date; } else { msg_info_map("invalid expires header: %T, ignore it", expires_hdr); @@ -528,7 +544,8 @@ http_map_finish(struct rspamd_http_connection *conn, hdate = rspamd_http_parse_date(expires_hdr->begin, expires_hdr->len); if (hdate != (time_t) -1 && hdate > msg->date) { - map->next_check = hdate; + map->next_check = rspamd_http_map_process_next_check(msg->date, hdate, + (time_t) map->poll_timeout); } else { msg_info_map("invalid expires header: %T, ignore it", expires_hdr); @@ -1663,7 +1680,7 @@ rspamd_map_read_http_cached_file(struct rspamd_map *map, double now = rspamd_get_calendar_ticks(); if (header.next_check > now) { - map->next_check = header.next_check; + map->next_check = rspamd_http_map_process_next_check(now, header.next_check, map->poll_timeout); } else { map->next_check = now; diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index 7159555d2..4d17348c2 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ #include "unix-std.h" #include "libutil/cxx/file_util.hxx" #include "libutil/cxx/util.hxx" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "contrib/t1ha/t1ha.h" #ifdef __has_include diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index 233e8113a..f58332ea5 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ #include "lua/lua_common.h" #include "symcache_internal.hxx" #include "symcache_item.hxx" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "libserver/task.h" #include "libutil/cxx/util.hxx" #include <numeric> diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx index bd05e8ef8..0f55a725c 100644 --- a/src/libstat/backends/cdb_backend.cxx +++ b/src/libstat/backends/cdb_backend.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ #include <optional> #include "contrib/expected/expected.hpp" #include "contrib/ankerl/unordered_dense.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" namespace rspamd::stat::cdb { diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx index 06842b078..7137904e9 100644 --- a/src/libstat/backends/redis_backend.cxx +++ b/src/libstat/backends/redis_backend.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2024 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include "stat_internal.h" #include "upstream.h" #include "libserver/mempool_vars_internal.h" -#include "fmt/base.h" +#include "contrib/fmt/include/fmt/base.h" #include "libutil/cxx/error.hxx" diff --git a/src/libutil/cxx/file_util.cxx b/src/libutil/cxx/file_util.cxx index 2f031f076..bc5dcdf3b 100644 --- a/src/libutil/cxx/file_util.cxx +++ b/src/libutil/cxx/file_util.cxx @@ -1,5 +1,5 @@ /* - * Copyright 2023 Vsevolod Stakhov + * Copyright 2025 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ #include "file_util.hxx" -#include <fmt/core.h> +#include "contrib/fmt/include/fmt/core.h" #include "libutil/util.h" #include "libutil/unix-std.h" diff --git a/src/lua/lua_shingles.cxx b/src/lua/lua_shingles.cxx index 4682ef74f..7d4b277fc 100644 --- a/src/lua/lua_shingles.cxx +++ b/src/lua/lua_shingles.cxx @@ -17,7 +17,7 @@ #include "lua_common.h" #include "lua_classnames.h" #include "shingles.h" -#include "fmt/format.h" +#include "contrib/fmt/include/fmt/format.h" /*** * @module rspamd_shingle diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 625450fd9..1d5c4b21e 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -15,7 +15,7 @@ limitations under the License. ]] -- local N = "gpt" -local REDIS_PREFIX = "rsllm_" +local REDIS_PREFIX = "rsllm" local E = {} if confighelp then @@ -65,6 +65,7 @@ local lua_mime = require "lua_mime" local lua_redis = require "lua_redis" local ucl = require "ucl" local fun = require "fun" +local lua_cache = require "lua_cache" -- Exclude checks if one of those is found local default_symbols_to_except = { @@ -120,10 +121,11 @@ local settings = { allow_passthrough = false, allow_ham = false, json = false, - redis_cache_expire = 3600 * 24, extra_symbols = nil, + cache_prefix = REDIS_PREFIX, } local redis_params +local cache_context local function default_condition(task) -- Check result @@ -474,27 +476,10 @@ local function redis_cache_key(sel_part) digest:update(settings.url) env_digest = digest:hex():sub(1, 4) end - return string.format('%s%s_%s', REDIS_PREFIX, env_digest, + return string.format('%s_%s', env_digest, sel_part:get_mimepart():get_digest():sub(1, 24)) end -local function maybe_save_cache(task, result, sel_part) - if not sel_part or not redis_params then - lua_util.debugm(N, task, 'cannot save cache: no part or no redis') - return -- cannot save intentionally - end - - local cache_key = redis_cache_key(sel_part) - lua_util.debugm(N, task, 'saving cache for %s', cache_key) - local result_json = ucl.to_format(result, 'json-compact') - lua_redis.redis_make_request(task, redis_params, cache_key, false, function(err, _) - if err then - rspamd_logger.errx(task, 'cannot save cache: %s', err) - end - end, - 'SETEX', { cache_key, tostring(settings.redis_cache_expire), result_json }) -end - local function process_categories(task, categories) for _, category in ipairs(categories) do local sym = categories_map[category:lower()] @@ -531,7 +516,10 @@ local function insert_results(task, result, sel_part) process_categories(task, result.categories) end end - maybe_save_cache(task, result, sel_part) + + if cache_context then + lua_cache.cache_set(task, redis_cache_key(sel_part), result, cache_context) + end end local function check_consensus_and_insert_results(task, results, sel_part) @@ -613,32 +601,21 @@ end local function check_llm_cached(task, content, sel_part) local cache_key = redis_cache_key(sel_part) - local ret = lua_redis.redis_make_request(task, redis_params, cache_key, false, function(err, data) + lua_cache.cache_get(task, cache_key, cache_context, settings.timeout * 1.5, function() + check_llm_uncached(task, content, sel_part) + end, function(_, err, data) if err then - rspamd_logger.errx(task, 'cannot check cache: %s', err) + rspamd_logger.errx(task, 'cannot get cache: %s', err) check_llm_uncached(task, content, sel_part) end - if type(data) == 'string' then - local parser = ucl.parser() - local res, parse_err = parser:parse_string(data) - if not res then - rspamd_logger.errx(task, 'Cannot parse cached response: %s', parse_err) - check_llm_uncached(task, content, sel_part) - else - rspamd_logger.infox(task, 'found cached response %s', cache_key) - insert_results(task, parser:get_object()) - end + if data then + rspamd_logger.infox(task, 'found cached response %s', cache_key) + insert_results(task, data, sel_part) else check_llm_uncached(task, content, sel_part) end - end, - 'GET', { cache_key }) - - if not ret then - rspamd_logger.errx(task, 'cannot query cache for request') - check_llm_uncached(task, content, sel_part) - end + end) end local function openai_check(task, content, sel_part) @@ -896,10 +873,7 @@ if opts then settings = lua_util.override_defaults(settings, opts) if redis_params then - lua_redis.register_prefix(REDIS_PREFIX .. '*', N, - 'Cache of LLM requests', { - type = 'string', - }) + cache_context = lua_cache.create_cache_context(redis_params, settings, N) end if not settings.symbols_to_except then diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 69d31d301..0f8e00723 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -248,17 +248,13 @@ local function check_string_setting(expected, str) end local function check_ip_setting(expected, ip) - if not expected[2] then - if lua_maps.rspamd_maybe_check_map(expected[1], ip:to_string()) then + if type(expected) == "string" then + if lua_maps.rspamd_maybe_check_map(expected, ip:to_string()) then return true end else - if expected[2] ~= 0 then - local nip = ip:apply_mask(expected[2]) - if nip and nip:to_string() == expected[1] then - return true - end - elseif ip:to_string() == expected[1] then + local nip = ip:apply_mask(expected[2]) + if nip and nip:to_string() == expected[1] then return true end end @@ -464,44 +460,52 @@ local function gen_settings_external_cb(name) end -- Process IP address: converted to a table {ip, mask} -local function process_ip_condition(ip) - local out = {} - +local function process_ip_condition(ip, out) if type(ip) == "table" then for _, v in ipairs(ip) do - table.insert(out, process_ip_condition(v)) + process_ip_condition(v, out) end - elseif type(ip) == "string" then - local slash = string.find(ip, '/') + return + end - if not slash then - -- Just a plain IP address - local res = rspamd_ip.from_string(ip) + if type(ip) == "string" then + if string.sub(ip, 1, 4) == "map:" then + -- It is a map, don't apply any extra logic + table.insert(out, ip) + return + end - if res:is_valid() then - out[1] = res:to_string() - out[2] = 0 - else - -- It can still be a map - out[1] = ip - end - else - local res = rspamd_ip.from_string(string.sub(ip, 1, slash - 1)) - local mask = tonumber(string.sub(ip, slash + 1)) + local mask + local slash = string.find(ip, '/') + if slash then + mask = string.sub(ip, slash + 1) + ip = string.sub(ip, 1, slash - 1) + end + + local res = rspamd_ip.from_string(ip) + if res:is_valid() then + if mask then + local mask_num = tonumber(mask) + if mask_num then + -- normalize IP + res = res:apply_mask(mask_num) + if res:is_valid() then + table.insert(out, { res:to_string(), mask_num }) + return + end + end - if res:is_valid() then - out[1] = res:to_string() - out[2] = mask - else - rspamd_logger.errx(rspamd_config, "bad IP address: " .. ip) - return nil + rspamd_logger.errx(rspamd_config, "bad IP mask: %s/%s", ip, mask) + return end + + -- Just a plain IP address + table.insert(out, res:to_string()) + return end - else - return nil end - return out + rspamd_logger.errx(rspamd_config, "bad IP address: " .. ip) end -- Process email like condition, converted to a table with fields: @@ -613,6 +617,12 @@ end -- Used to create a checking closure: if value matches expected somehow, return true local function gen_check_closure(expected, check_func) + if not check_func then + check_func = function(a, b) + return a == b + end + end + return function(value) if not value then return false @@ -623,13 +633,6 @@ local function gen_check_closure(expected, check_func) end if value then - - if not check_func then - check_func = function(a, b) - return a == b - end - end - local ret if type(expected) == 'table' then ret = fun.any(function(d) @@ -659,22 +662,21 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static) local checks = {} if elt.ip then - local ips_table = process_ip_condition(elt['ip']) + local ips_table = {} + process_ip_condition(elt.ip, ips_table) - if ips_table then - lua_util.debugm(N, rspamd_config, 'added ip condition to "%s": %s', - name, ips_table) - checks.ip = { - check = gen_check_closure(convert_to_table(elt.ip, ips_table), check_ip_setting), - extract = function(task) - local ip = task:get_from_ip() - if ip and ip:is_valid() then - return ip - end - return nil - end, - } - end + lua_util.debugm(N, rspamd_config, 'added ip condition to "%s": %s', + name, ips_table) + checks.ip = { + check = gen_check_closure(ips_table, check_ip_setting), + extract = function(task) + local ip = task:get_from_ip() + if ip and ip:is_valid() then + return ip + end + return nil + end, + } end if elt.ip_map then local ips_map = lua_maps.map_add_from_ucl(elt.ip_map, 'radix', @@ -697,23 +699,21 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static) end if elt.client_ip then - local client_ips_table = process_ip_condition(elt.client_ip) - - if client_ips_table then - lua_util.debugm(N, rspamd_config, 'added client_ip condition to "%s": %s', - name, client_ips_table) - checks.client_ip = { - check = gen_check_closure(convert_to_table(elt.client_ip, client_ips_table), - check_ip_setting), - extract = function(task) - local ip = task:get_client_ip() - if ip:is_valid() then - return ip - end - return nil - end, - } - end + local client_ips_table = {} + process_ip_condition(elt.client_ip, client_ips_table) + + lua_util.debugm(N, rspamd_config, 'added client_ip condition to "%s": %s', + name, client_ips_table) + checks.client_ip = { + check = gen_check_closure(client_ips_table, check_ip_setting), + extract = function(task) + local ip = task:get_client_ip() + if ip:is_valid() then + return ip + end + return nil + end, + } end if elt.client_ip_map then local ips_map = lua_maps.map_add_from_ucl(elt.ip_map, 'radix', |