local lua_util = require "lua_util"
local rspamd_ip = require "rspamd_ip"
local rspamd_regexp = require "rspamd_regexp"
+local lua_selectors = require "lua_selectors"
local ucl = require "ucl"
local fun = require "fun"
local settings_initialized = false
local max_pri = 0
+local selectors_cache = {} -- Used to speed up selectors in settings
+
local function apply_settings(task, to_apply)
task:set_settings(to_apply)
task:cache_set('settings', to_apply)
return false
end
- local function check_specific_setting(_, rule, ip, client_ip, from, rcpt,
+ local function check_specific_setting(rule_name, rule, ip, client_ip, from, rcpt,
user, auth_user)
local res = false
end
end
+ if rule['selector'] then
+ local sel = selectors_cache[rule_name]
+ if not sel then
+ sel = lua_selectors.create_selector_closure(rspamd_config, rule.selector,
+ rule.delimiter or "")
+
+ if sel then
+ selectors_cache[rule_name] = sel
+ end
+ end
+
+ if sel then
+ if sel(task) then
+ res = true
+ end
+ end
+ end
+
if res then
if rule['whitelist'] then
rule['apply'] = {whitelist = true}