summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-31 10:46:16 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-31 10:46:16 +0100
commitaf7322a2a685a9f6058629bde3859944ef4ce1a2 (patch)
tree1bfc08462ff4074dd170438dffea99cc26d15405
parentaa7679b9dfc18ba4c5f41d2b4c781d79cc48d4d5 (diff)
downloadrspamd-af7322a2a685a9f6058629bde3859944ef4ce1a2.tar.gz
rspamd-af7322a2a685a9f6058629bde3859944ef4ce1a2.zip
[Feature] Support MTA name header
-rw-r--r--src/libmime/message.c4
-rw-r--r--src/libserver/mempool_vars_internal.h1
-rw-r--r--src/libserver/protocol.c8
-rw-r--r--src/libserver/protocol_internal.h2
4 files changed, 13 insertions, 2 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 0cf18e0a4..647cacdf0 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -828,7 +828,7 @@ rspamd_message_parse (struct rspamd_task *task)
if (need_recv_correction && !(task->flags & RSPAMD_TASK_FLAG_NO_IP)
&& task->from_addr) {
msg_debug_task ("the first received seems to be"
- " not ours, replace it with fake one");
+ " not ours, prepend it with fake one");
trecv = rspamd_mempool_alloc0 (task->task_pool,
sizeof (struct received_header));
@@ -836,6 +836,8 @@ rspamd_message_parse (struct rspamd_task *task)
trecv->real_ip = rspamd_mempool_strdup (task->task_pool,
rspamd_inet_address_to_string (task->from_addr));
trecv->from_ip = trecv->real_ip;
+ trecv->by_hostname = rspamd_mempool_get_variable (task->task_pool,
+ RSPAMD_MEMPOOL_MTA_NAME);
trecv->addr = rspamd_inet_address_copy (task->from_addr);
rspamd_mempool_add_destructor (task->task_pool,
(rspamd_mempool_destruct_t)rspamd_inet_address_free,
diff --git a/src/libserver/mempool_vars_internal.h b/src/libserver/mempool_vars_internal.h
index 2e305b969..f566b78af 100644
--- a/src/libserver/mempool_vars_internal.h
+++ b/src/libserver/mempool_vars_internal.h
@@ -23,6 +23,7 @@
#define RSPAMD_MEMPOOL_HEADERS_HASH "headers_hash"
#define RSPAMD_MEMPOOL_SETTINGS_HASH "settings_hash"
#define RSPAMD_MEMPOOL_MTA_TAG "MTA-Tag"
+#define RSPAMD_MEMPOOL_MTA_NAME "MTA-Name"
#define RSPAMD_MEMPOOL_CACHED_REPLY "cached_reply"
#define RSPAMD_MEMPOOL_SPF_DOMAIN "spf_domain"
#define RSPAMD_MEMPOOL_PRINCIPAL_RECIPIENT "principal_recipient"
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 1602ab76f..3bb829cab 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -431,6 +431,14 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
mta_tag, NULL);
debug_task ("read MTA-Tag header, value: %s", mta_tag);
}
+ IF_HEADER (MTA_NAME_HEADER) {
+ gchar *mta_name;
+ mta_name = rspamd_mempool_ftokdup (task->task_pool, hv_tok);
+ rspamd_mempool_set_variable (task->task_pool,
+ RSPAMD_MEMPOOL_MTA_NAME,
+ mta_name, NULL);
+ debug_task ("read MTA-Name header, value: %s", mta_name);
+ }
break;
default:
debug_task ("unknown header: %V", hn);
diff --git a/src/libserver/protocol_internal.h b/src/libserver/protocol_internal.h
index 7be821462..f1897a945 100644
--- a/src/libserver/protocol_internal.h
+++ b/src/libserver/protocol_internal.h
@@ -77,6 +77,6 @@
#define PROFILE_HEADER "Profile"
#define TLS_CIPHER_HEADER "TLS-Cipher"
#define TLS_VERSION_HEADER "TLS-Version"
-
+#define MTA_NAME_HEADER "MTA-Name"
#endif //RSPAMD_PROTOCOL_INTERNAL_H