From 4d4668a0d4022583208d20bac9b8a0bede6f073d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 20 Apr 2012 20:02:28 +0400 Subject: * Fix spf plugin that was broken in 0.4.7 * Add partial ipv6 support for some rspamd modules. --- src/protocol.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/protocol.c') diff --git a/src/protocol.c b/src/protocol.c index 40bd01e0c..fc03acacb 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -537,10 +537,27 @@ parse_header (struct worker_task *task, f_str_t * line) /* ip_addr */ if (g_ascii_strncasecmp (headern, IP_ADDR_HEADER, sizeof (IP_ADDR_HEADER) - 1) == 0) { tmp = memory_pool_fstrdup (task->task_pool, line); +#ifdef HAVE_INET_PTON + if (inet_pton (AF_INET, tmp, &task->from_addr.d.in4) != 1) { + /* Try ipv6 */ + if (inet_pton (AF_INET6, tmp, &task->from_addr.d.in6) == 1) { + task->from_addr.ipv6 = TRUE; + } + else { + msg_info ("bad ip header: '%s'", tmp); + return FALSE; + } + } + else { + task->from_addr.ipv6 = FALSE; + } + task->from_addr.has_addr = TRUE; +#else if (!inet_aton (tmp, &task->from_addr)) { msg_info ("bad ip header: '%s'", tmp); return FALSE; } +#endif debug_task ("read IP header, value: %s", tmp); } else { -- cgit v1.2.3