summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2021-10-06 16:29:24 +0800
committerliuxueli <[email protected]>2021-10-06 16:29:24 +0800
commitb415f15aab811740bdf90edf27fc15333707ce2c (patch)
tree384ded0d8573392080b5b7777ad89c7eecd9f093
parenteade71227df822fa22e706cbd675f5d47ff855ed (diff)
TSG-7982: 新增公共日志字段common_device_tag
-rw-r--r--bin/tsg_log_field.conf3
-rw-r--r--src/tsg_entry.h1
-rw-r--r--src/tsg_rule.cpp5
-rw-r--r--src/tsg_send_log.cpp12
-rw-r--r--src/tsg_send_log_internal.h2
5 files changed, 19 insertions, 4 deletions
diff --git a/bin/tsg_log_field.conf b/bin/tsg_log_field.conf
index 453ede9..7764b26 100644
--- a/bin/tsg_log_field.conf
+++ b/bin/tsg_log_field.conf
@@ -96,4 +96,5 @@ LONG http_action_file_size 83
STRING common_link_info_c2s 84
STRING common_link_info_s2c 85
STRING quic_version 86
-STRING quic_user_agent 87 \ No newline at end of file
+STRING quic_user_agent 87
+STRING common_device_tag 88 \ No newline at end of file
diff --git a/src/tsg_entry.h b/src/tsg_entry.h
index 02ac0a9..1ae650e 100644
--- a/src/tsg_entry.h
+++ b/src/tsg_entry.h
@@ -250,6 +250,7 @@ typedef struct tsg_para
char log_path[MAX_DOMAIN_LEN/8];
char device_id_command[MAX_DOMAIN_LEN/8];
char data_center[_MAX_TABLE_NAME_LEN];
+ char device_tag[MAX_DOMAIN_LEN/2];
char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN];
void *logger;
void *maat_logger;
diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp
index 581fa4c..99392ad 100644
--- a/src/tsg_rule.cpp
+++ b/src/tsg_rule.cpp
@@ -1391,6 +1391,11 @@ static Maat_feather_t init_maat_feather(const char* conffile, char* instance_nam
MESA_load_profile_string_def(conffile, "MAAT", "ACCEPT_TAGS", effective_flag, sizeof(effective_flag),"");
}
+ if(strlen(g_tsg_para.device_tag)==0 && strlen(effective_flag)>0)
+ {
+ memcpy(g_tsg_para.device_tag, effective_flag, MIN(strlen(effective_flag), sizeof(g_tsg_para.device_tag)-1));
+ }
+
if(strlen(g_tsg_para.data_center)==0 && strlen(effective_flag)>0)
{
MESA_load_profile_string_def(conffile, module, "EFFECTIVE_TAG_KEY", effective_tag_key, sizeof(effective_tag_key),"data_center");
diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp
index e4a63eb..c915029 100644
--- a/src/tsg_send_log.cpp
+++ b/src/tsg_send_log.cpp
@@ -1375,7 +1375,8 @@ struct tsg_log_instance_t *tsg_sendlog_init(const char *conffile)
MESA_load_profile_int_def(conffile, "TSG_LOG", "LOG_LEVEL",&(_instance->level), 30);
MESA_load_profile_string_def(conffile, "TSG_LOG", "LOG_PATH", _instance->log_path, sizeof(_instance->log_path), "./tsglog/tsglog");
- MESA_load_profile_int_def(conffile, "TSG_LOG", "SEND_USER_REGION",&(_instance->send_user_region), 0);
+ MESA_load_profile_int_def(conffile, "TSG_LOG", "SEND_USER_REGION", &(_instance->send_user_region), 0);
+ MESA_load_profile_int_def(conffile, "TSG_LOG", "SEND_DATA_CENTER_SWITCH", &(_instance->send_data_center), 0);
MESA_load_profile_int_def(conffile, "TSG_LOG", "APP_ID_TYPE", &(_instance->app_id_type), 1); //0: int, 1: string
MESA_load_profile_string_def(conffile, "TSG_LOG", "L7_UNKNOWN_NAME", _instance->l7_unknown_name, sizeof(_instance->l7_unknown_name), "UNCATEGORIZED");
@@ -1537,11 +1538,16 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
TLD_append(_handle, _instance->id2field[LOG_COMMON_DEVICE_ID].name, (void *)(g_tsg_para.device_sn), TLD_TYPE_STRING);
}
- if(strlen(g_tsg_para.data_center)>0)
+ if(strlen(g_tsg_para.data_center)>0 && _instance->send_data_center==1)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_DATA_CENTER].name, (void *)(g_tsg_para.data_center), TLD_TYPE_STRING);
}
-
+
+ if(strlen(g_tsg_para.device_tag)>0)
+ {
+ TLD_append(_handle, _instance->id2field[LOG_COMMON_DEVICE_TAG].name, (void *)(g_tsg_para.device_tag), TLD_TYPE_STRING);
+ }
+
for(i=0;i<log_msg->result_num; i++)
{
if(is_multi_hit_same_policy(&(log_msg->result[i]), policy_id, &repeat_cnt))
diff --git a/src/tsg_send_log_internal.h b/src/tsg_send_log_internal.h
index bfbbe0d..5c2cd41 100644
--- a/src/tsg_send_log_internal.h
+++ b/src/tsg_send_log_internal.h
@@ -113,6 +113,7 @@ typedef enum _tsg_log_field_id
LOG_COMMON_LINK_INFO_S2C,
LOG_QUIC_VERSION,
LOG_QUIC_USER_AGENT,
+ LOG_COMMON_DEVICE_TAG,
LOG_COMMON_MAX
}tsg_log_field_id_t;
@@ -130,6 +131,7 @@ struct tsg_log_instance_t
int max_service;
int app_id_type;
int send_user_region;
+ int send_data_center;
int recovery_interval;
int session_attribute_project_id;
int tcp_flow_project_id;