/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "net.h"
#include "ostream.h"
#include "str.h"
#include "strescape.h"
#include "wildcard-match.h"
#include "mail-stats.h"
#include "mail-command.h"
#include "mail-session.h"
#include "mail-user.h"
#include "mail-domain.h"
#include "mail-ip.h"
#include "client.h"
#include "client-export.h"
enum mail_export_level {
};
static const char *mail_export_level_names[] = {
"command", "session", "user", "domain", "ip", "global"
};
struct mail_export_filter {
unsigned int ip_bits;
bool connected;
};
struct client_export_cmd {
bool header_sent;
};
static int
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(mail_export_level_names); i++) {
*level_r = (enum mail_export_level)i;
return 0;
}
}
return -1;
}
static int
struct mail_export_filter *filter_r,
const char **error_r)
{
unsigned long l;
/* filters:
user=<wildcard> | domain=<wildcard> | session=<str>
ip=<ip>[/<mask>]
since=<timestamp>
connected
*/
*error_r = "Invalid ip filter";
return -1;
}
*error_r = "Invalid since filter";
return -1;
}
}
}
return 0;
}
static void
{
for (i = 1; i < count; i++) {
}
}
static void
{
for (i = 1; i < count; i++) {
}
}
static bool
const struct mail_session *session)
{
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
return TRUE;
}
static bool
{
struct mail_session *s;
return FALSE;
if (!s->disconnected)
}
return FALSE;
return FALSE;
}
return TRUE;
}
static bool
{
return FALSE;
return FALSE;
}
static bool
const struct mail_domain *domain)
{
return FALSE;
return FALSE;
break;
}
return FALSE;
}
return TRUE;
}
static bool
{
struct mail_session *s;
if (!s->disconnected)
}
return FALSE;
return FALSE;
return FALSE;
}
return FALSE;
return FALSE;
return TRUE;
}
{
}
{
if (!cmd->header_sent) {
"cmd\targs\tsession\tuser\tlast_update\t");
}
if (client_is_busy(client))
break;
continue;
}
return 0;
}
return 1;
}
{
if (!cmd->header_sent) {
"session\tuser\tip\tservice\tpid\tconnected"
"\tlast_update\tnum_cmds\t");
}
if (client_is_busy(client))
break;
continue;
} T_END;
}
return 0;
}
return 1;
}
{
if (!cmd->header_sent) {
"user\treset_timestamp\tlast_update"
"\tnum_logins\tnum_cmds\t");
}
if (client_is_busy(client))
break;
continue;
}
return 0;
}
return 1;
}
{
if (!cmd->header_sent) {
"domain\treset_timestamp\tlast_update"
"\tnum_logins\tnum_cmds\tnum_connected_sessions\t");
}
if (client_is_busy(client))
break;
continue;
}
return 0;
}
return 1;
}
{
if (!cmd->header_sent) {
"ip\treset_timestamp\tlast_update"
"\tnum_logins\tnum_cmds\tnum_connected_sessions\t");
}
if (client_is_busy(client))
break;
continue;
T_BEGIN {
} T_END;
}
return 0;
}
return 1;
}
{
struct mail_global *g = &mail_global_stats;
if (!cmd->header_sent) {
"reset_timestamp\tlast_update"
"\tnum_logins\tnum_cmds\tnum_connected_sessions\t");
}
return 1;
}
{
return 0;
return 1;
}
{
/* exact user */
return FALSE;
return FALSE;
} else {
}
return TRUE;
}
/* exact IP address */
return FALSE;
return FALSE;
} else {
}
return TRUE;
}
/* exact domain */
return FALSE;
} else {
}
return TRUE;
}
return FALSE;
break;
return FALSE;
break;
case MAIL_EXPORT_LEVEL_USER:
return FALSE;
break;
case MAIL_EXPORT_LEVEL_DOMAIN:
return FALSE;
break;
case MAIL_EXPORT_LEVEL_IP:
return FALSE;
break;
case MAIL_EXPORT_LEVEL_GLOBAL:
break;
}
return TRUE;
}
const char **error_r)
{
*error_r = "Missing level parameter";
return -1;
}
*error_r = "Invalid level";
return -1;
}
return -1;
if (!client_export_iter_init(client)) {
/* nothing to export */
return 1;
}
return client_export_more(client);
}