@@ -24,3 +24,4 @@ classify_headers = [

control_socket = "$DBDIR/rspamd.sock mode=0600";
history_rows = 200;
explicit_modules = ["settings"];
@@ -49,6 +49,7 @@ symbol).
* `control_socket`: path/bind credits for the control socket
* `classify_headers`: list of headers that are processed by statistics
* `history_rows`: number of rows in the recent history roll table
* `explicit_modules`: always load modules from the list even if they have no according configuration section in the file

## DNS options

@@ -48,6 +48,10 @@ settings {
"add header" = 5.0; # Please mention a space instead of underscore
}
}
# Always add these symbols when settings rule has matched
symbols [
"symbol2", "symbol4"
]
}
whitelist {
priority = low;
@@ -69,6 +73,7 @@ So each setting has the following attributes:
- `apply` - list of applied rules, identified by metric name (e.g. `default`)
+ `symbol` - modify weight of a symbol
+ `actions` - section of modified actions
- `symbols` - add symbols from the list if a rule has matched

Match section performs `AND` operation on different matches, for example, if you have
`from` and `rcpt` in the same rule, then rule matches only when `from` `AND` `rcpt` match.
@@ -216,6 +216,7 @@ struct rspamd_config {
gboolean deliver_lmtp; /**< use LMTP instead of SMTP */

GList *script_modules; /**< linked list of script modules to load */
GHashTable *explicit_modules; /**< modules that should be always loaded */

GList *filters; /**< linked list of all filters */
GList *workers; /**< linked list of all workers params */
@@ -1304,6 +1304,11 @@ rspamd_rcl_config_init (void)
rspamd_rcl_parse_struct_string,
G_STRUCT_OFFSET (struct rspamd_config, control_socket_path),
0);
rspamd_rcl_add_default_handler (sub,
"explicit_modules",
rspamd_rcl_parse_struct_string_list,
G_STRUCT_OFFSET (struct rspamd_config, explicit_modules),
RSPAMD_CL_FLAG_STRING_LIST_HASH);

/* New DNS configuration */
ssub = rspamd_rcl_add_section (&sub->subsections, "dns", NULL, NULL,
@@ -167,6 +167,7 @@ rspamd_config_defaults (struct rspamd_config *cfg)
cfg->cfg_params = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->metrics_symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->debug_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->explicit_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);

cfg->map_timeout = DEFAULT_MAP_TIMEOUT;

@@ -193,10 +194,12 @@ rspamd_config_free (struct rspamd_config *cfg)
g_hash_table_destroy (cfg->metrics_symbols);
g_hash_table_unref (cfg->classifiers_symbols);
g_hash_table_unref (cfg->debug_modules);
g_hash_table_unref (cfg->explicit_modules);

if (cfg->checksum) {
g_free (cfg->checksum);
}

g_list_free (cfg->classifiers);
g_list_free (cfg->metrics_list);
rspamd_mempool_delete (cfg->cfg_pool);
@@ -1019,6 +1022,11 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
is_c = TRUE;
}

if (g_hash_table_lookup (cfg->explicit_modules, module_name) != NULL) {
/* Always load module */
return TRUE;
}

if (is_c) {
gboolean found = FALSE;

@@ -200,10 +200,10 @@ local function check_settings(task)

if res then
if rule['whitelist'] then
return {whitelist = true}
else
return rule['apply']
rule['apply'] = {whitelist = true}
end

return rule
end

return nil
@@ -246,7 +246,15 @@ local function check_settings(task)
if rule then
rspamd_logger.infox(task, "<%1> apply settings according to rule %2",
task:get_message_id(), name)
task:set_settings(rule)
if rule['apply'] then
task:set_settings(rule)
end
if rule['symbols'] then
-- Add symbols, specified in the settings
each(function(val)
task:insert_result(val, 1.0)
end, rule['symbols'])
end
end
end
end