ipv6 = ts.boolean:is_optional(),
is_whitelist = ts.boolean:is_optional(),
local_exclude_ip_map = ts.string:is_optional(),
- matcher = ts.one_of { "equality", "luapattern" }:is_optional(),
+ matcher = ts.one_of { "equality", "luapattern", "regexp" }:is_optional(),
monitored_address = ts.string:is_optional(),
no_ip = ts.boolean:is_optional(),
process_script = ts.string:is_optional(),
local hash = require 'rspamd_cryptobox_hash'
local rspamd_logger = require 'rspamd_logger'
+local rspamd_regexp = require 'rspamd_regexp'
local rspamd_util = require 'rspamd_util'
local rspamd_ip = require "rspamd_ip"
local fun = require 'fun'
return string.find(to_match, '^' .. pattern .. '$') and true or false
end
+matchers.regexp = function(to_match, pattern)
+ local re = rspamd_regexp.get_cached(pattern)
+ if not re then
+ re = rspamd_regexp.create_cached(pattern)
+ if not re then
+ rspamd_logger.errx('regexp did not compile: %s', pattern)
+ return false
+ end
+ end
+ return re:match(to_match)
+end
+
local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_table_elt, match)
local function make_option(ip, label)
if ip then
from = 'FAKE_RBL',
}
unknown = true;
+ matcher = "regexp";
returncodes = {
- "CODE_2" = "127.0.0.2";
- "CODE_3" = "127.0.0.3";
+ "CODE_2" = '^127\.0\.0\.2$';
+ "CODE_3" = '^127\.0\.0\.3$';
}
}
fake_whitelist {
rbl = "fake.wl";
symbol = "FAKE_WL_RBL_UNKNOWN";
unknown = true;
+ #matcher = "luapattern";
returncodes = {
- "FAKE_WL_RBL_CODE_2" = "127.0.0.2";
- "FAKE_WL_RBL_CODE_3" = "127.0.0.3";
+ "FAKE_WL_RBL_CODE_2" = "127%.0%.0%.2";
+ "FAKE_WL_RBL_CODE_3" = "127%.0%.0%.3";
}
}
RSPAMD_EMAILBL {