commit 798a6cc: [Project] Adopt main routines and plugins

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Jul 12 16:42:28 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-12 15:11:45 +0100
URL: https://github.com/rspamd/rspamd/commit/798a6cc321640f579c37dc400a9bca31cb8ad5e2

[Project] Adopt main routines and plugins

---
 src/controller.c           | 16 ++++++----
 src/libmime/mime_headers.h | 40 +++++++++++++++---------
 src/plugins/chartable.c    |  3 +-
 src/plugins/dkim_check.c   | 29 ++++++++---------
 src/plugins/fuzzy_check.c  | 48 +++++++++++++----------------
 src/plugins/spf.c          |  3 +-
 src/plugins/surbl.c        | 77 ++++++++++++++++++++--------------------------
 7 files changed, 104 insertions(+), 112 deletions(-)

diff --git a/src/controller.c b/src/controller.c
index 46c02d47c..bb8c67e6f 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1870,7 +1870,8 @@ rspamd_controller_learn_fin_task (void *ud)
 	session = conn_ent->ud;
 
 	if (task->err != NULL) {
-		msg_info_session ("cannot learn <%s>: %e", task->message_id, task->err);
+		msg_info_session ("cannot learn <%s>: %e",
+				MESSAGE_FIELD (task, message_id), task->err);
 		rspamd_controller_send_error (conn_ent, task->err->code, "%s",
 				task->err->message);
 
@@ -1882,13 +1883,14 @@ rspamd_controller_learn_fin_task (void *ud)
 		msg_info_task ("<%s> learned message as %s: %s",
 				rspamd_inet_address_to_string (session->from_addr),
 				session->is_spam ? "spam" : "ham",
-						task->message_id);
+				MESSAGE_FIELD (task, message_id));
 		rspamd_controller_send_string (conn_ent, "{\"success\":true}");
 		return TRUE;
 	}
 
 	if (!rspamd_task_process (task, RSPAMD_TASK_PROCESS_LEARN)) {
-		msg_info_task ("cannot learn <%s>: %e", task->message_id, task->err);
+		msg_info_task ("cannot learn <%s>: %e",
+				MESSAGE_FIELD (task, message_id), task->err);
 
 		if (task->err) {
 			rspamd_controller_send_error (conn_ent, task->err->code, "%s",
@@ -1909,7 +1911,7 @@ rspamd_controller_learn_fin_task (void *ud)
 			msg_info_task ("<%s> learned message as %s: %s",
 					rspamd_inet_address_to_string (session->from_addr),
 					session->is_spam ? "spam" : "ham",
-							task->message_id);
+					MESSAGE_FIELD (task, message_id));
 			rspamd_controller_send_string (conn_ent, "{\"success\":true}");
 		}
 
@@ -1948,7 +1950,8 @@ rspamd_controller_check_fin_task (void *ud)
 	conn_ent = task->fin_arg;
 
 	if (task->err) {
-		msg_info_task ("cannot check <%s>: %e", task->message_id, task->err);
+		msg_info_task ("cannot check <%s>: %e",
+				MESSAGE_FIELD (task, message_id), task->err);
 		rspamd_controller_send_error (conn_ent, task->err->code, "%s",
 				task->err->message);
 		return TRUE;
@@ -2027,7 +2030,8 @@ rspamd_controller_handle_learn_common (
 	rspamd_learn_task_spam (task, is_spam, session->classifier, NULL);
 
 	if (!rspamd_task_process (task, RSPAMD_TASK_PROCESS_LEARN)) {
-		msg_warn_session ("<%s> message cannot be processed", task->message_id);
+		msg_warn_session ("<%s> message cannot be processed",
+				MESSAGE_FIELD (task, message_id));
 		goto end;
 	}
 
diff --git a/src/libmime/mime_headers.h b/src/libmime/mime_headers.h
index 9b85e758f..f9aa555c5 100644
--- a/src/libmime/mime_headers.h
+++ b/src/libmime/mime_headers.h
@@ -68,22 +68,34 @@ struct rspamd_mime_header {
 __KHASH_TYPE (rspamd_mime_headers_htb, gchar *, struct rspamd_mime_header *)
 
 enum rspamd_received_type {
-	RSPAMD_RECEIVED_SMTP = 0,
-	RSPAMD_RECEIVED_ESMTP = 1u << 0u,
-	RSPAMD_RECEIVED_ESMTPA = 1u << 1u,
-	RSPAMD_RECEIVED_ESMTPS = 1u << 2u,
-	RSPAMD_RECEIVED_ESMTPSA = 1u << 3u,
-	RSPAMD_RECEIVED_LMTP = 1u << 4u,
-	RSPAMD_RECEIVED_IMAP = 1u << 5u,
-	RSPAMD_RECEIVED_LOCAL = 1u << 6u,
-	RSPAMD_RECEIVED_HTTP = 1u << 7u,
-	RSPAMD_RECEIVED_MAPI = 1u << 8u,
-	RSPAMD_RECEIVED_UNKNOWN = 1u << 9u,
-	RSPAMD_RECEIVED_FLAG_ARTIFICIAL =  (1u << 10u),
-	RSPAMD_RECEIVED_FLAG_SSL =  (1u << 11u),
-	RSPAMD_RECEIVED_FLAG_AUTHENTICATED =  (1u << 12u),
+	RSPAMD_RECEIVED_SMTP = 1u << 0u,
+	RSPAMD_RECEIVED_ESMTP = 1u << 1u,
+	RSPAMD_RECEIVED_ESMTPA = 1u << 2u,
+	RSPAMD_RECEIVED_ESMTPS = 1u << 3u,
+	RSPAMD_RECEIVED_ESMTPSA = 1u << 4u,
+	RSPAMD_RECEIVED_LMTP = 1u << 5u,
+	RSPAMD_RECEIVED_IMAP = 1u << 6u,
+	RSPAMD_RECEIVED_LOCAL = 1u << 7u,
+	RSPAMD_RECEIVED_HTTP = 1u << 8u,
+	RSPAMD_RECEIVED_MAPI = 1u << 9u,
+	RSPAMD_RECEIVED_UNKNOWN = 1u << 10u,
+	RSPAMD_RECEIVED_FLAG_ARTIFICIAL =  (1u << 11u),
+	RSPAMD_RECEIVED_FLAG_SSL =  (1u << 12u),
+	RSPAMD_RECEIVED_FLAG_AUTHENTICATED =  (1u << 13u),
 };
 
+#define RSPAMD_RECEIVED_FLAG_TYPE_MASK (RSPAMD_RECEIVED_SMTP| \
+			RSPAMD_RECEIVED_ESMTP| \
+			RSPAMD_RECEIVED_ESMTPA| \
+			RSPAMD_RECEIVED_ESMTPS| \
+			RSPAMD_RECEIVED_ESMTPSA| \
+			RSPAMD_RECEIVED_LMTP| \
+			RSPAMD_RECEIVED_IMAP| \
+			RSPAMD_RECEIVED_LOCAL| \
+			RSPAMD_RECEIVED_HTTP| \
+			RSPAMD_RECEIVED_MAPI| \
+			RSPAMD_RECEIVED_UNKNOWN)
+
 struct rspamd_received_header {
 	const gchar *from_hostname;
 	const gchar *from_ip;
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index b6e42457a..815afd95a 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -616,8 +616,7 @@ chartable_symbol_callback (struct rspamd_task *task,
 	struct rspamd_mime_text_part *part;
 	struct chartable_ctx *chartable_module_ctx = chartable_get_context (task->cfg);
 
-	for (i = 0; i < task->text_parts->len; i ++) {
-		part = g_ptr_array_index (task->text_parts, i);
+	PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
 		rspamd_chartable_process_part (task, part, chartable_module_ctx);
 	}
 
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 7d3475867..5c30245cf 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -1107,13 +1107,12 @@ dkim_symbol_callback (struct rspamd_task *task,
 		struct rspamd_symcache_item *item,
 		void *unused)
 {
-	GPtrArray *hlist;
 	rspamd_dkim_context_t *ctx;
 	rspamd_dkim_key_t *key;
 	GError *err = NULL;
-	struct rspamd_mime_header *rh;
+	struct rspamd_mime_header *rh, *rh_cur;
 	struct dkim_check_result *res = NULL, *cur;
-	guint checked = 0, i, *dmarc_checks;
+	guint checked = 0, *dmarc_checks;
 	struct dkim_ctx *dkim_module_ctx = dkim_get_context (task->cfg);
 
 	/* Allow dmarc */
@@ -1153,16 +1152,13 @@ dkim_symbol_callback (struct rspamd_task *task,
 	rspamd_symcache_item_async_inc (task, item, M);
 
 	/* Now check if a message has its signature */
-	hlist = rspamd_message_get_header_array (task,
-			RSPAMD_DKIM_SIGNHEADER,
-			FALSE);
-	if (hlist != NULL && hlist->len > 0) {
+	rh = rspamd_message_get_header_array (task, RSPAMD_DKIM_SIGNHEADER);
+	if (rh) {
 		msg_debug_task ("dkim signature found");
 
-		PTR_ARRAY_FOREACH (hlist, i, rh) {
-			if (rh->decoded == NULL || rh->decoded[0] == '\0') {
-				msg_info_task ("<%s> cannot load empty DKIM context",
-						task->message_id);
+		DL_FOREACH (rh, rh_cur) {
+			if (rh_cur->decoded == NULL || rh_cur->decoded[0] == '\0') {
+				msg_info_task ("cannot load empty DKIM signature");
 				continue;
 			}
 
@@ -1174,7 +1170,7 @@ dkim_symbol_callback (struct rspamd_task *task,
 			cur->mult_deny = 1.0;
 			cur->item = item;
 
-			ctx = rspamd_create_dkim_context (rh->decoded,
+			ctx = rspamd_create_dkim_context (rh_cur->decoded,
 					task->task_pool,
 					dkim_module_ctx->time_jitter,
 					RSPAMD_DKIM_NORMAL,
@@ -1191,15 +1187,14 @@ dkim_symbol_callback (struct rspamd_task *task,
 
 			if (ctx == NULL) {
 				if (err != NULL) {
-					msg_info_task ("<%s> cannot parse DKIM context: %e",
-							task->message_id, err);
+					msg_info_task ("cannot parse DKIM signature: %e",
+							err);
 					g_error_free (err);
 					err = NULL;
 				}
 				else {
-					msg_info_task ("<%s> cannot parse DKIM context: "
-							"unknown error",
-							task->message_id);
+					msg_info_task ("<%s> cannot parse DKIM signature: "
+							"unknown error");
 				}
 
 				continue;
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 8d1c63010..91d341507 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -1475,10 +1475,10 @@ fuzzy_cmd_from_text_part (struct rspamd_task *task,
 			rspamd_cryptobox_hash_update (&st, part->utf_stripped_content->data,
 					part->utf_stripped_content->len);
 
-			if (task->subject) {
+			if (MESSAGE_FIELD (task, subject)) {
 				/* We also include subject */
-				rspamd_cryptobox_hash_update (&st, task->subject,
-						strlen (task->subject));
+				rspamd_cryptobox_hash_update (&st, MESSAGE_FIELD (task, subject),
+						strlen (MESSAGE_FIELD (task, subject)));
 			}
 
 			rspamd_cryptobox_hash_final (&st, cmd->digest);
@@ -2127,7 +2127,7 @@ fuzzy_insert_metric_results (struct rspamd_task *task, GPtrArray *results)
 	struct rspamd_mime_text_part *tp;
 
 	/* About 5 words */
-	static const text_length_cutoff = 25;
+	static const unsigned int text_length_cutoff = 25;
 
 	PTR_ARRAY_FOREACH (results, i, res) {
 		if (res->type == FUZZY_RESULT_TXT) {
@@ -2139,7 +2139,7 @@ fuzzy_insert_metric_results (struct rspamd_task *task, GPtrArray *results)
 		}
 	}
 
-	PTR_ARRAY_FOREACH (task->text_parts, i, tp) {
+	PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, tp) {
 		if (!IS_PART_EMPTY (tp)) {
 			seen_text = TRUE;
 		}
@@ -2434,8 +2434,8 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg)
 				return;
 			}
 
-			msg_info_task ("cannot process fuzzy hash for message <%s>: %s",
-					session->task->message_id, strerror (errno));
+			msg_info_task ("cannot process fuzzy hash for message: %s",
+					strerror (errno));
 			if (*(session->err) == NULL) {
 				g_set_error (session->err,
 						g_quark_from_static_string (M),
@@ -2485,7 +2485,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg)
 							(gint)sizeof (rep->digest), rep->digest,
 							symbol,
 							rep->v1.flag,
-							session->task->message_id);
+							MESSAGE_FIELD (session->task, message_id));
 				}
 				else {
 					if (rep->v1.value == 401) {
@@ -2495,7 +2495,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg)
 										"list %s:%d, skipped by server",
 								ftype,
 								op,
-								session->task->message_id,
+								MESSAGE_FIELD (session->task, message_id),
 								(gint)sizeof (rep->digest), rep->digest,
 								symbol,
 								rep->v1.flag);
@@ -2513,7 +2513,7 @@ fuzzy_controller_io_callback (gint fd, short what, void *arg)
 										"list %s:%d, error: %d",
 								ftype,
 								op,
-								session->task->message_id,
+								MESSAGE_FIELD (session->task, message_id),
 								(gint)sizeof (rep->digest), rep->digest,
 								symbol,
 								rep->v1.flag,
@@ -2671,7 +2671,7 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 	GPtrArray *res;
 	gboolean check_part, fuzzy_check;
 
-	res = g_ptr_array_sized_new (task->parts->len + 1);
+	res = g_ptr_array_sized_new (MESSAGE_FIELD (task, parts)->len + 1);
 
 	if (c == FUZZY_STAT) {
 		io = fuzzy_cmd_stat (rule, c, flag, value, task->task_pool);
@@ -2682,7 +2682,7 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule,
 		goto end;
 	}
 
-	PTR_ARRAY_FOREACH (task->parts, i, mime_part) {
+	PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, parts), i, mime_part) {
 		check_part = FALSE;
 		fuzzy_check = FALSE;
 
@@ -2829,8 +2829,8 @@ fuzzy_symbol_callback (struct rspamd_task *task,
 		if (rspamd_match_radix_map_addr (fuzzy_module_ctx->whitelist,
 				task->from_addr) != NULL) {
 			msg_info_task ("<%s>, address %s is whitelisted, skip fuzzy check",
-				task->message_id,
-				rspamd_inet_address_to_string (task->from_addr));
+					MESSAGE_FIELD (task, message_id),
+					rspamd_inet_address_to_string (task->from_addr));
 			rspamd_symcache_finalize_item (task, item);
 
 			return;
@@ -2963,7 +2963,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
 
 		if (r == -1) {
 			msg_warn_task ("<%s>: cannot process message for fuzzy",
-					task->message_id);
+					MESSAGE_FIELD (task, message_id));
 			rspamd_task_free (task);
 			rspamd_controller_send_error (conn_ent, 400,
 					"Message processing error");
@@ -3102,7 +3102,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
 	}
 
 	if (res == -1) {
-		msg_warn_task ("<%s>: cannot send fuzzy request: %s", task->message_id,
+		msg_warn_task ("cannot send fuzzy request: %s",
 				strerror (errno));
 		rspamd_controller_send_error (conn_ent, 400, "Message sending error");
 		rspamd_task_free (task);
@@ -3111,8 +3111,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
 	}
 	else if (!processed) {
 		if (rules) {
-			msg_warn_task ("<%s>: no content to generate fuzzy",
-					task->message_id);
+			msg_warn_task ("no content to generate fuzzy");
 			rspamd_controller_send_error (conn_ent, 404,
 				"No content to generate fuzzy for flag %d", flag);
 		}
@@ -3122,9 +3121,7 @@ fuzzy_process_handler (struct rspamd_http_connection_entry *conn_ent,
 						"Message is conditionally skipped for flag %d", flag);
 			}
 			else {
-				msg_warn_task ("<%s>: no fuzzy rules found for flag %d",
-						task->message_id,
-						flag);
+				msg_warn_task ("no fuzzy rules found for flag %d", flag);
 				rspamd_controller_send_error (conn_ent, 404,
 						"No fuzzy rules matched for flag %d", flag);
 			}
@@ -3342,20 +3339,17 @@ fuzzy_check_lua_process_learn (struct rspamd_task *task,
 	}
 
 	if (res == -1) {
-		msg_warn_task ("<%s>: cannot send fuzzy request: %s", task->message_id,
+		msg_warn_task ("cannot send fuzzy request: %s",
 				strerror (errno));
 	}
 	else if (!processed) {
 		if (rules) {
-			msg_warn_task ("<%s>: no content to generate fuzzy",
-					task->message_id);
+			msg_warn_task ("no content to generate fuzzy");
 
 			return FALSE;
 		}
 		else {
-			msg_warn_task ("<%s>: no fuzzy rules found for flag %d",
-					task->message_id,
-				flag);
+			msg_warn_task ("no fuzzy rules found for flag %d", flag);
 			return FALSE;
 		}
 	}
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 89adefbe7..9c54bb696 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -665,8 +665,7 @@ spf_symbol_callback (struct rspamd_task *task,
 		else {
 
 			if (!rspamd_spf_resolve (task, spf_plugin_callback, item)) {
-				msg_info_task ("cannot make spf request for [%s]",
-						task->message_id);
+				msg_info_task ("cannot make spf request for %s", domain);
 				rspamd_task_insert_result (task,
 						spf_module_ctx->symbol_dnsfail,
 						1,
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index baf985c39..860f4b5e5 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -1579,8 +1579,7 @@ process_dns_results (struct rspamd_task *task,
 
 		bit = g_hash_table_lookup (suffix->ips, &addr);
 		if (bit != NULL) {
-			msg_info_surbl ("<%s> domain [%s] is in surbl %s(%xd)",
-					task->message_id,
+			msg_info_surbl ("domain [%s] is in surbl %s(%xd)",
 					resolved_name, suffix->suffix,
 					bit->bit);
 			rspamd_task_insert_result (task, bit->symbol, 1, resolved_name);
@@ -1602,8 +1601,7 @@ process_dns_results (struct rspamd_task *task,
 
 			if (((gint)bit->bit & (gint)ntohl (addr)) != 0) {
 				got_result = TRUE;
-				msg_info_surbl ("<%s> domain [%s] is in surbl %s(%xd)",
-						task->message_id,
+				msg_info_surbl ("domain [%s] is in surbl %s(%xd)",
 						resolved_name, suffix->suffix,
 						bit->bit);
 				rspamd_task_insert_result (task, bit->symbol, 1, resolved_name);
@@ -1617,8 +1615,7 @@ process_dns_results (struct rspamd_task *task,
 	if (!got_result) {
 		if ((suffix->bits == NULL || suffix->bits->len == 0) &&
 				suffix->ips == NULL) {
-			msg_info_surbl ("<%s> domain [%s] is in surbl %s",
-					task->message_id,
+			msg_info_surbl ("domain [%s] is in surbl %s",
 					resolved_name, suffix->suffix);
 			rspamd_task_insert_result (task, suffix->symbol, 1, resolved_name);
 
@@ -1628,8 +1625,7 @@ process_dns_results (struct rspamd_task *task,
 		}
 		else {
 			ina.s_addr = addr;
-			msg_info_surbl ("<%s> domain [%s] is in surbl %s but at unknown result: %s",
-					task->message_id,
+			msg_info_surbl ("domain [%s] is in surbl %s but at unknown result: %s",
 					resolved_name, suffix->suffix,
 					inet_ntoa (ina));
 		}
@@ -1645,8 +1641,7 @@ surbl_dns_callback (struct rdns_reply *reply, gpointer arg)
 
 	task = param->task;
 	if (reply->code == RDNS_RC_NOERROR && reply->entries) {
-		msg_debug_surbl ("<%s> domain [%s] is in surbl %s",
-				param->task->message_id,
+		msg_debug_surbl ("domain [%s] is in surbl %s",
 				param->host_orig, param->suffix->suffix);
 
 		DL_FOREACH (reply->entries, elt) {
@@ -1659,8 +1654,8 @@ surbl_dns_callback (struct rdns_reply *reply, gpointer arg)
 	}
 	else {
 		if (reply->code == RDNS_RC_NXDOMAIN || reply->code == RDNS_RC_NOREC) {
-			msg_debug_surbl ("<%s> domain [%s] is not in surbl %s",
-					param->task->message_id, param->host_orig,
+			msg_debug_surbl ("domain [%s] is not in surbl %s",
+					param->host_orig,
 					param->suffix->suffix);
 		}
 		else {
@@ -1705,8 +1700,7 @@ surbl_dns_ip_callback (struct rdns_reply *reply, gpointer arg)
 						ip_addr >> 8 & 0xff,
 						ip_addr & 0xff, param->suffix->suffix);
 				msg_debug_surbl (
-						"<%s> domain [%s] send %v request to surbl",
-						param->task->message_id,
+						"domain [%s] send %v request to surbl",
 						param->host_orig,
 						to_resolve);
 
@@ -1721,8 +1715,8 @@ surbl_dns_ip_callback (struct rdns_reply *reply, gpointer arg)
 		}
 	}
 	else {
-		msg_debug_surbl ("<%s> domain [%s] cannot be resolved for SURBL check %s",
-				param->task->message_id, param->host_resolve,
+		msg_debug_surbl ("domain [%s] cannot be resolved for SURBL check %s",
+				param->host_resolve,
 				param->suffix->suffix);
 
 	}
@@ -1778,8 +1772,7 @@ surbl_redirector_finish (struct rspamd_http_connection *conn,
 		hdr = rspamd_http_message_find_header (msg, "Uri");
 
 		if (hdr != NULL) {
-			msg_info_surbl ("<%s> got reply from redirector: '%*s' -> '%T'",
-					param->task->message_id,
+			msg_info_surbl ("got reply from redirector: '%*s' -> '%T'",
 					param->url->urllen, param->url->string,
 					hdr);
 			urllen = hdr->len;
@@ -1792,8 +1785,9 @@ surbl_redirector_finish (struct rspamd_http_connection *conn,
 					task->task_pool, RSPAMD_URL_PARSE_TEXT);
 
 			if (r == URI_ERRNO_OK) {
-				if ((existing = g_hash_table_lookup (task->urls, redirected_url)) == NULL) {
-					g_hash_table_insert (task->urls, redirected_url,
+				if ((existing = g_hash_table_lookup (MESSAGE_FIELD (task, urls),
+						redirected_url)) == NULL) {
+					g_hash_table_insert (MESSAGE_FIELD (task, urls), redirected_url,
 							redirected_url);
 					redirected_url->phished_url = param->url;
 					redirected_url->flags |= RSPAMD_URL_FLAG_REDIRECTED;
@@ -1813,8 +1807,7 @@ surbl_redirector_finish (struct rspamd_http_connection *conn,
 		}
 	}
 	else {
-		msg_info_surbl ("<%s> could not resolve '%*s' on redirector",
-				param->task->message_id,
+		msg_info_surbl ("could not resolve '%*s' on redirector",
 				param->url->urllen, param->url->string);
 	}
 
@@ -1852,8 +1845,7 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task,
 		}
 
 		if (param->conn == NULL) {
-			msg_info_surbl ("<%s> cannot create tcp socket failed: %s",
-					task->message_id,
+			msg_info_surbl ("cannot create tcp socket failed: %s",
 					strerror (errno));
 
 			return;
@@ -1880,8 +1872,7 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task,
 				NULL, param, surbl_module_ctx->read_timeout);
 
 		msg_info_surbl (
-				"<%s> registered redirector call for %*s to %s, according to rule: %s",
-				task->message_id,
+				"registered redirector call for %*s to %s, according to rule: %s",
 				url->urllen, url->string,
 				rspamd_upstream_name (param->redirector),
 				rule);
@@ -1909,8 +1900,7 @@ surbl_test_tags (struct rspamd_task *task, struct redirector_param *param,
 		/* We know results for this URL */
 
 		DL_FOREACH (tag, cur) {
-			msg_info_surbl ("<%s> domain [%s] is in surbl %s (tags)",
-					task->message_id,
+			msg_info_surbl ("domain [%s] is in surbl %s (tags)",
 					ftld, cur->data);
 			rspamd_task_insert_result (task, cur->data, 1, ftld);
 		}
@@ -2084,19 +2074,19 @@ surbl_test_url (struct rspamd_task *task,
 	rspamd_mempool_add_destructor (task->task_pool,
 		(rspamd_mempool_destruct_t)g_hash_table_unref,
 		param->tree);
-	g_hash_table_foreach (task->urls, surbl_tree_url_callback, param);
+	g_hash_table_foreach (MESSAGE_FIELD (task, urls),
+			surbl_tree_url_callback, param);
 
 	rspamd_symcache_item_async_inc (task, item, M);
 
 	if (suffix->options & SURBL_OPTION_CHECKEMAILS) {
-		g_hash_table_foreach (task->emails, surbl_tree_url_callback, param);
+		g_hash_table_foreach (MESSAGE_FIELD (task, emails),
+				surbl_tree_url_callback, param);
 	}
 
 	/* We also need to check and process img URLs */
 	if (suffix->options & SURBL_OPTION_CHECKIMAGES) {
-		for (i = 0; i < task->text_parts->len; i ++) {
-			part = g_ptr_array_index (task->text_parts, i);
-
+		PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
 			if (part->html && part->html->images) {
 				for (j = 0; j < part->html->images->len; j ++) {
 					img = g_ptr_array_index (part->html->images, j);
@@ -2166,11 +2156,11 @@ surbl_test_redirector (struct rspamd_task *task,
 	param->redirector_requests = 0;
 	param->ctx = surbl_module_ctx;
 	param->item = item;
-	g_hash_table_foreach (task->urls, surbl_tree_redirector_callback, param);
+	g_hash_table_foreach (MESSAGE_FIELD (task, urls),
+			surbl_tree_redirector_callback, param);
 
 	/* We also need to check and process img URLs */
-	for (i = 0; i < task->text_parts->len; i ++) {
-		part = g_ptr_array_index (task->text_parts, i);
+	PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, part) {
 		if (part->html && part->html->images) {
 			for (j = 0; j < part->html->images->len; j ++) {
 				img = g_ptr_array_index (part->html->images, j);
@@ -2314,8 +2304,7 @@ surbl_continue_process_handler (lua_State *L)
 		surbl_module_ctx = surbl_get_context (task->cfg);
 
 		if (nurl != NULL) {
-			msg_info_surbl ("<%s> got reply from redirector: '%*s' -> '%*s'",
-					param->task->message_id,
+			msg_info_surbl ("got reply from redirector: '%*s' -> '%*s'",
 					param->url->urllen, param->url->string,
 					(gint)urllen, nurl);
 			urlstr = rspamd_mempool_alloc (task->task_pool,
@@ -2327,8 +2316,10 @@ surbl_continue_process_handler (lua_State *L)
 					task->task_pool, RSPAMD_URL_PARSE_TEXT);
 
 			if (r == URI_ERRNO_OK) {
-				if (!g_hash_table_lookup (task->urls, redirected_url)) {
-					g_hash_table_insert (task->urls, redirected_url,
+				if (!g_hash_table_lookup (MESSAGE_FIELD (task, urls),
+						redirected_url)) {
+					g_hash_table_insert (MESSAGE_FIELD (task, urls),
+							redirected_url,
 							redirected_url);
 					redirected_url->phished_url = param->url;
 					redirected_url->flags |= RSPAMD_URL_FLAG_REDIRECTED;
@@ -2340,14 +2331,12 @@ surbl_continue_process_handler (lua_State *L)
 				}
 			}
 			else {
-				msg_info_surbl ("<%s> could not resolve '%*s' on redirector",
-						param->task->message_id,
+				msg_info_surbl ("could not resolve '%*s' on redirector",
 						param->url->urllen, param->url->string);
 			}
 		}
 		else {
-			msg_info_surbl ("<%s> could not resolve '%*s' on redirector",
-					param->task->message_id,
+			msg_info_surbl ("could not resolve '%*s' on redirector",
 					param->url->urllen, param->url->string);
 		}
 	}


More information about the Commits mailing list