GList *urls; /**< list of parsed urls */
GHashTable *results; /**< hash table of metric_result indexed by
* metric's name */
+ GList *messages; /**< list of messages that would be reported */
GHashTable *re_cache; /**< cache for matched or not matched regexps */
struct config_file *cfg; /**< pointer to config object */
struct save_point save; /**< save point for delayed processing */
{
char *arg, out_buf[BUFSIZ], *err_str;
uint32_t size;
- int r, value, *sargs;
+ int r, value = 1, *sargs;
/* Process size */
arg = args[0];
}
/* Process value */
arg = args[1];
- if (!arg || *arg == '\0') {
- msg_info ("empty value, assume it 1");
- value = 1;
- }
- else {
+ if (arg && *arg != '\0') {
value = strtol (arg, &err_str, 10);
}
switch (addr->mech) {
case SPF_FAIL:
insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_fail, 1, g_list_prepend (NULL, addr->spf_string));
+ task->messages = g_list_prepend (task->messages, "(SPF): spf fail");
break;
case SPF_SOFT_FAIL:
case SPF_NEUTRAL:
insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_softfail, 1, g_list_prepend (NULL, addr->spf_string));
+ task->messages = g_list_prepend (task->messages, "(SPF): spf softfail");
break;
default:
insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_allow, 1, g_list_prepend (NULL, addr->spf_string));
+ task->messages = g_list_prepend (task->messages, "(SPF): spf allow");
break;
}
/* Stop parsing */
}
}
+
static void
show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data)
{
(long int)task->msg->len, calculate_check_time (&task->ts, task->cfg->clock_res));
}
+static void
+show_messages (struct worker_task *task)
+{
+ int r = 0;
+ char outbuf[OUTBUFSIZ];
+ GList *cur;
+
+ cur = task->messages;
+ while (cur) {
+ r += snprintf (outbuf + r, sizeof (outbuf) - r, "Message: %s" CRLF, (char *)cur->data);
+ cur = g_list_next (cur);
+ }
+
+ rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE);
+}
+
static int
write_check_reply (struct worker_task *task)
{
/* Write result for each metric separately */
g_hash_table_foreach (task->results, show_metric_result, &cd);
+ /* Messages */
+ show_messages (task);
/* URL stat */
show_url_header (task);
}
/* Write result for each metric separately */
g_hash_table_foreach (task->results, show_metric_result, &cd);
- /* URL stat */
+ /* Messages */
+ show_messages (task);
}
write_hashes_to_log (task, logbuf, cd.log_offset, cd.log_size);
msg_info ("%s", logbuf);
begin += sizeof (SPF_INCLUDE) - 1;
res = parse_spf_include (task, begin, rec, new);
}
+ else if (strncmp (begin, SPF_IP6, sizeof (SPF_IP4) - 1) == 0) {
+ begin += sizeof (SPF_IP6) - 1;
+ msg_info ("ignoring ip6 spf command as IPv6 is not supported: %s", begin);
+ new = NULL;
+ res = TRUE;
+ }
else {
msg_info ("bad spf command: %s", begin);
}
if (task->urls) {
g_list_free (task->urls);
}
+ if (task->messages) {
+ g_list_free (task->messages);
+ }
memory_pool_delete (task->task_pool);
if (task->dispatcher) {
if (is_soft) {