]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Finish conversion to new inet addr structure.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 14:29:05 +0000 (15:29 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 21 Apr 2014 14:29:05 +0000 (15:29 +0100)
12 files changed:
src/buffer.c
src/controller.c
src/logger.c
src/logger.h
src/lua/lua_common.c
src/lua_worker.c
src/plugins/fuzzy_check.c
src/plugins/spf.c
src/protocol.c
src/smtp_proxy.c
src/webui.c
src/worker.c

index 95104d2a526e8be9b0c04f1774e984544fea6330..864f2fad605c2eccb7abda5c374b4f806d4ea41a 100644 (file)
@@ -30,7 +30,7 @@
 #endif
 
 #define G_DISPATCHER_ERROR dispatcher_error_quark()
-#define debug_ip(...) rspamd_conditional_debug(rspamd_main->logger, d->peer_addr, __FUNCTION__, __VA_ARGS__)
+#define debug_ip(...) rspamd_conditional_debug(rspamd_main->logger, NULL, __FUNCTION__, __VA_ARGS__)
 
 static void                     dispatcher_cb (gint fd, short what, void *arg);
 
index 3b48bf5cd8135841b31e1690fbc4d0f9773a1940..f8b49d236ad2f91522fce589c938d45ffd519042 100644 (file)
@@ -1488,7 +1488,6 @@ controller_read_socket (f_str_t * in, void *arg)
                }
                /* Set up async session */
                task->s = new_async_session (task->task_pool, fin_learn_task, restore_learn_task, free_task_hard, task);
-               task->dispatcher = session->dispatcher;
                session->learn_task = task;
                session->state = STATE_LEARN_SPAM;
                rspamd_dispatcher_pause (session->dispatcher);
@@ -1692,7 +1691,6 @@ controller_write_socket (void *arg)
                                }
                        }
                }
