@@ -345,7 +345,7 @@ bayes_classify (struct classifier_ctx * ctx, | |||
} | |||
rspamd_snprintf (sumbuf, 32, "%.2f%%", final_prob * 100.); | |||
cur = g_list_prepend (NULL, sumbuf); | |||
insert_result (task, | |||
rspamd_task_insert_result (task, | |||
data.statfiles[selected_st].st->symbol, | |||
final_prob, | |||
cur); |
@@ -316,7 +316,7 @@ winnow_classify (struct classifier_ctx *ctx, | |||
sumbuf = rspamd_mempool_alloc (task->task_pool, 32); | |||
rspamd_snprintf (sumbuf, 32, "%.2F", max); | |||
cur = g_list_prepend (NULL, sumbuf); | |||
insert_result (task, sel->symbol, max, cur); | |||
rspamd_task_insert_result (task, sel->symbol, max, cur); | |||
} | |||
return TRUE; |
@@ -378,7 +378,7 @@ rspamd_controller_handle_actions (struct rspamd_http_connection_entry *conn_ent, | |||
if (act->score >= 0) { | |||
obj = ucl_object_typed_new (UCL_OBJECT); | |||
ucl_object_insert_key (obj, | |||
ucl_object_fromstring (str_action_metric ( | |||
ucl_object_fromstring (rspamd_action_to_str ( | |||
act->action)), "action", 0, false); | |||
ucl_object_insert_key (obj, ucl_object_fromdouble ( | |||
act->score), "value", 0, false); | |||
@@ -704,7 +704,7 @@ rspamd_controller_handle_history (struct rspamd_http_connection_entry *conn_ent, | |||
ucl_object_insert_key (obj, ucl_object_fromstring ( | |||
ip_buf), "ip", 0, false); | |||
ucl_object_insert_key (obj, | |||
ucl_object_fromstring (str_action_metric ( | |||
ucl_object_fromstring (rspamd_action_to_str ( | |||
row->action)), "action", 0, false); | |||
ucl_object_insert_key (obj, ucl_object_fromdouble ( | |||
row->score), "score", 0, false); | |||
@@ -743,7 +743,7 @@ rspamd_controller_learn_fin_task (void *ud) | |||
conn_ent = task->fin_arg; | |||
session = conn_ent->ud; | |||
if (!learn_task_spam (session->cl, task, session->is_spam, &err)) { | |||
if (!rspamd_learn_task_spam (session->cl, task, session->is_spam, &err)) { | |||
rspamd_controller_send_error (conn_ent, 500 + err->code, err->message); | |||
return TRUE; | |||
} | |||
@@ -763,7 +763,7 @@ rspamd_controller_check_fin_task (void *ud) | |||
struct rspamd_http_connection_entry *conn_ent; | |||
struct rspamd_http_message *msg; | |||
process_statfiles (task); | |||
rspamd_process_statistics (task); | |||
conn_ent = task->fin_arg; | |||
msg = rspamd_http_new_message (HTTP_RESPONSE); | |||
msg->date = time (NULL); | |||
@@ -1289,7 +1289,7 @@ rspamd_controller_handle_stat_common ( | |||
for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i++) { | |||
ucl_object_insert_key (sub, | |||
ucl_object_fromint (stat->actions_stat[i]), | |||
str_action_metric (i), 0, false); | |||
rspamd_action_to_str (i), 0, false); | |||
if (i < METRIC_ACTION_GREYLIST) { | |||
spam += stat->actions_stat[i]; | |||
} |
@@ -504,7 +504,7 @@ process_stat_command (struct controller_session *session, gboolean do_reset) | |||
for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i++) { | |||
rspamd_printf_gstring (out, | |||
"Messages with action %s: %ud, %.2f%%" CRLF, | |||
str_action_metric ( | |||
rspamd_action_to_str ( | |||
i), | |||
stat->actions_stat[i], | |||
(double)stat->actions_stat[i] / (double)stat->messages_scanned * | |||
@@ -708,7 +708,7 @@ process_dynamic_conf_command (gchar **cmd_args, | |||
} | |||
if (is_action) { | |||
if (!check_action_str (name, &real_act)) { | |||
if (!rspamd_action_from_str (name, &real_act)) { | |||
msg_info ("invalid action string: %s", name); | |||
res = FALSE; | |||
} | |||
@@ -1658,7 +1658,7 @@ controller_read_socket (f_str_t * in, void *arg) | |||
return FALSE; | |||
} | |||
if (!learn_task (session->learn_symbol, task, &err)) { | |||
if (!rspamd_learn_task (session->learn_symbol, task, &err)) { | |||
rspamd_task_free (task, FALSE); | |||
if (err) { | |||
if (session->restful) { | |||
@@ -1759,7 +1759,7 @@ controller_read_socket (f_str_t * in, void *arg) | |||
session->learn_task = task; | |||
session->state = STATE_LEARN_SPAM; | |||
rspamd_dispatcher_pause (session->dispatcher); | |||
r = process_filters (task); | |||
r = rspamd_process_filters (task); | |||
if (r == -1) { | |||
rspamd_dispatcher_restore (session->dispatcher); | |||
session->state = STATE_REPLY; | |||
@@ -1966,7 +1966,7 @@ controller_write_socket (void *arg) | |||
} | |||
} | |||
else { | |||
if (!learn_task_spam (session->learn_classifier, | |||
if (!rspamd_learn_task_spam (session->learn_classifier, | |||
session->learn_task, session->in_class, &err)) { | |||
if (err) { | |||
if (session->restful) { |
@@ -63,7 +63,7 @@ filter_error_quark (void) | |||
} | |||
struct metric_result * | |||
create_metric_result (struct rspamd_task *task, const gchar *name) | |||
rspamd_create_metric_result (struct rspamd_task *task, const gchar *name) | |||
{ | |||
struct metric_result *metric_res; | |||
struct metric *metric; | |||
@@ -110,7 +110,7 @@ insert_metric_result (struct rspamd_task *task, | |||
gdouble *weight, w; | |||
const ucl_object_t *mobj, *sobj; | |||
metric_res = create_metric_result (task, metric->name); | |||
metric_res = rspamd_create_metric_result (task, metric->name); | |||
weight = g_hash_table_lookup (metric->symbols, symbol); | |||
if (weight == NULL) { | |||
@@ -265,7 +265,7 @@ insert_result_common (struct rspamd_task *task, | |||
/* Insert result that may be increased on next insertions */ | |||
void | |||
insert_result (struct rspamd_task *task, | |||
rspamd_task_insert_result (struct rspamd_task *task, | |||
const gchar *symbol, | |||
double flag, | |||
GList * opts) | |||
@@ -275,7 +275,7 @@ insert_result (struct rspamd_task *task, | |||
/* Insert result as a single option */ | |||
void | |||
insert_result_single (struct rspamd_task *task, | |||
rspamd_task_insert_result_single (struct rspamd_task *task, | |||
const gchar *symbol, | |||
double flag, | |||
GList * opts) | |||
@@ -299,7 +299,7 @@ check_metric_settings (struct rspamd_task *task, struct metric *metric, | |||
act = ucl_object_find_key (mobj, "actions"); | |||
if (act != NULL) { | |||
reject = ucl_object_find_key (act, | |||
str_action_metric (METRIC_ACTION_REJECT)); | |||
rspamd_action_to_str (METRIC_ACTION_REJECT)); | |||
if (reject != NULL && ucl_object_todouble_safe (reject, &val)) { | |||
*score = val; | |||
return TRUE; | |||
@@ -346,14 +346,14 @@ check_metric_is_spam (struct rspamd_task *task, struct metric *metric) | |||
} | |||
gint | |||
process_filters (struct rspamd_task *task) | |||
rspamd_process_filters (struct rspamd_task *task) | |||
{ | |||
GList *cur; | |||
struct metric *metric; | |||
gpointer item = NULL; | |||
/* Insert default metric to be sure that it exists all the time */ | |||
create_metric_result (task, DEFAULT_METRIC); | |||
rspamd_create_metric_result (task, DEFAULT_METRIC); | |||
if (task->settings) { | |||
const ucl_object_t *wl; | |||
@@ -568,7 +568,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) | |||
s = g_list_next (s); | |||
} | |||
/* Add new symbol */ | |||
insert_result_single (cd->task, key, 1.0, NULL); | |||
rspamd_task_insert_result_single (cd->task, key, 1.0, NULL); | |||
msg_info ("%s", logbuf); | |||
} | |||
} | |||
@@ -716,7 +716,7 @@ composites_metric_callback (gpointer key, gpointer value, gpointer data) | |||
} | |||
void | |||
make_composites (struct rspamd_task *task) | |||
rspamd_make_composites (struct rspamd_task *task) | |||
{ | |||
g_hash_table_foreach (task->results, composites_metric_callback, task); | |||
} | |||
@@ -871,7 +871,7 @@ classifiers_callback (gpointer value, void *arg) | |||
void | |||
process_statfiles (struct rspamd_task *task) | |||
rspamd_process_statistics (struct rspamd_task *task) | |||
{ | |||
struct classifiers_cbdata cbdata; | |||
@@ -889,11 +889,11 @@ process_statfiles (struct rspamd_task *task) | |||
g_list_foreach (task->cfg->classifiers, classifiers_callback, &cbdata); | |||
/* Process results */ | |||
make_composites (task); | |||
rspamd_make_composites (task); | |||
} | |||
void | |||
process_statfiles_threaded (gpointer data, gpointer user_data) | |||
rspamd_process_statistic_threaded (gpointer data, gpointer user_data) | |||
{ | |||
struct rspamd_task *task = (struct rspamd_task *)data; | |||
struct lua_locked_state *nL = user_data; | |||
@@ -977,7 +977,7 @@ insert_headers (struct rspamd_task *task) | |||
} | |||
gboolean | |||
check_action_str (const gchar *data, gint *result) | |||
rspamd_action_from_str (const gchar *data, gint *result) | |||
{ | |||
if (g_ascii_strncasecmp (data, "reject", sizeof ("reject") - 1) == 0) { | |||
*result = METRIC_ACTION_REJECT; | |||
@@ -1009,7 +1009,7 @@ check_action_str (const gchar *data, gint *result) | |||
} | |||
const gchar * | |||
str_action_metric (enum rspamd_metric_action action) | |||
rspamd_action_to_str (enum rspamd_metric_action action) | |||
{ | |||
switch (action) { | |||
case METRIC_ACTION_REJECT: | |||
@@ -1041,7 +1041,7 @@ get_specific_action_score (const ucl_object_t *metric, | |||
if (metric) { | |||
act = ucl_object_find_key (metric, "actions"); | |||
if (act) { | |||
sact = ucl_object_find_key (act, str_action_metric (action->action)); | |||
sact = ucl_object_find_key (act, rspamd_action_to_str (action->action)); | |||
if (sact != NULL && ucl_object_todouble_safe (sact, &score)) { | |||
return score; | |||
} | |||
@@ -1052,7 +1052,7 @@ get_specific_action_score (const ucl_object_t *metric, | |||
} | |||
gint | |||
check_metric_action (struct rspamd_task *task, | |||
rspamd_check_action_metric (struct rspamd_task *task, | |||
double score, double *rscore, struct metric *metric) | |||
{ | |||
struct metric_action *action, *selected_action = NULL; | |||
@@ -1092,7 +1092,7 @@ check_metric_action (struct rspamd_task *task, | |||
} | |||
gboolean | |||
learn_task (const gchar *statfile, struct rspamd_task *task, GError **err) | |||
rspamd_learn_task (const gchar *statfile, struct rspamd_task *task, GError **err) | |||
{ | |||
GList *cur, *ex; | |||
struct rspamd_classifier_config *cl; | |||
@@ -1237,7 +1237,7 @@ learn_task (const gchar *statfile, struct rspamd_task *task, GError **err) | |||
} | |||
gboolean | |||
learn_task_spam (struct rspamd_classifier_config *cl, | |||
rspamd_learn_task_spam (struct rspamd_classifier_config *cl, | |||
struct rspamd_task *task, | |||
gboolean is_spam, | |||
GError **err) |
@@ -84,7 +84,7 @@ struct rspamd_composite { | |||
* @param name name of metric | |||
* @return metric result or NULL if metric `name` has not been found | |||
*/ | |||
struct metric_result * create_metric_result (struct rspamd_task *task, | |||
struct metric_result * rspamd_create_metric_result (struct rspamd_task *task, | |||
const gchar *name); | |||
/** | |||
@@ -92,19 +92,19 @@ struct metric_result * create_metric_result (struct rspamd_task *task, | |||
* @param task worker's task that present message from user | |||
* @return 0 - if there is non-finished tasks and 1 if processing is completed | |||
*/ | |||
gint process_filters (struct rspamd_task *task); | |||
gint rspamd_process_filters (struct rspamd_task *task); | |||
/** | |||
* Process message with statfiles | |||
* @param task worker's task that present message from user | |||
*/ | |||
void process_statfiles (struct rspamd_task *task); | |||
void rspamd_process_statistics (struct rspamd_task *task); | |||
/** | |||
* Process message with statfiles threaded | |||
* @param data worker's task that present message from user | |||
*/ | |||
void process_statfiles_threaded (gpointer data, gpointer user_data); | |||
void rspamd_process_statistic_threaded (gpointer data, gpointer user_data); | |||
/** | |||
* Insert a result to task | |||
@@ -114,7 +114,7 @@ void process_statfiles_threaded (gpointer data, gpointer user_data); | |||
* @param flag numeric weight for symbol | |||
* @param opts list of symbol's options | |||
*/ | |||
void insert_result (struct rspamd_task *task, | |||
void rspamd_task_insert_result (struct rspamd_task *task, | |||
const gchar *symbol, | |||
double flag, | |||
GList *opts); | |||
@@ -127,7 +127,7 @@ void insert_result (struct rspamd_task *task, | |||
* @param flag numeric weight for symbol | |||
* @param opts list of symbol's options | |||
*/ | |||
void insert_result_single (struct rspamd_task *task, | |||
void rspamd_task_insert_result_single (struct rspamd_task *task, | |||
const gchar *symbol, | |||
double flag, | |||
GList *opts); | |||
@@ -136,7 +136,7 @@ void insert_result_single (struct rspamd_task *task, | |||
* Process all results and form composite metrics from existent metrics as it is defined in config | |||
* @param task worker's task that present message from user | |||
*/ | |||
void make_composites (struct rspamd_task *task); | |||
void rspamd_make_composites (struct rspamd_task *task); | |||
/** | |||
* Default consolidation function for metric, it get all symbols and multiply symbol | |||
@@ -145,7 +145,7 @@ void make_composites (struct rspamd_task *task); | |||
* @param metric_name name of metric | |||
* @return result metric weight | |||
*/ | |||
double factor_consolidation_func (struct rspamd_task *task, | |||
double rspamd_factor_consolidation_func (struct rspamd_task *task, | |||
const gchar *metric_name, | |||
const gchar *unused); | |||
@@ -156,7 +156,7 @@ double factor_consolidation_func (struct rspamd_task *task, | |||
* @param err pointer to GError | |||
* @return true if learn succeed | |||
*/ | |||
gboolean learn_task (const gchar *statfile, | |||
gboolean rspamd_learn_task (const gchar *statfile, | |||
struct rspamd_task *task, | |||
GError **err); | |||
@@ -167,7 +167,7 @@ gboolean learn_task (const gchar *statfile, | |||
* @param err pointer to GError | |||
* @return true if learn succeed | |||
*/ | |||
gboolean learn_task_spam (struct rspamd_classifier_config *cl, | |||
gboolean rspamd_learn_task_spam (struct rspamd_classifier_config *cl, | |||
struct rspamd_task *task, | |||
gboolean is_spam, | |||
GError **err); | |||
@@ -175,17 +175,17 @@ gboolean learn_task_spam (struct rspamd_classifier_config *cl, | |||
/* | |||
* Get action from a string | |||
*/ | |||
gboolean check_action_str (const gchar *data, gint *result); | |||
gboolean rspamd_action_from_str (const gchar *data, gint *result); | |||
/* | |||
* Return textual representation of action enumeration | |||
*/ | |||
const gchar * str_action_metric (enum rspamd_metric_action action); | |||
const gchar * rspamd_action_to_str (enum rspamd_metric_action action); | |||
/* | |||
* Get action for specific metric | |||
*/ | |||
gint check_metric_action (struct rspamd_task *task, | |||
gint rspamd_check_action_metric (struct rspamd_task *task, | |||
double score, | |||
double *rscore, | |||
struct metric *metric); |
@@ -195,7 +195,7 @@ smtp_metric_callback (gpointer key, gpointer value, gpointer ud) | |||
"(%s: %c (%s): [%.2f/%.2f/%.2f] [", | |||
(gchar *)key, | |||
is_spam ? 'T' : 'F', | |||
str_action_metric (action), | |||
rspamd_action_to_str (action), | |||
metric_res->score, | |||
ms, | |||
rs); |
@@ -393,7 +393,7 @@ rspamd_rcl_metric_handler (struct rspamd_config *cfg, const ucl_object_t *obj, | |||
return FALSE; | |||
} | |||
while ((cur = ucl_iterate_object (val, &it, true)) != NULL) { | |||
if (!check_action_str (ucl_object_key (cur), &action_value) || | |||
if (!rspamd_action_from_str (ucl_object_key (cur), &action_value) || | |||
!ucl_object_todouble_safe (cur, &action_score)) { | |||
g_set_error (err, | |||
CFG_RCL_ERROR, | |||
@@ -423,7 +423,7 @@ rspamd_rcl_metric_handler (struct rspamd_config *cfg, const ucl_object_t *obj, | |||
act_str = ucl_object_tostring (cur); | |||
semicolon = strchr (act_str, ':'); | |||
if (semicolon != NULL) { | |||
if (check_action_str (act_str, &action_value)) { | |||
if (rspamd_action_from_str (act_str, &action_value)) { | |||
action_score = strtod (semicolon + 1, NULL); | |||
action = &metric->actions[action_value]; | |||
action->action = action_value; |
@@ -108,7 +108,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) | |||
while ((it_val = ucl_iterate_object (cur_nm, &nit, true))) { | |||
if (ucl_object_find_key (it_val, "name") && | |||
ucl_object_find_key (it_val, "value")) { | |||
if (!check_action_str (ucl_object_tostring ( | |||
if (!rspamd_action_from_str (ucl_object_tostring ( | |||
ucl_object_find_key (it_val, "name")), &test_act)) { | |||
msg_err ("unknown action: %s", | |||
ucl_object_tostring (ucl_object_find_key (it_val, | |||
@@ -485,7 +485,7 @@ add_dynamic_action (struct rspamd_config *cfg, | |||
gdouble value) | |||
{ | |||
ucl_object_t *metric, *acts; | |||
const gchar *action_name = str_action_metric (action); | |||
const gchar *action_name = rspamd_action_to_str (action); | |||
if (cfg->dynamic_conf == NULL) { | |||
msg_info ("dynamic conf is disabled"); |
@@ -648,7 +648,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task, | |||
m = mres->metric; | |||
/* XXX: handle settings */ | |||
action = check_metric_action (task, mres->score, &required_score, m); | |||
action = rspamd_check_action_metric (task, mres->score, &required_score, m); | |||
is_spam = (action == METRIC_ACTION_REJECT); | |||
if (task->is_skipped) { | |||
action_char = 'S'; | |||
@@ -661,7 +661,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task, | |||
} | |||
rspamd_printf_gstring (logbuf, "(%s: %c (%s): [%.2f/%.2f] [", | |||
m->name, action_char, | |||
str_action_metric (action), | |||
rspamd_action_to_str (action), | |||
mres->score, required_score); | |||
obj = ucl_object_typed_new (UCL_OBJECT); | |||
@@ -674,7 +674,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task, | |||
ucl_object_insert_key (obj, ucl_object_fromdouble (required_score), | |||
"required_score", 0, false); | |||
ucl_object_insert_key (obj, | |||
ucl_object_fromstring (str_action_metric (action)), | |||
ucl_object_fromstring (rspamd_action_to_str (action)), | |||
"action", 0, false); | |||
if (action == METRIC_ACTION_REWRITE_SUBJECT) { | |||
@@ -835,7 +835,7 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg, | |||
/* Update stat for default metric */ | |||
metric_res = g_hash_table_lookup (task->results, DEFAULT_METRIC); | |||
if (metric_res != NULL) { | |||
action = check_metric_action (task, metric_res->score, &required_score, | |||
action = rspamd_check_action_metric (task, metric_res->score, &required_score, | |||
metric_res->metric); | |||
if (action <= METRIC_ACTION_NOACTION) { | |||
task->worker->srv->stat->actions_stat[action]++; |
@@ -129,7 +129,7 @@ rspamd_roll_history_update (struct roll_history *history, | |||
} | |||
else { | |||
row->score = metric_res->score; | |||
row->action = check_metric_action (task, metric_res->score, | |||
row->action = rspamd_check_action_metric (task, metric_res->score, | |||
&row->required_score, | |||
metric_res->metric); | |||
cbdata.pos = row->symbols; |
@@ -142,11 +142,11 @@ rspamd_task_fin (void *arg) | |||
/* Process all statfiles */ | |||
if (task->classify_pool == NULL) { | |||
/* Non-threaded version */ | |||
process_statfiles (task); | |||
rspamd_process_statistics (task); | |||
} | |||
else { | |||
/* Just process composites */ | |||
make_composites (task); | |||
rspamd_make_composites (task); | |||
} | |||
if (task->cfg->post_filters) { | |||
/* More to process */ | |||
@@ -173,7 +173,7 @@ rspamd_task_fin (void *arg) | |||
} | |||
else { | |||
task->state = WAIT_FILTER; | |||
r = process_filters (task); | |||
r = rspamd_process_filters (task); | |||
if (r == -1) { | |||
task->last_error = "Filter processing error"; | |||
task->error_code = RSPAMD_FILTER_ERROR; | |||
@@ -311,7 +311,7 @@ rspamd_task_process (struct rspamd_task *task, | |||
} | |||
task->skip_extra_filters = !process_extra_filters; | |||
if (!process_extra_filters || task->cfg->pre_filters == NULL) { | |||
r = process_filters (task); | |||
r = rspamd_process_filters (task); | |||
if (r == -1) { | |||
task->last_error = "filter processing error"; | |||
task->error_code = RSPAMD_FILTER_ERROR; |
@@ -167,7 +167,7 @@ lmtp_read_socket (f_str_t * in, void *arg) | |||
break; | |||
case READ_MESSAGE: | |||
r = process_message (lmtp->task); | |||
r = process_filters (lmtp->task); | |||
r = rspamd_process_filters (lmtp->task); | |||
if (r == -1) { | |||
return FALSE; | |||
} | |||
@@ -176,7 +176,7 @@ lmtp_read_socket (f_str_t * in, void *arg) | |||
rspamd_dispatcher_pause (lmtp->task->dispatcher); | |||
} | |||
else { | |||
process_statfiles (lmtp->task); | |||
rspamd_process_statistics (lmtp->task); | |||
task->state = WRITE_REPLY; | |||
lmtp_write_socket (lmtp); | |||
} |
@@ -273,7 +273,7 @@ lua_add_actions_global (lua_State *L) | |||
lua_newtable (L); | |||
for (i = METRIC_ACTION_REJECT; i <= METRIC_ACTION_NOACTION; i++) { | |||
lua_pushstring (L, str_action_metric (i)); | |||
lua_pushstring (L, rspamd_action_to_str (i)); | |||
lua_pushinteger (L, i); | |||
lua_settable (L, -3); | |||
} |
@@ -877,7 +877,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud) | |||
rspamd_mempool_strdup (task->task_pool, opt)); | |||
} | |||
} | |||
insert_result (task, cd->symbol, flag, opts); | |||
rspamd_task_insert_result (task, cd->symbol, flag, opts); | |||
} | |||
} | |||
lua_pop (cd->L, nresults); |
@@ -761,7 +761,7 @@ lua_task_insert_result (lua_State * L) | |||
rspamd_mempool_strdup (task->task_pool, param)); | |||
} | |||
insert_result (task, symbol_name, flag, params); | |||
rspamd_task_insert_result (task, symbol_name, flag, params); | |||
} | |||
return 0; | |||
} | |||
@@ -1738,7 +1738,7 @@ lua_task_learn (lua_State *L) | |||
ret = 2; | |||
} | |||
else { | |||
if (!learn_task_spam (cl, task, is_spam, &err)) { | |||
if (!rspamd_learn_task_spam (cl, task, is_spam, &err)) { | |||
lua_pushboolean (L, FALSE); | |||
if (err != NULL) { | |||
lua_pushstring (L, err->message); | |||
@@ -1811,10 +1811,10 @@ lua_task_get_metric_action (lua_State *L) | |||
if (task && metric_name) { | |||
if ((metric_res = | |||
g_hash_table_lookup (task->results, metric_name)) != NULL) { | |||
action = check_metric_action (task, metric_res->score, | |||
action = rspamd_check_action_metric (task, metric_res->score, | |||
NULL, | |||
metric_res->metric); | |||
lua_pushstring (L, str_action_metric (action)); | |||
lua_pushstring (L, rspamd_action_to_str (action)); | |||
} | |||
else { | |||
lua_pushnil (L); |
@@ -217,7 +217,7 @@ chartable_symbol_callback (struct rspamd_task *task, void *unused) | |||
while (cur) { | |||
part = cur->data; | |||
if (!part->is_empty && check_part (part, task->cfg->raw_mode)) { | |||
insert_result (task, chartable_module_ctx->symbol, 1, NULL); | |||
rspamd_task_insert_result (task, chartable_module_ctx->symbol, 1, NULL); | |||
} | |||
cur = g_list_next (cur); | |||
} |
@@ -308,13 +308,13 @@ dkim_module_check (struct rspamd_task *task, | |||
} | |||
if (res == DKIM_REJECT) { | |||
insert_result (task, dkim_module_ctx->symbol_reject, score_deny, NULL); | |||
rspamd_task_insert_result (task, dkim_module_ctx->symbol_reject, score_deny, NULL); | |||
} | |||
else if (res == DKIM_TRYAGAIN) { | |||
insert_result (task, dkim_module_ctx->symbol_tempfail, 1, NULL); | |||
rspamd_task_insert_result (task, dkim_module_ctx->symbol_tempfail, 1, NULL); | |||
} | |||
else if (res == DKIM_CONTINUE) { | |||
insert_result (task, dkim_module_ctx->symbol_allow, score_allow, NULL); | |||
rspamd_task_insert_result (task, dkim_module_ctx->symbol_allow, score_allow, NULL); | |||
} | |||
} | |||
@@ -339,13 +339,13 @@ dkim_module_key_handler (rspamd_dkim_key_t *key, | |||
/* Insert tempfail symbol */ | |||
msg_info ("cannot get key for domain %s", ctx->dns_key); | |||
if (err != NULL) { | |||
insert_result (task, dkim_module_ctx->symbol_tempfail, 1, | |||
rspamd_task_insert_result (task, dkim_module_ctx->symbol_tempfail, 1, | |||
g_list_prepend (NULL, | |||
rspamd_mempool_strdup (task->task_pool, err->message))); | |||
} | |||
else { | |||
insert_result (task, dkim_module_ctx->symbol_tempfail, 1, NULL); | |||
rspamd_task_insert_result (task, dkim_module_ctx->symbol_tempfail, 1, NULL); | |||
} | |||
} | |||
@@ -610,7 +610,7 @@ fuzzy_io_callback (gint fd, short what, void *arg) | |||
flag, | |||
value, | |||
nval); | |||
insert_result_single (session->task, | |||
rspamd_task_insert_result_single (session->task, | |||
symbol, | |||
nval, | |||
g_list_prepend (NULL, |
@@ -1018,7 +1018,7 @@ process_regexp_item_threaded (gpointer data, gpointer user_data) | |||
if (process_regexp_expression (ud->item->expr, ud->item->symbol, ud->task, | |||
NULL, nL)) { | |||
g_mutex_lock (workers_mtx); | |||
insert_result (ud->task, ud->item->symbol, 1, NULL); | |||
rspamd_task_insert_result (ud->task, ud->item->symbol, 1, NULL); | |||
g_mutex_unlock (workers_mtx); | |||
} | |||
remove_async_thread (ud->task->s); | |||
@@ -1085,14 +1085,14 @@ process_regexp_item (struct rspamd_task *task, void *user_data) | |||
/* Just call function */ | |||
if (rspamd_lua_call_expression_func (item->lua_function, task, NULL, | |||
&res) && res) { | |||
insert_result (task, item->symbol, 1, NULL); | |||
rspamd_task_insert_result (task, item->symbol, 1, NULL); | |||
} | |||
} | |||
else { | |||
/* Process expression */ | |||
if (process_regexp_expression (item->expr, item->symbol, task, NULL, | |||
NULL)) { | |||
insert_result (task, item->symbol, 1, NULL); | |||
rspamd_task_insert_result (task, item->symbol, 1, NULL); | |||
} | |||
} | |||
} |
@@ -243,7 +243,7 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task) | |||
if (res) { | |||
switch (addr->mech) { | |||
case SPF_FAIL: | |||
insert_result (task, | |||
rspamd_task_insert_result (task, | |||
spf_module_ctx->symbol_fail, | |||
1, | |||
g_list_prepend (NULL, addr->spf_string)); | |||
@@ -251,7 +251,7 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task) | |||
break; | |||
case SPF_SOFT_FAIL: | |||
case SPF_NEUTRAL: | |||
insert_result (task, | |||
rspamd_task_insert_result (task, | |||
spf_module_ctx->symbol_softfail, | |||
1, | |||
g_list_prepend (NULL, addr->spf_string)); | |||
@@ -259,7 +259,7 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task) | |||
"(SPF): spf softfail"); | |||
break; | |||
default: | |||
insert_result (task, | |||
rspamd_task_insert_result (task, | |||
spf_module_ctx->symbol_allow, | |||
1, | |||
g_list_prepend (NULL, addr->spf_string)); |
@@ -825,7 +825,7 @@ process_dns_results (struct rspamd_task *task, | |||
(gint)ntohl (bit->bit), | |||
(gint)bit->bit & (gint)ntohl (addr)); | |||
if (((gint)bit->bit & (gint)ntohl (addr)) != 0) { | |||
insert_result (task, bit->symbol, 1, | |||
rspamd_task_insert_result (task, bit->symbol, 1, | |||
g_list_prepend (NULL, | |||
rspamd_mempool_strdup (task->task_pool, url))); | |||
} | |||
@@ -833,7 +833,7 @@ process_dns_results (struct rspamd_task *task, | |||
} | |||
} | |||
else { | |||
insert_result (task, suffix->symbol, 1, | |||
rspamd_task_insert_result (task, suffix->symbol, 1, | |||
g_list_prepend (NULL, | |||
rspamd_mempool_strdup (task->task_pool, url))); | |||
} | |||
@@ -1108,7 +1108,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data) | |||
g_regex_match (re, url->string, 0, NULL))) { | |||
/* If no regexp found or founded regexp matches url string register redirector's call */ | |||
if (surbl_module_ctx->redirector_symbol != NULL) { | |||
insert_result (param->task, | |||
rspamd_task_insert_result (param->task, | |||
surbl_module_ctx->redirector_symbol, | |||
1, | |||
g_list_prepend (NULL, red_domain)); |
@@ -311,7 +311,7 @@ process_smtp_data (struct smtp_session *session) | |||
goto err; | |||
} | |||
if (session->task->cfg->pre_filters == NULL) { | |||
r = process_filters (session->task); | |||
r = rspamd_process_filters (session->task); | |||
if (r == -1) { | |||
msg_err ("cannot process message"); | |||
munmap (session->task->msg->str, st.st_size); |
@@ -322,7 +322,7 @@ start_worker (struct rspamd_worker *worker) | |||
ctx->classify_pool = NULL; | |||
if (ctx->classify_threads > 1) { | |||
nL = rspamd_init_lua_locked (worker->srv->cfg); | |||
ctx->classify_pool = g_thread_pool_new (process_statfiles_threaded, | |||
ctx->classify_pool = g_thread_pool_new (rspamd_process_statistic_threaded, | |||
nL, | |||
ctx->classify_threads, | |||
TRUE, |