]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix roll history IP storage.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 Oct 2014 11:46:48 +0000 (11:46 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 31 Oct 2014 11:46:48 +0000 (11:46 +0000)
src/controller.c
src/libserver/roll_history.h

index dafbe5bc1fec7b734bab404164518b009baca28f..98a9df614b72994665aaa09f788b7bfd710f633e 100644 (file)
@@ -647,7 +647,6 @@ rspamd_controller_handle_history (struct rspamd_http_connection_entry *conn_ent,
        gint i, rows_proc, row_num;
        struct tm *tm;
        gchar timebuf[32];
-       gchar ip_buf[INET6_ADDRSTRLEN];
        ucl_object_t *top, *obj;
 
        ctx = session->ctx;
@@ -675,27 +674,14 @@ rspamd_controller_handle_history (struct rspamd_http_connection_entry *conn_ent,
                /* Get only completed rows */
                if (row->completed) {
                        tm = localtime (&row->tv.tv_sec);
-                       strftime (timebuf, sizeof (timebuf), "%F %H:%M:%S", tm);
-#ifdef HAVE_INET_PTON
-                       if (row->from_addr.ipv6) {
-                               inet_ntop (AF_INET6, &row->from_addr.d.in6, ip_buf,
-                                       sizeof (ip_buf));
-                       }
-                       else {
-                               inet_ntop (AF_INET, &row->from_addr.d.in4, ip_buf,
-                                       sizeof (ip_buf));
-                       }
-#else
-                       rspamd_strlcpy (ip_buf, inet_ntoa (task->from_addr),
-                               sizeof (ip_buf));
-#endif
                        obj = ucl_object_typed_new (UCL_OBJECT);
                        ucl_object_insert_key (obj, ucl_object_fromstring (
                                        timebuf),                 "time", 0, false);
                        ucl_object_insert_key (obj, ucl_object_fromstring (
                                        row->message_id), "id",   0, false);
                        ucl_object_insert_key (obj, ucl_object_fromstring (
-                                       ip_buf),                  "ip",   0, false);
+                                       rspamd_inet_address_to_string (&row->from_addr)),
+                                       "ip", 0, false);
                        ucl_object_insert_key (obj,
                                ucl_object_fromstring (rspamd_action_to_str (
                                        row->action)), "action", 0, false);
index 85a8f2ddc64e36b6302bae78f548902294c2cb30..d4034202c8d706b37052ec7f3e4a3bf40dbad405 100644 (file)
@@ -45,18 +45,7 @@ struct roll_history_row {
        gchar message_id[HISTORY_MAX_ID];
        gchar symbols[HISTORY_MAX_SYMBOLS];
        gchar user[HISTORY_MAX_USER];
-#ifdef HAVE_INET_PTON
-       struct {
-               union {
-                       struct in_addr in4;
-                       struct in6_addr in6;
-               } d;
-               gboolean ipv6;
-               gboolean has_addr;
-       } from_addr;
-#else
-       struct in_addr from_addr;
-#endif
+       rspamd_inet_addr_t from_addr;
        gsize len;
        guint scan_time;
        gint action;