changeset 18924:f611d66e56f6

stats: Added session=<ID> filter to doveadm dump session|command
author Timo Sirainen <tss@iki.fi>
date Fri, 07 Aug 2015 15:30:26 +0300
parents 573118da2eaa
children ff17864ba6e0
files src/stats/client-export.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/stats/client-export.c	Fri Aug 07 15:13:34 2015 +0300
+++ b/src/stats/client-export.c	Fri Aug 07 15:30:26 2015 +0300
@@ -28,7 +28,7 @@
 };
 
 struct mail_export_filter {
-	const char *user, *domain;
+	const char *user, *domain, *session;
 	struct ip_addr ip;
 	unsigned int ip_bits;
 	time_t since;
@@ -65,7 +65,7 @@
 	unsigned long l;
 
 	/* filters:
-	   user=<wildcard> | domain=<wildcard>
+	   user=<wildcard> | domain=<wildcard> | session=<str>
 	   ip=<ip>[/<mask>]
 	   since=<timestamp>
 	   connected
@@ -76,6 +76,8 @@
 			filter_r->user = p_strdup(pool, *args + 5);
 		else if (strncmp(*args, "domain=", 7) == 0)
 			filter_r->domain = p_strdup(pool, *args + 7);
+		else if (strncmp(*args, "session=", 8) == 0)
+			filter_r->session = p_strdup(pool, *args + 8);
 		else if (strncmp(*args, "ip=", 3) == 0) {
 			if (net_parse_range(*args + 3, &filter_r->ip,
 					    &filter_r->ip_bits) < 0) {
@@ -134,6 +136,9 @@
 		return FALSE;
 	if (filter->since > session->last_update.tv_sec)
 		return FALSE;
+	if (filter->session != NULL &&
+	    strcmp(session->id, filter->session) != 0)
+		return FALSE;
 	if (filter->user != NULL &&
 	    !wildcard_match(session->user->name, filter->user))
 		return FALSE;