From 0b0292961eece87784fe5fc618fc55e9cb6f06ac Mon Sep 17 00:00:00 2001 From: 彭宣正 Date: Mon, 1 Nov 2021 11:18:38 +0800 Subject: ✨ feat(TSG-8103): MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/tsg_send_log.h | 1 + src/tsg_entry.cpp | 28 +++++++++++++++++++++++++++- src/tsg_send_log.cpp | 15 +++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/inc/tsg_send_log.h b/inc/tsg_send_log.h index 2f9caf1..e61a4c4 100644 --- a/inc/tsg_send_log.h +++ b/inc/tsg_send_log.h @@ -36,6 +36,7 @@ struct TLD_handle_t *TLD_create(int thread_id); int TLD_append(struct TLD_handle_t *handle, char *key, void *value, TLD_TYPE type); int TLD_append_streaminfo(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, struct streaminfo *a_stream); int TLD_cancel(struct TLD_handle_t *handle); +struct TLD_handle_t *TLD_duplicate(struct TLD_handle_t *handle); int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handle, tsg_log_t *log_msg, int thread_id); diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp index 7ffafb8..23e2645 100644 --- a/src/tsg_entry.cpp +++ b/src/tsg_entry.cpp @@ -47,8 +47,13 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL; } #endif +struct session_record_ctx +{ + struct TLD_handle_t *log; + tsg_protocol_t proto_type; +}; -char TSG_MASTER_VERSION_20200805=0; +char TSG_MASTER_VERSION_20200805 = 0; const char *tsg_conffile="tsgconf/main.conf"; g_tsg_para_t g_tsg_para; @@ -1631,6 +1636,27 @@ static unsigned char tsg_master_data_entry(const struct streaminfo *a_stream, vo { if(context!=NULL && context->is_log==0 && context->hit_cnt>0 && context->result!=NULL) { + if (context->proto == PROTO_SSH && context->result->action == TSG_ACTION_MONITOR) + { + int ssh_project_id = project_customer_register("SKETCH_PROTO_CTX_LABEL", PROJECT_VAL_TYPE_STRUCT); + if (ssh_project_id >= 0) + { + session_record_ctx * ssh_session_record_ctx = (session_record_ctx *)project_req_get_struct(a_stream, ssh_project_id); + if (ssh_session_record_ctx != NULL && ssh_session_record_ctx->proto_type == PROTO_SSH) + { + tsg_log_t log_msg; + log_msg.a_stream = (streaminfo *)a_stream; + log_msg.result = p_result; + log_msg.result_num = 1; + + struct TLD_handle_t *_handle = TLD_duplicate(ssh_session_record_ctx->log); + if (_handle != NULL) + { + tsg_send_log(g_tsg_log_instance, _handle, &log_msg, thread_seq); + } + } + } + } context->is_log=1; master_send_log(a_stream, context->result, context->hit_cnt, context, thread_seq); } diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index c51d40e..1a5d3b6 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -890,6 +890,21 @@ int TLD_append(struct TLD_handle_t *handle, char *key, void *value, TLD_TYPE typ return 0; } +struct TLD_handle_t *TLD_duplicate(struct TLD_handle_t *handle) +{ + if (handle == NULL) + { + return NULL; + } + struct TLD_handle_t *_handle=(struct TLD_handle_t *)calloc(1, sizeof(struct TLD_handle_t)); + _handle->thread_id = handle->thread_id; + _handle->document = new Document(); + //_handle->document->SetObject(); + + _handle->document->CopyFrom(*handle->document, _handle->document->GetAllocator()); + return _handle; +} + struct TLD_handle_t *TLD_create(int thread_id) { //struct _tld_handle *_handle=(struct _tld_handle *)dictator_malloc(thread_id, sizeof(struct _tld_handle)); -- cgit v1.2.3