resolve_table_elt.what)
end
end
+
+ local function insert_result(s, ip)
+ if rbl.symbols_prefixes then
+ local prefix = rbl.symbols_prefixes[resolve_table_elt.what]
+
+ if not prefix then
+ rspamd_logger.warnx(task, 'unlisted symbol prefix for %s', resolve_table_elt.what)
+ task:insert_result(s, 1.0, make_option(ip))
+ else
+ task:insert_result(prefix .. '_' .. s, 1.0, make_option(ip))
+ end
+ else
+ task:insert_result(s, 1.0, make_option(ip))
+ end
+ end
+
if err and (err ~= 'requested record is not found' and
err ~= 'no records with this name') then
rspamd_logger.infox(task, 'error looking up %s: %s', to_resolve, err)
end
if rbl.returncodes == nil and rbl.returnbits == nil and rbl.symbol ~= nil then
- task:insert_result(rbl.symbol, 1, make_option())
+ insert_result(rbl.symbol)
return
end
for _,check_bit in ipairs(bits) do
if bit.band(ipnum, check_bit) == check_bit then
foundrc = true
- task:insert_result(s, 1, make_option())
+ insert_result(s)
-- Here, we continue with other bits
end
end
for _,v in ipairs(codes) do
if string.find(ipstr, '^' .. v .. '$') then
foundrc = true
- task:insert_result(s, 1, make_option())
+ insert_result(s)
break
end
end
if not foundrc then
if rbl.unknown and rbl.symbol then
- task:insert_result(rbl.symbol, 1, make_option(ipstr))
+ insert_result(rbl.symbol, ipstr)
else
rspamd_logger.errx(task, 'RBL %1 returned unknown result: %2',
rbl.rbl, ipstr)
local callback,description = gen_rbl_callback(rbl)
if callback then
- local id = rspamd_config:register_symbol{
- type = 'callback',
- callback = callback,
- name = rbl.symbol,
- flags = table.concat(flags_tbl, ',')
- }
+ local id
+
+ if rbl.symbols_prefixes then
+ if not rbl.symbol:match('_CHECK$') then
+ rbl.symbol = rbl.symbol .. '_CHECK'
+ end
+
+ id = rspamd_config:register_symbol{
+ type = 'callback',
+ callback = callback,
+ name = rbl.symbol,
+ flags = table.concat(flags_tbl, ',')
+ }
+
+ for _,prefix in pairs(rbl.symbols_prefixes) do
+ rspamd_config:register_symbol{
+ type = 'virtual',
+ parent = id,
+ name = prefix .. '_' .. rbl.symbol,
+ }
+ end
+ else
+ id = rspamd_config:register_symbol{
+ type = 'callback',
+ callback = callback,
+ name = rbl.symbol,
+ flags = table.concat(flags_tbl, ',')
+ }
+ end
+
rspamd_logger.infox(rspamd_config, 'added rbl rule %s: %s',
rbl.symbol, description)
local function process_return_code(s)
if s ~= rbl.symbol then
-- hack
- rspamd_config:register_symbol({
- name = s,
- parent = id,
- type = 'virtual'
- })
+ if rbl.symbols_prefixes then
+ for _,prefix in pairs(rbl.symbols_prefixes) do
+ rspamd_config:register_symbol{
+ type = 'virtual',
+ parent = id,
+ name = prefix .. '_' .. s,
+ }
+ end
+ else
+ rspamd_config:register_symbol({
+ name = s,
+ parent = id,
+ type = 'virtual'
+ })
+ end
+
end
if rbl.is_whitelist then
requests_limit = (ts.integer + ts.string / tonumber):is_optional(),
process_script = ts.string:is_optional(),
emails_delimiter = ts.string:is_optional(),
+ symbols_prefixes = ts.map_of(ts.string, ts.string):is_optional(),
}, {
-- Covers boolean defaults
extra_fields = ts.map_of(ts.string, ts.boolean)