-               session->learn_task->dispatcher = NULL;
                destroy_session (session->learn_task->s);
                session->state = STATE_REPLY;
                if (! rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
@@ -1738,13 +1736,13 @@ accept_socket (gint fd, short what, void *arg)
        union sa_union                  su;
        struct controller_session      *new_session;
        struct timeval                 *io_tv;
-       socklen_t                       addrlen = sizeof (su.ss);
        gint                            nfd;
        struct rspamd_controller_ctx   *ctx;
+       rspamd_inet_addr_t addr;
 
        ctx = worker->ctx;
 
-       if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
+       if ((nfd = rspamd_accept_from_socket (fd, &addr)) == -1) {
                return;
        }
 
index 285e8decb18ec7c5ddf38a5034443bc3d89461ef..01814d24dd55eb8cc1b02b77d7189219e4b8eea8 100644 (file)
@@ -711,15 +711,20 @@ file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFla
  * Write log line depending on ip
  */
 void
-rspamd_conditional_debug (rspamd_logger_t *rspamd_log, guint32 addr, const gchar *function, const gchar *fmt, ...)
+rspamd_conditional_debug (rspamd_logger_t *rspamd_log,
+               rspamd_inet_addr_t *addr, const gchar *function, const gchar *fmt, ...)
 {
        static gchar                     logbuf[BUFSIZ];
        va_list                         vp;
     u_char                         *end;
 
-       if (rspamd_log->cfg->log_level >= G_LOG_LEVEL_DEBUG || rspamd_log->is_debug ||
-                       (rspamd_log->debug_ip != NULL && radix32tree_find (rspamd_log->debug_ip, ntohl (addr)) != RADIX_NO_VALUE)) {
-
+       if (rspamd_log->cfg->log_level >= G_LOG_LEVEL_DEBUG || rspamd_log->is_debug) {
+               if (rspamd_log->debug_ip && addr != NULL) {
+                       if (addr->af == AF_INET && radix32tree_find (rspamd_log->debug_ip,
+                                       ntohl (addr->addr.s4.sin_addr.s_addr)) == RADIX_NO_VALUE) {
+                               return;
+                       }
+               }
                g_mutex_lock (rspamd_log->mtx);
                va_start (vp, fmt);
                end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp);
index 6f46080def0c0fb3754a2deeb92bb60c59d2cd27..b0766b938fc3f9bfee7f8985bc386829ba63a457 100644 (file)
@@ -70,7 +70,7 @@ void rspamd_common_logv (rspamd_logger_t *logger,
  * Conditional debug function
  */
 void rspamd_conditional_debug (rspamd_logger_t *logger,
-               guint32 addr, const gchar *function, const gchar *fmt, ...) ;
+               rspamd_inet_addr_t *addr, const gchar *function, const gchar *fmt, ...) ;
 
 /**
  * Function with variable number of arguments support that uses static default logger
@@ -104,12 +104,8 @@ void rspamd_log_nodebug (rspamd_logger_t *logger);
 #define msg_err(...)   rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_CRITICAL, __FUNCTION__, __VA_ARGS__)
 #define msg_warn(...)  rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_WARNING, __FUNCTION__, __VA_ARGS__)
 #define msg_info(...)  rspamd_common_log_function(rspamd_main->logger, G_LOG_LEVEL_INFO, __FUNCTION__, __VA_ARGS__)
-#define msg_debug(...) rspamd_conditional_debug(rspamd_main->logger, -1, __FUNCTION__, __VA_ARGS__)
-#ifdef HAVE_INET_PTON
-# define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, task->from_addr.d.in4.s_addr, __FUNCTION__, __VA_ARGS__)
-#else
-# define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, task->from_addr.s_addr, __FUNCTION__, __VA_ARGS__)
-#endif
+#define msg_debug(...) rspamd_conditional_debug(rspamd_main->logger, NULL, __FUNCTION__, __VA_ARGS__)
+#define debug_task(...) rspamd_conditional_debug(rspamd_main->logger, &task->from_addr, __FUNCTION__, __VA_ARGS__)
 #else
 #define msg_err(...)   rspamd_default_log_function(G_LOG_LEVEL_CRITICAL, __FUNCTION__, __VA_ARGS__)
 #define msg_warn(...)  rspamd_default_log_function(G_LOG_LEVEL_WARNING, __FUNCTION__, __VA_ARGS__)
index ee624db3d2d0ef6273fd8f23240a7ab4826724c8..f7912a722286385edff93d1fa6d808ade1a09d31 100644 (file)
@@ -170,7 +170,7 @@ lua_common_log (GLogLevelFlags level, lua_State *L, const gchar *msg)
                }
                rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p, d.currentline);
                if (level == G_LOG_LEVEL_DEBUG) {
-                       rspamd_conditional_debug (rspamd_main->logger, -1, func_buf, "%s", msg);
+                       rspamd_conditional_debug (rspamd_main->logger, NULL, func_buf, "%s", msg);
                }
                else {
                        rspamd_common_log_function (rspamd_main->logger, level, func_buf, "%s", msg);
@@ -178,7 +178,7 @@ lua_common_log (GLogLevelFlags level, lua_State *L, const gchar *msg)
        }
        else {
                if (level == G_LOG_LEVEL_DEBUG) {
-                       rspamd_conditional_debug (rspamd_main->logger, -1, __FUNCTION__, "%s", msg);
+                       rspamd_conditional_debug (rspamd_main->logger, NULL, __FUNCTION__, "%s", msg);
                }
                else {
                        rspamd_common_log_function (rspamd_main->logger, level, __FUNCTION__, "%s", msg);
index 319242a3abef6d11032921b51fb32eb2f28c9aec..c6482bcfd6366ed6bb47d8295e9617fb1cb45b88 100644 (file)
@@ -325,52 +325,26 @@ lua_accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *) arg;
        struct rspamd_lua_worker_ctx   *ctx, **pctx;
-       union sa_union                  su;
-       socklen_t                       addrlen = sizeof (su.ss);
        gint                            nfd;
-       struct in_addr                              addr;
-       gchar                                              *addr_str = NULL;
        lua_State                                          *L;
+       rspamd_inet_addr_t              addr;
 
        ctx = worker->ctx;
        L = ctx->L;
 
        if ((nfd =
-                       accept_from_socket (fd, (struct sockaddr *) &su.ss, &addrlen)) == -1) {
+                       rspamd_accept_from_socket (fd, &addr)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
                return;
        }
        /* Check for EAGAIN */
-       if (nfd == 0){
+       if (nfd == 0) {
                return;
        }
 
-       if (su.ss.ss_family == AF_UNIX) {
-               msg_info ("accepted connection from unix socket");
-               addr.s_addr = INADDR_NONE;
-               addr_str = "127.0.0.1";
-       }
-       else if (su.ss.ss_family == AF_INET) {
-               msg_info ("accepted connection from %s port %d",
-                               inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
-               memcpy (&addr, &su.s4.sin_addr,
-                               sizeof (struct in_addr));
-               addr_str = g_strdup (inet_ntoa (su.s4.sin_addr));
-       }
-       else if (su.ss.ss_family == AF_INET6) {
-               addr_str = g_malloc0 (INET6_ADDRSTRLEN + 1);
-               /* XXX: support ipv6 addresses here */
-               addr.s_addr = INADDR_NONE;
-               inet_ntop (AF_INET6, &su.s6.sin6_addr, addr_str, INET6_ADDRSTRLEN);
-               msg_info ("accepted connection from [%s] port %d",
-                                               addr_str, ntohs (su.s6.sin6_port));
-       }
-       else {
-               addr.s_addr = INADDR_NONE;
-               msg_err ("accepted connection from unsupported address family: %d", su.ss.ss_family);
-               close (nfd);
-               return;
-       }
+       msg_info ("accepted connection from %s port %d",
+                               rspamd_inet_address_to_string (&addr),
+                               rspamd_inet_address_get_port (&addr));
 
        /* Call finalizer function */
        lua_rawgeti (L, LUA_REGISTRYINDEX, ctx->cbref_accept);
@@ -378,17 +352,13 @@ lua_accept_socket (gint fd, short what, void *arg)
        lua_setclass (L, "rspamd{worker}", -1);
        *pctx = ctx;
        lua_pushinteger (L, nfd);
-       lua_pushstring (L, addr_str);
-       lua_pushinteger (L, addr.s_addr);
+       lua_pushstring (L, rspamd_inet_address_to_string (&addr));
+       lua_pushinteger (L, 0);
 
 
        if (lua_pcall (L, 4, 0, 0) != 0) {
                msg_info ("call to worker accept failed: %s", lua_tostring (L, -1));
        }
-
-       if (addr_str) {
-               g_free (addr_str);
-       }
 }
 
 static gboolean
index 195ee19da70c5f07ee4875e6cbcb52290648d2eb..a6c1ed0f29fe0226d817faeaa05afa6fcdbe120f 100644 (file)
@@ -821,24 +821,14 @@ fuzzy_symbol_callback (struct rspamd_task *task, void *unused)
        GList *cur;
 
        /* Check whitelist */
-#ifdef HAVE_INET_PTON
        if (fuzzy_module_ctx->whitelist && task->from_addr.af == AF_INET) {
                if (radix32tree_find (fuzzy_module_ctx->whitelist,
                                ntohl (task->from_addr.addr.s4.sin_addr.s_addr)) != RADIX_NO_VALUE) {
                        msg_info ("<%s>, address %s is whitelisted, skip fuzzy check",
-                                       task->message_id, inet_ntoa (task->from_addr.d.in4));
+                                       task->message_id, rspamd_inet_address_to_string (&task->from_addr));
                        return;
                }
        }
-#else
-       if (fuzzy_module_ctx->whitelist && task->from_addr.s_addr != 0) {
-               if (radix32tree_find (fuzzy_module_ctx->whitelist, ntohl ((guint32) task->from_addr.s_addr)) != RADIX_NO_VALUE) {
-                       msg_info ("<%s>, address %s is whitelisted, skip fuzzy check",
-                                       task->message_id, inet_ntoa (task->from_addr));
-                       return;
-               }
-       }
-#endif
 
        cur = fuzzy_module_ctx->fuzzy_rules;
        while (cur) {
index 94245ea7e3405435b227ea3b4e0cb7d89278d9e6..19aaa44e55d9c93aff6472cce6711086ca2677c3 100644 (file)
@@ -161,25 +161,24 @@ static gboolean
 spf_check_element (struct spf_addr *addr, struct rspamd_task *task)
 {
        gboolean                        res = FALSE;
-#ifdef HAVE_INET_PTON
        guint8                         *s, *d, t;
        guint                           nbits, addrlen;
        struct in_addr                                  in4s, in4d;
        struct in6_addr                 in6s, in6d;
 
        /* Basic comparing algorithm */
-       if (addr->data.normal.ipv6 == task->from_addr.ipv6) {
+       if (addr->data.normal.ipv6 && task->from_addr.af == AF_INET6) {
                if (addr->data.normal.ipv6) {
                        addrlen = sizeof (struct in6_addr);
                        memcpy (&in6s, &addr->data.normal.d.in6, sizeof (struct in6_addr));
-                       memcpy (&in6d, &task->from_addr.d.in6, sizeof (struct in6_addr));
+                       memcpy (&in6d, &task->from_addr.addr.s6.sin6_addr, sizeof (struct in6_addr));
                        s = (guint8 *)&in6s;
                        d = (guint8 *)&in6d;
                }
                else {
                        addrlen = sizeof (struct in_addr);
                        memcpy (&in4s, &addr->data.normal.d.in4, sizeof (struct in_addr));
-                       memcpy (&in4d, &task->from_addr.d.in4, sizeof (struct in_addr));
+                       memcpy (&in4d, &task->from_addr.addr.s4.sin_addr, sizeof (struct in_addr));
                        s = (guint8 *)&in4s;
                        d = (guint8 *)&in4d;
                }
@@ -215,18 +214,6 @@ spf_check_element (struct spf_addr *addr, struct rspamd_task *task)
                        res = FALSE;
                }
        }
-#else
-       guint32                         s, m;
-
-       if (addr->data.normal.mask == 0) {
-               m = 0;
-       }
-       else {
-               m = htonl (G_MAXUINT32 << (32 - addr->data.normal.mask));
-       }
-       s = task->from_addr.s_addr;
-       res = (s & m) == (addr->data.normal.d.in4.s_addr & m);
-#endif
 
        if (res) {
                switch (addr->mech) {
@@ -300,28 +287,16 @@ spf_symbol_callback (struct rspamd_task *task, void *unused)
        gchar                           *domain;
        GList                           *l;
 
-#ifdef HAVE_INET_PTON
-       if (task->from_addr.has_addr) {
-               if (TRUE) {
-#else
-       if (task->from_addr.s_addr != INADDR_NONE && task->from_addr.s_addr != INADDR_ANY) {
-               if (radix32tree_find (spf_module_ctx->whitelist_ip, ntohl (task->from_addr.s_addr)) == RADIX_NO_VALUE) {
-#endif
-                       domain = get_spf_domain (task);
-                       if (domain) {
-                               if ((l = rspamd_lru_hash_lookup (spf_module_ctx->spf_hash, domain, task->tv.tv_sec)) != NULL) {
-                                       spf_check_list (l, task);
-                               }
-                               else if (!resolve_spf (task, spf_plugin_callback)) {
-                                       msg_info ("cannot make spf request for [%s]", task->message_id);
-                               }
+       if (task->from_addr.af != AF_UNIX) {
+               domain = get_spf_domain (task);
+               if (domain) {
+                       if ((l = rspamd_lru_hash_lookup (spf_module_ctx->spf_hash, domain, task->tv.tv_sec)) != NULL) {
+                               spf_check_list (l, task);
+                       }
+                       else if (!resolve_spf (task, spf_plugin_callback)) {
+                               msg_info ("cannot make spf request for [%s]", task->message_id);
                        }
                }
-#ifndef HAVE_INET_PTON
-               else {
-                       msg_info ("ip %s is whitelisted for spf checks", inet_ntoa (task->from_addr));
-               }
-#endif
        }
 }
 
index 9da4f445d29ae2ff74f378e8d60ba94b1c86cc47..8a5c3f0df8556ad0df10c5d1f5b6ffa953649d91 100644 (file)
@@ -312,39 +312,10 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, struct rspamd_http_mes
                case 'I':
                        if (g_ascii_strcasecmp (headern, IP_ADDR_HEADER) == 0) {
                                tmp = h->value->str;
-#ifdef HAVE_INET_PTON
-                               if (g_ascii_strncasecmp (tmp, "IPv6:", 5) == 0) {
-                                       if (inet_pton (AF_INET6, tmp + 6, &task->from_addr.d.in6) == 1) {
-                                               task->from_addr.ipv6 = TRUE;
-                                       }
-                                       else {
-                                               msg_err ("bad ip header: '%s'", tmp);
-                                               return FALSE;
-                                       }
-                                       task->from_addr.has_addr = TRUE;
-                               }
-                               else {
-                                       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_err ("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)) {
+                               if (!rspamd_parse_inet_address (&task->from_addr, tmp)) {
                                        msg_err ("bad ip header: '%s'", tmp);
                                        return FALSE;
                                }
-#endif
                                debug_task ("read IP header, value: %s", tmp);
                        }
                        else {
@@ -482,7 +453,8 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud)
        if (cb->task->cfg->log_urls) {
                msg_info ("<%s> URL: %s - %s: %s", cb->task->message_id, cb->task->user ?
                                cb->task->user : (cb->task->from ? cb->task->from : "unknown"),
-                               inet_ntoa (cb->task->client_addr), struri (url));
+                               rspamd_inet_address_to_string (&cb->task->from_addr),
+                               struri (url));
        }
 
        return FALSE;
index bffad8e48ef462baa93c2553f70e70d65ec512b6..c4fa236056888829a98bd2c90bbeb44cbdec84f0 100644 (file)
@@ -667,7 +667,7 @@ smtp_dns_cb (struct rdns_reply *reply, void *arg)
                /* Parse reverse reply and start resolve of this ip */
                if (reply->code != RDNS_RC_NOERROR) {
                        rspamd_conditional_debug (rspamd_main->logger,
-                                       session->client_addr.s_addr, __FUNCTION__, "DNS error: %s",
+                                       NULL, __FUNCTION__, "DNS error: %s",
                                        rdns_strerror (reply->code));
 
                        if (reply->code == RDNS_RC_NXDOMAIN) {
@@ -696,7 +696,7 @@ smtp_dns_cb (struct rdns_reply *reply, void *arg)
        case SMTP_PROXY_STATE_RESOLVE_NORMAL:
                if (reply->code != RDNS_RC_NOERROR) {
                        rspamd_conditional_debug (rspamd_main->logger,
-                                       session->client_addr.s_addr, __FUNCTION__, "DNS error: %s",
+                                       NULL, __FUNCTION__, "DNS error: %s",
                                        rdns_strerror (reply->code));
 
                        if (reply->code == RDNS_RC_NXDOMAIN) {
@@ -901,14 +901,15 @@ static void
 accept_socket (gint fd, short what, void *arg)
 {
        struct rspamd_worker           *worker = (struct rspamd_worker *)arg;
-       union sa_union                  su;
        struct smtp_proxy_session      *session;
        struct smtp_proxy_ctx          *ctx;
+       rspamd_inet_addr_t               addr;
+       gint                             nfd;
 
-       socklen_t                       addrlen = sizeof (su.ss);
-       gint                            nfd;
+       ctx = worker->ctx;
 
-       if ((nfd = accept_from_socket (fd, (struct sockaddr *)&su.ss, &addrlen)) == -1) {
+       if ((nfd =
+                       rspamd_accept_from_socket (fd, &addr)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
                return;
        }
@@ -917,18 +918,14 @@ accept_socket (gint fd, short what, void *arg)
                return;
        }
 
+       msg_info ("accepted connection from %s port %d",
+                       rspamd_inet_address_to_string (&addr),
+                       rspamd_inet_address_get_port (&addr));
+
        ctx = worker->ctx;
        session = g_slice_alloc0 (sizeof (struct smtp_proxy_session));
        session->pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
 
-       if (su.ss.ss_family == AF_UNIX) {
-               msg_info ("accepted connection from unix socket");
-               session->client_addr.s_addr = INADDR_NONE;
-       }
-       else if (su.ss.ss_family == AF_INET) {
-               msg_info ("accepted connection from %s port %d", inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
-               memcpy (&session->client_addr, &su.s4.sin_addr, sizeof (struct in_addr));
-       }
 
        session->sock = nfd;
        session->worker = worker;
@@ -936,7 +933,7 @@ accept_socket (gint fd, short what, void *arg)
        session->resolver = ctx->resolver;
        session->ev_base = ctx->ev_base;
        session->upstream_sock = -1;
-       session->ptr_str = rdns_generate_ptr_from_str (inet_ntoa (su.s4.sin_addr));
+       session->ptr_str = rdns_generate_ptr_from_str (rspamd_inet_address_to_string (&addr));
        worker->srv->stat->connections_count++;
 
        /* Resolve client's addr */
index 5e8c33a35d71ccab7cc8868639afa155216742f0..6c438135fecc176c176e523dbcae59ea5799820c 100644 (file)
@@ -1691,47 +1691,29 @@ rspamd_webui_accept_socket (gint fd, short what, void *arg)
        struct rspamd_worker                            *worker = (struct rspamd_worker *) arg;
        struct rspamd_webui_worker_ctx          *ctx;
        struct rspamd_webui_session                     *nsession;
+       rspamd_inet_addr_t                                       addr;
        gint                                                             nfd;
-       union sa_union                                           su;
-       socklen_t                                                        addrlen = sizeof (su);
-       char                                                             ip_str[INET6_ADDRSTRLEN + 1];
 
        ctx = worker->ctx;
 
        if ((nfd =
-                       accept_from_socket (fd, &su.sa, &addrlen)) == -1) {
+                       rspamd_accept_from_socket (fd, &addr)) == -1) {
                msg_warn ("accept failed: %s", strerror (errno));
                return;
        }
        /* Check for EAGAIN */
-       if (nfd == 0){
+       if (nfd == 0) {
                return;
        }
 
+       msg_info ("accepted connection from %s port %d",
+                       rspamd_inet_address_to_string (&addr),
+                       rspamd_inet_address_get_port (&addr));
+
        nsession = g_slice_alloc0 (sizeof (struct rspamd_webui_session));
        nsession->pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
        nsession->ctx = ctx;
 
-       if (su.sa.sa_family == AF_UNIX) {
-               msg_info ("accepted connection from unix socket");
-               nsession->from_addr.has_addr = FALSE;
-       }
-       else if (su.sa.sa_family == AF_INET) {
-               msg_info ("accepted connection from %s port %d",
-                               inet_ntoa (su.s4.sin_addr), ntohs (su.s4.sin_port));
-               nsession->from_addr.has_addr = TRUE;
-               nsession->from_addr.d.in4.s_addr = su.s4.sin_addr.s_addr;
-       }
-       else if (su.sa.sa_family == AF_INET6) {
-               msg_info ("accepted connection from %s port %d",
-                               inet_ntop (su.sa.sa_family, &su.s6.sin6_addr, ip_str, sizeof (ip_str)),
-                               ntohs (su.s6.sin6_port));
-               memcpy (&nsession->from_addr.d.in6, &su.s6.sin6_addr,
-                               sizeof (struct in6_addr));
-               nsession->from_addr.has_addr = TRUE;
-               nsession->from_addr.ipv6 = TRUE;
-       }
-
        rspamd_http_router_handle_socket (ctx->http, nfd, nsession);
 }
 
index 978ff72ecd1b24b9bd7f46bc912a852fc25ed4d4..8efb5a19e7baf745616c43e3a9b7476827d1d487 100644 (file)
@@ -254,7 +254,7 @@ rspamd_worker_error_handler (struct rspamd_http_connection *conn, GError *err)
        struct rspamd_task             *task = (struct rspamd_task *) conn->ud;
 
        msg_info ("abnormally closing connection from: %s, error: %s",
-                       inet_ntoa (task->client_addr), err->message);
+                       rspamd_inet_address_to_string (&task->client_addr), err->message);
        if (task->state != CLOSING_CONNECTION) {
                /* We still need to write a reply */
                task->error_code = err->code;
@@ -275,7 +275,8 @@ rspamd_worker_finish_handler (struct rspamd_http_connection *conn,
        struct rspamd_task             *task = (struct rspamd_task *) conn->ud;
 
        if (task->state == CLOSING_CONNECTION) {
-               msg_debug ("normally closing connection from: %s", inet_ntoa (task->client_addr));
+               msg_debug ("normally closing connection from: %s",
+                               rspamd_inet_address_to_string (&task->client_addr));
                destroy_session (task->s);
        }
        else {