-/* Copyright (C) 2007-2020 Open Information Security Foundation
+/* Copyright (C) 2007-2021 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
SCEnter();
JsonEmailLogThread *jhl = (JsonEmailLogThread *)thread_data;
- JsonBuilder *jb = CreateEveHeaderWithTxId(p, LOG_DIR_FLOW, "smtp", NULL, tx_id);
+ JsonBuilder *jb = CreateEveHeaderWithTxId(
+ p, LOG_DIR_FLOW, "smtp", NULL, tx_id, jhl->emaillog_ctx->eve_ctx);
if (unlikely(jb == NULL))
return TM_ECODE_OK;
- EveAddCommonOptions(&jhl->emaillog_ctx->cfg, p, f, jb);
-
- /* reset */
- MemBufferReset(jhl->buffer);
jb_open_object(jb, "smtp");
EveSmtpDataLogger(f, state, tx, tx_id, jb);
jb_close(jb);
- if (EveEmailLogJson(jhl, jb, p, f, state, tx, tx_id) == TM_ECODE_OK) {
- OutputJsonBuilderBuffer(jb, jhl->file_ctx, &jhl->buffer);
- }
+ EveEmailLogJson(jhl, jb, p, f, state, tx, tx_id);
+ OutputJsonBuilderBuffer(jb, jhl->ctx);
jb_free(jb);
return result;
}
- email_ctx->file_ctx = ojc->file_ctx;
- email_ctx->cfg = ojc->cfg;
+ email_ctx->eve_ctx = ojc;
OutputEmailInitConf(conf, email_ctx);
/* Use the Output Context (file pointer and mutex) */
aft->emaillog_ctx = ((OutputCtx *)initdata)->data;
- aft->buffer = MemBufferCreateNew(JSON_OUTPUT_BUFFER_SIZE);
- if (aft->buffer == NULL) {
+ aft->ctx = CreateEveThreadCtx(t, aft->emaillog_ctx->eve_ctx);
+ if (aft->ctx == NULL) {
goto error_exit;
}
- aft->file_ctx = LogFileEnsureExists(aft->emaillog_ctx->file_ctx, t->id);
- if (!aft->file_ctx) {
- goto error_exit;
- }
*data = (void *)aft;
return TM_ECODE_OK;
error_exit:
- if (aft->buffer != NULL) {
- MemBufferFree(aft->buffer);
- }
SCFree(aft);
return TM_ECODE_FAILED;
}
if (aft == NULL) {
return TM_ECODE_OK;
}
+ FreeEveThreadCtx(aft->ctx);
- MemBufferFree(aft->buffer);
/* clear memory */
memset(aft, 0, sizeof(JsonEmailLogThread));