{
struct rspamd_controller_worker_ctx *ctx = worker->ctx;
GList *cur;
- struct filter *f;
struct module_ctx *mctx;
GHashTableIter iter;
gpointer key, value;
rspamd_http_router_set_key (ctx->http, ctx->key);
}
- /* Attach plugins */
- cur = g_list_first (ctx->cfg->filters);
- while (cur) {
- f = cur->data;
- mctx = g_hash_table_lookup (ctx->cfg->c_modules, f->module->name);
- if (mctx != NULL && f->module->module_attach_controller_func != NULL) {
- f->module->module_attach_controller_func (mctx,
- ctx->custom_commands);
- }
- cur = g_list_next (cur);
- }
-
g_hash_table_iter_init (&iter, ctx->custom_commands);
while (g_hash_table_iter_next (&iter, &key, &value)) {
rspamd_http_router_add_path (ctx->http,
rspamd_controller_handle_custom);
}
+ g_hash_table_iter_init (&iter, ctx->cfg->c_modules);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ mctx = value;
+ if (mctx->mod->module_attach_controller_func != NULL) {
+ mctx->mod->module_attach_controller_func (mctx,
+ ctx->custom_commands);
+ }
+ }
+
ctx->resolver = dns_resolver_init (worker->srv->logger,
ctx->ev_base,
worker->srv->cfg);
g_hash_table_insert (cfg->c_modules,
(gpointer) mod->name,
mod_ctx);
+ mod_ctx->mod = mod;
}
}
while (cur) {
/* Perform modules configuring */
- mod = NULL;
- for (pmod = modules; *pmod != NULL; pmod ++) {
- if ((*pmod)->name && g_ascii_strcasecmp ((*pmod)->name,
- cur->data) == 0) {
- mod = *pmod;
-
- if (reconfig) {
- (void)mod->module_reconfig_func (cfg);
- msg_debug ("reconfig of %s", mod->name);
- }
- else {
- (void)mod->module_config_func (cfg);
- }
+ mod_ctx = NULL;
+ mod_ctx = g_hash_table_lookup (cfg->c_modules, cur->data);
+
+ if (mod_ctx) {
+ mod = mod_ctx->mod;
+ mod_ctx->enabled = TRUE;
+
+ if (reconfig) {
+ (void)mod->module_reconfig_func (cfg);
+ msg_debug ("reconfig of %s", mod->name);
+ }
+ else {
+ (void)mod->module_config_func (cfg);
}
}
- if (mod == NULL) {
+ if (mod_ctx == NULL) {
msg_warn ("requested unknown module %s", cur->data);
}
*/
struct module_ctx {
gint (*filter)(struct rspamd_task *task); /**< pointer to headers process function */
+ module_t *mod; /**< module pointer */
+ gboolean enabled; /**< true if module is enabled in configuration */
};
/**
};
struct chartable_ctx {
- gint (*filter) (struct rspamd_task * task);
+ struct module_ctx ctx;
const gchar *symbol;
double threshold;
{
chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx));
- chartable_module_ctx->filter = chartable_mime_filter;
chartable_module_ctx->chartable_pool = rspamd_mempool_new (
rspamd_mempool_suggest_size ());
}
}
-
-static gint
-chartable_mime_filter (struct rspamd_task *task)
-{
- /* XXX: remove it */
- return 0;
-}
#define DEFAULT_TIME_JITTER 60
struct dkim_ctx {
- gint (*filter) (struct rspamd_task * task);
+ struct module_ctx ctx;
const gchar *symbol_reject;
const gchar *symbol_tempfail;
const gchar *symbol_allow;
};
struct fuzzy_ctx {
- gint (*filter) (struct rspamd_task * task);
+ struct module_ctx ctx;
rspamd_mempool_t *fuzzy_pool;
GList *fuzzy_rules;
struct rspamd_config *cfg;
};
struct regexp_ctx {
+ struct module_ctx ctx;
rspamd_mempool_t *regexp_pool;
gsize max_size;
};
#define DEFAULT_CACHE_MAXAGE 86400
struct spf_ctx {
- gint (*filter) (struct rspamd_task * task);
+ struct module_ctx ctx;
const gchar *symbol_fail;
const gchar *symbol_softfail;
const gchar *symbol_neutral;
#define MAX_LEVELS 10
struct surbl_ctx {
- gint (*filter)(struct rspamd_task *task);
+ struct module_ctx ctx;
guint16 weight;
gdouble connect_timeout;
gdouble read_timeout;