新增common_data_center日志字段

This commit is contained in:
liuxueli
2020-09-23 16:51:25 +08:00
parent d1a6f00fba
commit f1150118de
5 changed files with 64 additions and 6 deletions

View File

@@ -49,3 +49,4 @@ STRING common_clinet_location 41
STRING common_server_location 42 STRING common_server_location 42
STRING quic_sni 43 STRING quic_sni 43
STRING ssl_ja3_fingerprint 44 STRING ssl_ja3_fingerprint 44
STRING common_data_center 45

View File

@@ -97,6 +97,7 @@ typedef struct _tsg_para
int proto_flag; //tsg_protocol_t int proto_flag; //tsg_protocol_t
int fs2_field_id[TSG_FS2_MAX]; int fs2_field_id[TSG_FS2_MAX];
char device_sn[MAX_DOAMIN_LEN/8]; char device_sn[MAX_DOAMIN_LEN/8];
char data_center[_MAX_TABLE_NAME_LEN];
char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN]; char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN];
void *logger; void *logger;
screen_stat_handle_t fs2_handle; screen_stat_handle_t fs2_handle;

View File

@@ -6,7 +6,7 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <MESA/stream.h> #include <MESA/stream.h>
#include <MESA/MESA_prof_load.h> #include <MESA/MESA_prof_load.h>
#include "MESA/cJSON.h"
#include "MESA/MESA_handle_logger.h" #include "MESA/MESA_handle_logger.h"
#include "Maat_rule.h" #include "Maat_rule.h"
#include "Maat_command.h" #include "Maat_command.h"
@@ -124,6 +124,39 @@ static int proto_str2id(tsg_protocol_t proto)
return 0; return 0;
} }
static int get_data_center(char *accept_tag, char *data_center, int data_center_len)
{
int i=0,len;
cJSON *object=cJSON_Parse(accept_tag);
if(object!=NULL)
{
cJSON *array=cJSON_GetObjectItem(object, "tags");
if(array!=NULL)
{
for(i=0; i<cJSON_GetArraySize(array); i++)
{
cJSON *item=cJSON_GetArrayItem(array, i);
if(item!=NULL)
{
cJSON *tag_item=cJSON_GetObjectItem(item, "tag");
if(tag_item!=NULL && tag_item->valuestring!=NULL && (memcmp("device_id", tag_item->valuestring, strlen("device_id")))==0)
{
cJSON *v_item=cJSON_GetObjectItem(item, "value");
if(v_item!=NULL && v_item->valuestring!=NULL)
{
len=strlen(v_item->valuestring);
memcpy(data_center, v_item->valuestring, (len>data_center_len-1 ? data_center_len-1 : len));
}
return 1;
}
}
}
}
}
return 0;
}
static void eliminate_default_value(char *value) static void eliminate_default_value(char *value)
{ {
if(value!=NULL && (memcmp(value, "null", 4))==0) if(value!=NULL && (memcmp(value, "null", 4))==0)
@@ -419,7 +452,21 @@ static Maat_feather_t init_maat_feather(const char* conffile, char* instance_nam
memset(effective_flag, 0, sizeof(effective_flag)); memset(effective_flag, 0, sizeof(effective_flag));
MESA_load_profile_string_def(conffile, module, "EFFECTIVE_RANGE_FILE", effective_range_filename, sizeof(effective_range_filename),"./tsgconf/maat.conf"); MESA_load_profile_string_def(conffile, module, "EFFECTIVE_RANGE_FILE", effective_range_filename, sizeof(effective_range_filename),"./tsgconf/maat.conf");
if(strlen(effective_range_filename)>0)
{
MESA_load_profile_string_def(effective_range_filename, "MAAT", "ACCEPT_TAGS", effective_flag, sizeof(effective_flag),"");
}
if(strlen(effective_flag)==0)
{
MESA_load_profile_string_def(conffile, "MAAT", "ACCEPT_TAGS", effective_flag, sizeof(effective_flag),""); MESA_load_profile_string_def(conffile, "MAAT", "ACCEPT_TAGS", effective_flag, sizeof(effective_flag),"");
}
if(strlen(g_tsg_para.data_center)==0 && strlen(effective_flag)>0)
{
get_data_center(effective_flag, g_tsg_para.data_center, sizeof(g_tsg_para.data_center));
}
MESA_load_profile_int_def(conffile, module,"MAAT_MODE", &(maat_mode),0); MESA_load_profile_int_def(conffile, module,"MAAT_MODE", &(maat_mode),0);
MESA_load_profile_int_def(conffile, module,"STAT_SWITCH", &(maat_stat_on),1); MESA_load_profile_int_def(conffile, module,"STAT_SWITCH", &(maat_stat_on),1);
@@ -515,7 +562,7 @@ int tsg_rule_init(const char* conffile, void *logger)
MESA_load_profile_int_def(conffile, "MAAT","APP_ID_TABLE_TYPE", &g_tsg_para.app_id_table_type, 1); MESA_load_profile_int_def(conffile, "MAAT","APP_ID_TABLE_TYPE", &g_tsg_para.app_id_table_type, 1);
MESA_load_profile_string_def(conffile, "MAAT", "PROFILE", maat_conffile, sizeof(maat_conffile), "./tsgconf/maat_profile.conf"); MESA_load_profile_string_def(conffile, "MAAT", "PROFILE", maat_conffile, sizeof(maat_conffile), "./tsgconf/maat.conf");
MESA_load_profile_string_def(conffile, "MAAT", "IP_ADDR_TABLE", g_tsg_para.table_name[TABLE_IP_ADDR], _MAX_TABLE_NAME_LEN, "TSG_SECURITY_ADDR"); MESA_load_profile_string_def(conffile, "MAAT", "IP_ADDR_TABLE", g_tsg_para.table_name[TABLE_IP_ADDR], _MAX_TABLE_NAME_LEN, "TSG_SECURITY_ADDR");
MESA_load_profile_string_def(conffile, "MAAT", "SUBSCRIBER_ID_TABLE", g_tsg_para.table_name[TABLE_SUBSCRIBER_ID], _MAX_TABLE_NAME_LEN, "TSG_OBJ_SUBSCRIBER_ID"); MESA_load_profile_string_def(conffile, "MAAT", "SUBSCRIBER_ID_TABLE", g_tsg_para.table_name[TABLE_SUBSCRIBER_ID], _MAX_TABLE_NAME_LEN, "TSG_OBJ_SUBSCRIBER_ID");
MESA_load_profile_string_def(conffile, "MAAT", "APP_ID_TABLE", g_tsg_para.table_name[TABLE_APP_ID], _MAX_TABLE_NAME_LEN, "TSG_OBJ_APP_ID"); MESA_load_profile_string_def(conffile, "MAAT", "APP_ID_TABLE", g_tsg_para.table_name[TABLE_APP_ID], _MAX_TABLE_NAME_LEN, "TSG_OBJ_APP_ID");

View File

@@ -614,7 +614,15 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
TLD_append_streaminfo(instance, handle, log_msg->a_stream); TLD_append_streaminfo(instance, handle, log_msg->a_stream);
TLD_append(_handle, _instance->id2field[LOG_COMMON_SLED_IP].name, (void *)(_instance->local_ip_str), TLD_TYPE_STRING); TLD_append(_handle, _instance->id2field[LOG_COMMON_SLED_IP].name, (void *)(_instance->local_ip_str), TLD_TYPE_STRING);
if(strlen(g_tsg_para.device_sn)>0)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_DEVICE_ID].name, (void *)(g_tsg_para.device_sn), TLD_TYPE_STRING); 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)
{
TLD_append(_handle, _instance->id2field[LOG_COMMON_DATA_CENTER].name, (void *)(g_tsg_para.data_center), TLD_TYPE_STRING);
}
for(i=0;i<log_msg->result_num; i++) for(i=0;i<log_msg->result_num; i++)
{ {

View File

@@ -69,6 +69,7 @@ typedef enum _tsg_log_field_id
LOG_COMMON_SERVER_LOCATION, LOG_COMMON_SERVER_LOCATION,
LOG_QUIC_SNI, LOG_QUIC_SNI,
LOG_SSL_JA3_FINGERPRINT, LOG_SSL_JA3_FINGERPRINT,
LOG_COMMON_DATA_CENTER,
LOG_COMMON_MAX LOG_COMMON_MAX
}tsg_log_field_id_t; }tsg_log_field_id_t;