TSG-12005 Proxy日志增加common_vsys_id字段

TSG-12080 中间证书缓存Kafka输出Json增加vsys_id字段
This commit is contained in:
fengweihao
2022-09-23 15:34:50 +08:00
parent 69f76bbf60
commit d4dc6394ac
6 changed files with 17 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ extern "C"
typedef struct tfe_kafka_logger_s typedef struct tfe_kafka_logger_s
{ {
int enable; int enable;
int vsys_id;
unsigned int local_ip_num; unsigned int local_ip_num;
char local_ip_str[TFE_SYMBOL_MAX]; char local_ip_str[TFE_SYMBOL_MAX];

View File

@@ -155,7 +155,7 @@ error_out:
static tfe_kafka_logger_t *create_kafka_logger(const char *profile, const char *section, void *logger) static tfe_kafka_logger_t *create_kafka_logger(const char *profile, const char *section, void *logger)
{ {
int enable = 0; int enable = 0, vsystem_id = 0;
char nic_name[TFE_SYMBOL_MAX] = {0}; char nic_name[TFE_SYMBOL_MAX] = {0};
char brokerlist[TFE_STRING_MAX] = {0}; char brokerlist[TFE_STRING_MAX] = {0};
char topic_name[TFE_STRING_MAX] = {0}; char topic_name[TFE_STRING_MAX] = {0};
@@ -164,6 +164,7 @@ static tfe_kafka_logger_t *create_kafka_logger(const char *profile, const char *
tfe_kafka_logger_t *kafka_logger = NULL; tfe_kafka_logger_t *kafka_logger = NULL;
MESA_load_profile_int_def(profile, section, "enable", &enable, 1); MESA_load_profile_int_def(profile, section, "enable", &enable, 1);
MESA_load_profile_int_def(profile, section, "VSYSTEM_ID", &vsystem_id, 1);
MESA_load_profile_string_def(profile, section, "NIC_NAME", nic_name, sizeof(nic_name), "eth0"); MESA_load_profile_string_def(profile, section, "NIC_NAME", nic_name, sizeof(nic_name), "eth0");
MESA_load_profile_string_def(profile, section, "KAFKA_BROKERLIST", brokerlist, sizeof(brokerlist), ""); MESA_load_profile_string_def(profile, section, "KAFKA_BROKERLIST", brokerlist, sizeof(brokerlist), "");
MESA_load_profile_string_def(profile, section, "KAFKA_TOPIC", topic_name, sizeof(topic_name), "POLICY-EVENT-LOG"); MESA_load_profile_string_def(profile, section, "KAFKA_TOPIC", topic_name, sizeof(topic_name), "POLICY-EVENT-LOG");
@@ -182,8 +183,10 @@ static tfe_kafka_logger_t *create_kafka_logger(const char *profile, const char *
TFE_LOG_ERROR(logger, "tfe kafka init failed, error to create kafka logger."); TFE_LOG_ERROR(logger, "tfe kafka init failed, error to create kafka logger.");
return NULL; return NULL;
} }
kafka_logger->vsys_id=vsystem_id;
TFE_LOG_INFO(logger, "tfe kafka logger : %s", enable ? "ENABLE" : "DISABLE"); TFE_LOG_INFO(logger, "tfe kafka logger : %s", enable ? "ENABLE" : "DISABLE");
TFE_LOG_INFO(logger, "tfe kafka vsystem id : %d", vsystem_id);
TFE_LOG_INFO(logger, "tfe kafka topic : %s", topic_name); TFE_LOG_INFO(logger, "tfe kafka topic : %s", topic_name);
TFE_LOG_INFO(logger, "tfe kafka brokerlist : %s", brokerlist); TFE_LOG_INFO(logger, "tfe kafka brokerlist : %s", brokerlist);

View File

@@ -96,6 +96,7 @@ key_log_file=log/sslkeylog.log
# mid cert cache # mid cert cache
mc_cache_enable=1 mc_cache_enable=1
mc_vsystem_id=1
mc_cache_eth=eth0 mc_cache_eth=eth0
mc_cache_broker_list=192.168.40.224:9092 mc_cache_broker_list=192.168.40.224:9092
mc_cache_topic=PXY-EXCH-INTERMEDIA-CERT mc_cache_topic=PXY-EXCH-INTERMEDIA-CERT
@@ -167,6 +168,7 @@ stat_file=log/traffic_mirror.status
[kafka] [kafka]
enable=1 enable=1
vsystem_id=1
NIC_NAME=enp2s0 NIC_NAME=enp2s0
kafka_brokerlist=192.168.40.224:9092 kafka_brokerlist=192.168.40.224:9092
kafka_topic=PROXY-EVENT kafka_topic=PROXY-EVENT

View File

@@ -44,7 +44,7 @@ void ssl_mid_cert_kafka_logger_destory(void)
int ssl_mid_cert_kafka_logger_create(const char *profile, const char *section) int ssl_mid_cert_kafka_logger_create(const char *profile, const char *section)
{ {
int enable = 0; int enable = 0, vsystem_id = 0;
char nic_name[TFE_SYMBOL_MAX] = {0}; char nic_name[TFE_SYMBOL_MAX] = {0};
char broker_list[TFE_SYMBOL_MAX] = {0}; char broker_list[TFE_SYMBOL_MAX] = {0};
char topic_name[TFE_SYMBOL_MAX] = {0}; char topic_name[TFE_SYMBOL_MAX] = {0};
@@ -52,6 +52,7 @@ int ssl_mid_cert_kafka_logger_create(const char *profile, const char *section)
char sasl_passwd[TFE_STRING_MAX] = {0}; char sasl_passwd[TFE_STRING_MAX] = {0};
MESA_load_profile_int_def(profile, section, "mc_cache_enable", &enable, 0); MESA_load_profile_int_def(profile, section, "mc_cache_enable", &enable, 0);
MESA_load_profile_int_def(profile, section, "mc_vsystem_id", &vsystem_id, 1);
MESA_load_profile_string_def(profile, section, "mc_cache_eth", nic_name, sizeof(nic_name), "eth0"); MESA_load_profile_string_def(profile, section, "mc_cache_eth", nic_name, sizeof(nic_name), "eth0");
MESA_load_profile_string_def(profile, section, "mc_cache_topic", topic_name, sizeof(topic_name), "PXY-EXCH-INTERMEDIA-CERT"); MESA_load_profile_string_def(profile, section, "mc_cache_topic", topic_name, sizeof(topic_name), "PXY-EXCH-INTERMEDIA-CERT");
MESA_load_profile_string_def(profile, section, "SASL_USERNAME", sasl_username, sizeof(sasl_username), ""); MESA_load_profile_string_def(profile, section, "SASL_USERNAME", sasl_username, sizeof(sasl_username), "");
@@ -67,9 +68,14 @@ int ssl_mid_cert_kafka_logger_create(const char *profile, const char *section)
skip: skip:
g_kafka_logger = tfe_kafka_logger_create(enable, nic_name, broker_list, topic_name, sasl_username, sasl_passwd, g_default_logger); g_kafka_logger = tfe_kafka_logger_create(enable, nic_name, broker_list, topic_name, sasl_username, sasl_passwd, g_default_logger);
if (g_kafka_logger) if (g_kafka_logger)
{
g_kafka_logger->vsys_id=vsystem_id;
return 0; return 0;
}
else else
{
return -1; return -1;
}
} }
static void ssl_mid_cert_kafka_logger_send(const char *sni, const char *fingerprint, const char *cert) static void ssl_mid_cert_kafka_logger_send(const char *sni, const char *fingerprint, const char *cert)
@@ -85,6 +91,7 @@ static void ssl_mid_cert_kafka_logger_send(const char *sni, const char *fingerpr
obj = cJSON_CreateObject(); obj = cJSON_CreateObject();
cJSON_AddStringToObject(obj, "sni", sni); cJSON_AddStringToObject(obj, "sni", sni);
cJSON_AddStringToObject(obj, "fingerprint", fingerprint); cJSON_AddStringToObject(obj, "fingerprint", fingerprint);
cJSON_AddNumberToObject(obj, "vsys_id", g_kafka_logger->vsys_id);
cJSON_AddStringToObject(obj, "cert", cert); cJSON_AddStringToObject(obj, "cert", cert);
cJSON_AddStringToObject(obj, "tfe_ip", g_kafka_logger->local_ip_str); cJSON_AddStringToObject(obj, "tfe_ip", g_kafka_logger->local_ip_str);
dup = cJSON_Duplicate(obj, 1); dup = cJSON_Duplicate(obj, 1);

View File

@@ -400,6 +400,7 @@ int doh_send_log(struct doh_conf *handle, const struct tfe_http_session *http, c
cJSON_AddNumberToObject(common_obj, "common_link_id", 0); cJSON_AddNumberToObject(common_obj, "common_link_id", 0);
cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double 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); cJSON_AddStringToObject(common_obj, "common_sled_ip", handle->kafka_logger->local_ip_str);
cJSON_AddNumberToObject(common_obj, "common_vsys_id", handle->kafka_logger->vsys_id);
cJSON_AddNumberToObject(common_obj, "common_entrance_id", handle->entry_id); cJSON_AddNumberToObject(common_obj, "common_entrance_id", handle->entry_id);
cJSON_AddStringToObject(common_obj, "common_device_id", handle->device_id); cJSON_AddStringToObject(common_obj, "common_device_id", handle->device_id);
cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num); cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num);

View File

@@ -224,6 +224,7 @@ int proxy_send_log(struct proxy_logger* handle, const struct proxy_log* log_msg)
cJSON_AddNumberToObject(common_obj, "common_link_id", 0); cJSON_AddNumberToObject(common_obj, "common_link_id", 0);
cJSON_AddNumberToObject(common_obj, "common_stream_dir", 3); //1:c2s, 2:s2c, 3:double 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); cJSON_AddStringToObject(common_obj, "common_sled_ip", handle->kafka_logger->local_ip_str);
cJSON_AddNumberToObject(common_obj, "common_vsys_id", handle->kafka_logger->vsys_id);
cJSON_AddNumberToObject(common_obj, "common_entrance_id", handle->entry_id); cJSON_AddNumberToObject(common_obj, "common_entrance_id", handle->entry_id);
cJSON_AddStringToObject(common_obj, "common_device_id", handle->device_id); cJSON_AddStringToObject(common_obj, "common_device_id", handle->device_id);
cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num); cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num);