]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Support MTA name header
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 31 May 2017 09:46:16 +0000 (10:46 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 31 May 2017 09:46:16 +0000 (10:46 +0100)
src/libmime/message.c
src/libserver/mempool_vars_internal.h
src/libserver/protocol.c
src/libserver/protocol_internal.h

index 0cf18e0a48debf577ef35a1cac5792974c4aa218..647cacdf02565cc9a10a7ce8b35edce5f5143e31 100644 (file)
@@ -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,
index 2e305b96933706bc87beceaf32dd04efeda0db0b..f566b78af475a9efa522c121fe3b41e0a9fd98b5 100644 (file)
@@ -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"
index 1602ab76fcc9a76c2d5ac0815cf4801a7d2a380a..3bb829cab731039c2077681a67abf1508d2f0313 100644 (file)
@@ -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);
index 7be8214620c2630c51e4fd81ac372cecbc879dac..f1897a94561978c6c363f1a46133da5f62020329 100644 (file)
@@ -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