diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp index 045406e..c2604b1 100644 --- a/common/src/tfe_packet_io.cpp +++ b/common/src/tfe_packet_io.cpp @@ -1098,7 +1098,6 @@ static int handle_session_opening(struct metadata *meta, marsio_buff_t *rx_buff, uint8_t hit_no_intercept = 0; uint8_t is_session_id_only_key = 0; uint16_t out_size = 0; - char stream_traceid[24] = {0}; char reason_no_intercept_param[] = "Hit No Intercept Policy"; char reason_invalid_intercept_param[] = "Invalid Intercept Param"; char reason_invalid_tcp_policy_param[] = "Invalid tcp policy Param"; diff --git a/common/src/tfe_scan.cpp b/common/src/tfe_scan.cpp index 5dc0bff..ebcdc36 100644 --- a/common/src/tfe_scan.cpp +++ b/common/src/tfe_scan.cpp @@ -211,7 +211,7 @@ int tfe_scan_fqdn_tags(const struct tfe_stream *stream, uuid_t *result, struct m { memset(&objects, 0, sizeof(objects)); uuid_copy(objects.object_uuid, opt_val[i]); - scan_ret = scan_object(result, scan_mid, hit_cnt, objects, "TSG_OBJ_FQDN", "SERVER_FQDN"); + scan_ret = scan_object(result, scan_mid, hit_cnt, objects, "TSG_OBJ_FQDN", "DESTINATION_FQDN"); if (scan_ret > 0) { char result_str[UUID_STRING_SIZE]={0}; diff --git a/plugin/business/doh/src/doh.cpp b/plugin/business/doh/src/doh.cpp index dc91fcd..1a32e92 100644 --- a/plugin/business/doh/src/doh.cpp +++ b/plugin/business/doh/src/doh.cpp @@ -283,22 +283,22 @@ static void doh_maat_scan(const struct tfe_stream *stream, const struct tfe_http const char *host = session->req->req_spec.host; if (host) { - scan_ret = maat_scan_string(g_doh_conf->maat, "TSG_OBJ_FQDN", "SERVER_FQDN", host, strlen(host), + scan_ret = maat_scan_string(g_doh_conf->maat, "TSG_OBJ_FQDN", "DESTINATION_FQDN", host, strlen(host), result + hit_cnt, MAX_SCAN_RESULT - hit_cnt, &n_hit_result, ctx->scan_mid); if (scan_ret == MAAT_SCAN_HIT) { memset(result_str, 0, sizeof(result_str)); uuid_unparse(result[hit_cnt], result_str); TFE_LOG_INFO(g_doh_conf->local_logger, "Scan %s, Hit host: %s scan ret: %d policy_id: %s addr: %s", - "SERVER_FQDN", host, scan_ret, result_str, stream->str_stream_info); + "DESTINATION_FQDN", host, scan_ret, result_str, stream->str_stream_info); hit_cnt += n_hit_result; } else { TFE_LOG_INFO(g_doh_conf->local_logger, "Scan %s, NO hit host: %s scan ret: %d addr: %s", - "SERVER_FQDN", host, scan_ret, stream->str_stream_info); + "DESTINATION_FQDN", host, scan_ret, stream->str_stream_info); } - scan_ret = maat_scan_not_logic(g_doh_conf->maat, "TSG_OBJ_FQDN", "SERVER_FQDN", + scan_ret = maat_scan_not_logic(g_doh_conf->maat, "TSG_OBJ_FQDN", "DESTINATION_FQDN", result + hit_cnt, MAX_SCAN_RESULT - hit_cnt, &n_hit_result, ctx->scan_mid); if (scan_ret == MAAT_SCAN_HIT) { diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp index 50e2648..ca68bc3 100644 --- a/plugin/business/doh/src/logger.cpp +++ b/plugin/business/doh/src/logger.cpp @@ -285,7 +285,7 @@ int doh_get_format_host(cJSON *common_obj, const char *req_spec_host) char *format_host=ALLOC(char, strlen(req_spec_host)+1); sscanf(req_spec_host, "%[^:]:%u", format_host, &port); cJSON_AddStringToObject(common_obj, "doh_host", format_host); - cJSON_AddStringToObject(common_obj, "server_fqdn", format_host); + cJSON_AddStringToObject(common_obj, "destination_fqdn", format_host); FREE(&format_host); return 0; } @@ -321,6 +321,36 @@ int doh_get_string_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_ return 0; } +int doh_get_uuid_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type type, const char *keyword) +{ + uuid_t opt_val; + char session_uuid[UUID_STRING_SIZE]={0}; + uint16_t opt_out_size = 0; + + int ret=tfe_cmsg_get_value(cmsg, type, (unsigned char *)opt_val, sizeof(opt_val), &opt_out_size); + if (ret == 0 && opt_out_size > 0) + { + uuid_unparse(opt_val,session_uuid); + cJSON_AddStringToObject(common_obj, keyword, session_uuid); + } + return 0; +} + + +#ifdef __x86_64__ +#include "uuid_v4_x86.h" +#else +#include "uuid_v4_arm.h" +#endif + +void doh_uuidv4_generate(char *uuid) +{ + UUIDv4::UUIDGenerator uuidGenerator; + UUIDv4::UUID uid = uuidGenerator.getUUID(); + uid.str(uuid); + return; +} + int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, const struct tfe_stream *stream, struct doh_ctx *ctx) { struct doh_maat_rule_t *result = ctx->result; @@ -348,6 +378,9 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c return 0; } + char log_uuid[40] = {0}; + doh_uuidv4_generate(log_uuid); + common_obj = cJSON_CreateObject(); gettimeofday(&cur_time, NULL); @@ -355,11 +388,12 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c cJSON_AddNumberToObject(common_obj, "end_timestamp_ms", get_time_ms(cur_time)); cJSON_AddStringToObject(common_obj, "doh_version", app_proto[http->major_version]); cJSON_AddStringToObject(common_obj, "decoded_as", "DoH"); + cJSON_AddStringToObject(common_obj, "log_uuid", log_uuid); struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream); if (cmsg != NULL) { - doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_id"); + doh_get_uuid_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_uuid"); doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_SUB_ID, "subscriber_id"); doh_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_IMSI_STR, "imsi"); diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp index d059355..994a3e0 100644 --- a/plugin/business/tsg-http/src/tsg_http.cpp +++ b/plugin/business/tsg-http/src/tsg_http.cpp @@ -2824,13 +2824,13 @@ enum proxy_action http_scan(const struct tfe_http_session * session, enum tfe_ht int str_host_length = get_fqdn_len(str_host); if (str_host != NULL && str_host_length != 0) { - scan_ret = maat_scan_string(g_proxy_rt->feather, "TSG_OBJ_FQDN", "SERVER_FQDN", str_host, str_host_length, + scan_ret = maat_scan_string(g_proxy_rt->feather, "TSG_OBJ_FQDN", "DESTINATION_FQDN", str_host, str_host_length, result + hit_cnt, MAX_SCAN_RESULT - hit_cnt, &n_hit_result, ctx->scan_mid); if (scan_ret == MAAT_SCAN_HIT) { hit_cnt += n_hit_result; } - scan_ret = maat_scan_not_logic(g_proxy_rt->feather, "TSG_OBJ_FQDN", "SERVER_FQDN", + scan_ret = maat_scan_not_logic(g_proxy_rt->feather, "TSG_OBJ_FQDN", "DESTINATION_FQDN", result + hit_cnt, MAX_SCAN_RESULT - hit_cnt, &n_hit_result, ctx->scan_mid); if (scan_ret == MAAT_SCAN_HIT) { diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp index e7875aa..b058351 100644 --- a/plugin/business/tsg-http/src/tsg_logger.cpp +++ b/plugin/business/tsg-http/src/tsg_logger.cpp @@ -48,10 +48,10 @@ enum _log_action #else #include "uuid_v4_arm.h" #endif -UUIDv4::UUIDGenerator uuidGenerator; -void get_http_body_uuid(char *uuid) +void uuidv4_generate(char *uuid) { + UUIDv4::UUIDGenerator uuidGenerator; UUIDv4::UUID uid = uuidGenerator.getUUID(); uid.str(uuid); return; @@ -119,7 +119,7 @@ int tfe_get_format_host(cJSON *common_obj, const char *req_spec_host) char *format_host=ALLOC(char, strlen(req_spec_host)+1); sscanf(req_spec_host, "%[^:]:%u", format_host, &port); cJSON_AddStringToObject(common_obj, "http_host", format_host); - cJSON_AddStringToObject(common_obj, "server_fqdn", format_host); + cJSON_AddStringToObject(common_obj, "destination_fqdn", format_host); FREE(&format_host); return 0; } @@ -155,6 +155,21 @@ int tfe_get_string_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_ return 0; } +int tfe_get_uuid_by_cmsg(cJSON *common_obj, struct tfe_cmsg * cmsg, enum tfe_cmsg_tlv_type type, const char *keyword) +{ + uuid_t opt_val; + char session_uuid[UUID_STRING_SIZE]={0}; + uint16_t opt_out_size = 0; + + int ret=tfe_cmsg_get_value(cmsg, type, (unsigned char *)opt_val, sizeof(opt_val), &opt_out_size); + if (ret == 0 && opt_out_size > 0) + { + uuid_unparse(opt_val,session_uuid); + cJSON_AddStringToObject(common_obj, keyword, session_uuid); + } + return 0; +} + size_t tfe_get_c2s_byte_num(const struct tfe_stream *stream, size_t c2s_byte_num) { size_t rewrite_c2s_byte_num = 0; @@ -187,7 +202,7 @@ int tfe_upload_http_body(struct proxy_logger* handle, cJSON *common_obj, struct } else { - get_http_body_uuid(uuid); + uuidv4_generate(uuid); datalen=file_bucket_upload_once(handle, uuid, http_body); if(datalen>0) { @@ -234,15 +249,19 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg) return 0; } + char log_uuid[40] = {0}; + uuidv4_generate(log_uuid); + common_obj=cJSON_CreateObject(); gettimeofday(&cur_time, NULL); cJSON_AddNumberToObject(common_obj, "start_timestamp_ms", get_time_ms(http->start_time)); cJSON_AddNumberToObject(common_obj, "end_timestamp_ms", get_time_ms(cur_time)); + cJSON_AddStringToObject(common_obj, "log_uuid", log_uuid); struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(log_msg->stream); if (cmsg != NULL) { - tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_id"); + tfe_get_uuid_by_cmsg(common_obj, cmsg, TFE_CMSG_STREAM_TRACE_ID, "session_uuid"); tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_SUB_ID, "subscriber_id"); tfe_get_string_by_cmsg(common_obj, cmsg, TFE_CMSG_SRC_IMSI_STR, "imsi"); diff --git a/resource/pangu/pangu_http.json b/resource/pangu/pangu_http.json index 9e7c25a..c936b90 100644 --- a/resource/pangu/pangu_http.json +++ b/resource/pangu/pangu_http.json @@ -47,7 +47,7 @@ "is_valid": "yes", "and_conditions": [ { - "filed_name": "SERVER_FQDN", + "filed_name": "DESTINATION_FQDN", "objects": [ { "items": [