From: Vsevolod Stakhov Date: Sat, 28 Mar 2015 10:57:59 +0000 (+0000) Subject: Parse IP from the first received header if not specified by protocol. X-Git-Tag: 0.9.0~401 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1212a7448201dadc199419c237e94a3828c8a0b9;p=rspamd.git Parse IP from the first received header if not specified by protocol. --- diff --git a/src/libmime/message.c b/src/libmime/message.c index 15a59978d..f8ae25554 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1600,6 +1600,20 @@ process_message (struct rspamd_task *task) /* Restore normal order */ task->received = g_list_reverse (task->received); + /* Extract data from received header if we were not given IP */ + if (task->received && (task->flags & RSPAMD_TASK_FLAG_NO_IP)) { + recv = task->received->data; + if (recv->real_ip) { + if (!rspamd_parse_inet_address (&task->from_addr, recv->real_ip)) { + msg_warn ("cannot get IP from received header: '%s'", + recv->real_ip); + } + } + if (recv->real_hostname) { + task->hostname = recv->real_hostname; + } + } + /* free the parser (and the stream) */ g_object_unref (parser); }