aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-31 11:46:48 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-10-31 11:46:48 +0000
commitfcc328517c4440e13b086691ff57874db5816885 (patch)
tree37d8964a47e07177c3c66a06e50dff0f77f8521e /src
parentff8a6010e8798bf1242246705b88176538e626ff (diff)
downloadrspamd-fcc328517c4440e13b086691ff57874db5816885.tar.gz
rspamd-fcc328517c4440e13b086691ff57874db5816885.zip
Fix roll history IP storage.
Diffstat (limited to 'src')
-rw-r--r--src/controller.c18
-rw-r--r--src/libserver/roll_history.h13
2 files changed, 3 insertions, 28 deletions
diff --git a/src/controller.c b/src/controller.c
index dafbe5bc1..98a9df614 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -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);
diff --git a/src/libserver/roll_history.h b/src/libserver/roll_history.h
index 85a8f2ddc..d4034202c 100644
--- a/src/libserver/roll_history.h
+++ b/src/libserver/roll_history.h
@@ -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;