}
static void cmd_id_handle_keyvalue(struct imap_client *client,
+ struct imap_id_log_entry *log_entry,
const char *key, const char *value)
{
bool client_id_str;
imap_append_quoted(client->common.client_id, value);
}
- if (client->cmd_id->log_reply != NULL &&
- (client->cmd_id->log_keys == NULL ||
- str_array_icase_find((void *)client->cmd_id->log_keys, key)))
- imap_id_log_reply_append(client->cmd_id->log_reply, key, value);
+ imap_id_add_log_entry(log_entry, key, value);
}
static int cmd_id_handle_args(struct imap_client *client,
+ struct imap_id_log_entry *log_entry,
const struct imap_arg *arg)
{
struct imap_client_cmd_id *id = client->cmd_id;
return 1;
if (arg->type != IMAP_ARG_LIST)
return -1;
- if (client->set->imap_id_log[0] == '\0') {
- /* no ID logging */
- } else if (client->id_logged) {
- /* already logged the ID reply */
- } else {
+ if (!client->id_logged)
id->log_reply = str_new(default_pool, 64);
- if (strcmp(client->set->imap_id_log, "*") == 0) {
- /* log all keys */
- } else {
- /* log only specified keys */
- id->log_keys = p_strsplit_spaces(default_pool,
- client->set->imap_id_log, " ");
- }
- }
id->state = IMAP_CLIENT_ID_STATE_KEY;
break;
case IMAP_CLIENT_ID_STATE_KEY:
case IMAP_CLIENT_ID_STATE_VALUE:
if (!imap_arg_get_nstring(arg, &value))
return -1;
- cmd_id_handle_keyvalue(client, id->key, value);
+ if (!client->id_logged && id->log_reply != NULL) {
+ log_entry->reply = id->log_reply;
+ cmd_id_handle_keyvalue(client, log_entry, id->key, value);
+ }
id->state = IMAP_CLIENT_ID_STATE_KEY;
break;
}
static void cmd_id_finish(struct imap_client *client)
{
- /* finished handling the parameters */
if (!client->id_logged) {
client->id_logged = TRUE;
- if (client->cmd_id->log_reply != NULL) {
- e_info(client->common.event, "ID sent: %s",
- str_c(client->cmd_id->log_reply));
+ if (client->cmd_id->log_reply != NULL &&
+ str_len(client->cmd_id->log_reply) > 0) {
+ e_debug(client->cmd_id->params_event,
+ "Pre-login ID sent: %s",
+ str_c(client->cmd_id->log_reply));
}
}
{
struct imap_client_cmd_id *id = client->cmd_id;
+ event_unref(&id->params_event);
str_free(&id->log_reply);
- if (id->log_keys != NULL)
- p_strsplit_free(default_pool, id->log_keys);
imap_parser_unref(&id->parser);
i_free_and_null(client->cmd_id);
parser_flags = IMAP_PARSE_FLAG_INSIDE_LIST;
}
+ if (id->params_event == NULL) {
+ id->params_event = event_create(client->common.event);
+ event_set_name(id->params_event, "imap_id_received");
+ }
+ struct imap_id_log_entry log_entry = {
+ .event = id->params_event,
+ };
while ((ret = imap_parser_read_args(id->parser, 1, parser_flags, &args)) > 0) {
i_assert(ret == 1);
- if ((ret = cmd_id_handle_args(client, args)) < 0) {
+ if ((ret = cmd_id_handle_args(client, &log_entry, args)) < 0) {
client_send_reply(&client->common,
IMAP_CMD_REPLY_BAD,
"Invalid ID parameters");