feat(TSG-8103):

This commit is contained in:
彭宣正
2021-11-01 11:18:38 +08:00
parent 092aba6df7
commit 0b0292961e
3 changed files with 43 additions and 1 deletions

View File

@@ -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);

View File

@@ -47,6 +47,11 @@ 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;
const char *tsg_conffile="tsgconf/main.conf";
@@ -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);
}

View File

@@ -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));