diff options
| author | fengweihao <[email protected]> | 2020-12-04 18:20:36 +0800 |
|---|---|---|
| committer | 卢文朋 <[email protected]> | 2020-12-15 12:56:07 +0800 |
| commit | 17bbb543431bf9842e5655fe05d150d5b85fd7e2 (patch) | |
| tree | 6815514739104f5e20c0f369b99549bc40935378 | |
| parent | 65ca1cf6793cd032e549ac312c08e1e50869b96d (diff) | |
TSG-4524 panggu和doh日志字段设置common_directionv4.3.26-202011
| -rw-r--r-- | common/include/tfe_cmsg.h | 1 | ||||
| -rw-r--r-- | plugin/business/doh/src/logger.cpp | 8 | ||||
| -rw-r--r-- | plugin/business/pangu-http/src/pangu_logger.cpp | 7 |
3 files changed, 13 insertions, 3 deletions
diff --git a/common/include/tfe_cmsg.h b/common/include/tfe_cmsg.h index e8b4b8b..df46091 100644 --- a/common/include/tfe_cmsg.h +++ b/common/include/tfe_cmsg.h @@ -81,6 +81,7 @@ enum tfe_cmsg_tlv_type TFE_CMSG_FQDN_CAT_ID_NUM, // unsigned int TFE_CMSG_FQDN_CAT_ID_VAL, // max size 8 * sizeof(unsigned int) + TFE_CMSG_COMMON_DIRECTION, /* Add new cmsg here */ /* Add new cmsg here */ /* Add new cmsg here */ diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp index 95dbe30..a5cc0fb 100644 --- a/plugin/business/doh/src/logger.cpp +++ b/plugin/business/doh/src/logger.cpp @@ -334,7 +334,7 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c cJSON_AddStringToObject(common_obj, "common_schema_type", "DoH"); char opt_val[24] = { 0 }; - uint16_t opt_out_size; + uint16_t opt_out_size; unsigned int common_direction=0; struct tfe_cmsg *cmsg = tfe_stream_get0_cmsg(stream); if (cmsg != NULL) { @@ -343,6 +343,11 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c { cJSON_AddNumberToObject(common_obj, "common_stream_trace_id", atoll(opt_val)); } + ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_COMMON_DIRECTION, (unsigned char *)&common_direction, sizeof(common_direction), &opt_out_size); + if (ret==0) + { + cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息 + } } if (http->req) @@ -392,7 +397,6 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c tfe_stream_info_get(stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num)); tfe_stream_info_get(stream, INFO_FROM_UPSTREAM_RX_OFFSET, &s2c_byte_num, sizeof(s2c_byte_num)); - cJSON_AddNumberToObject(common_obj, "common_direction", 0); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息 cJSON_AddNumberToObject(common_obj, "common_link_id", 0); cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double cJSON_AddStringToObject(common_obj, "common_sled_ip", handle->kafka_logger->local_ip_str); diff --git a/plugin/business/pangu-http/src/pangu_logger.cpp b/plugin/business/pangu-http/src/pangu_logger.cpp index 86efcab..70d2dd5 100644 --- a/plugin/business/pangu-http/src/pangu_logger.cpp +++ b/plugin/business/pangu-http/src/pangu_logger.cpp @@ -125,6 +125,7 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) cJSON_AddStringToObject(common_obj, "http_version", app_proto[http->major_version]); cJSON_AddStringToObject(common_obj, "common_schema_type", "HTTP"); + unsigned int common_direction=0; char opt_val[24] = { 0 }; uint16_t opt_out_size; struct tfe_cmsg * cmsg = tfe_stream_get0_cmsg(log_msg->stream); if (cmsg!=NULL) @@ -134,6 +135,11 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) { cJSON_AddNumberToObject(common_obj, "common_stream_trace_id", atoll(opt_val)); } + ret = tfe_cmsg_get_value(cmsg, TFE_CMSG_COMMON_DIRECTION, (unsigned char *)&common_direction, sizeof(common_direction), &opt_out_size); + if (ret==0) + { + cJSON_AddNumberToObject(common_obj, "common_direction", common_direction); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息 + } } if (http->req) @@ -183,7 +189,6 @@ int pangu_send_log(struct pangu_logger* handle, const struct pangu_log* log_msg) tfe_stream_info_get(log_msg->stream, INFO_FROM_DOWNSTREAM_RX_OFFSET, &c2s_byte_num, sizeof(c2s_byte_num)); tfe_stream_info_get(log_msg->stream, INFO_FROM_UPSTREAM_RX_OFFSET, &s2c_byte_num, sizeof(s2c_byte_num)); - cJSON_AddNumberToObject(common_obj, "common_direction", 0); //0:域内->域外,1:域外->域内,描述的是CLIENT_IP信息 cJSON_AddNumberToObject(common_obj, "common_link_id", 0); cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double cJSON_AddStringToObject(common_obj, "common_sled_ip", handle->kafka_logger->local_ip_str); |
