summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengweihao <[email protected]>2022-09-23 15:34:50 +0800
committerfengweihao <[email protected]>2022-09-23 15:34:50 +0800
commitd4dc6394acc4b137f9a2b0d368ffd4b9a9046a83 (patch)
tree52c612b6c4b4946f1070cc2361099ef64824dd72
parent69f76bbf6079ad79e438a9c417f3544dadf484d9 (diff)
TSG-12005 Proxy日志增加common_vsys_id字段v4.6.19-20220923
TSG-12080 中间证书缓存Kafka输出Json增加vsys_id字段
-rw-r--r--common/include/tfe_kafka_logger.h1
-rw-r--r--common/src/tfe_resource.cpp5
-rw-r--r--conf/tfe/tfe.conf2
-rw-r--r--platform/src/ssl_fetch_cert.cpp9
-rw-r--r--plugin/business/doh/src/logger.cpp1
-rw-r--r--plugin/business/tsg-http/src/tsg_logger.cpp1
6 files changed, 17 insertions, 2 deletions
diff --git a/common/include/tfe_kafka_logger.h b/common/include/tfe_kafka_logger.h
index 3e5e609..316dfe4 100644
--- a/common/include/tfe_kafka_logger.h
+++ b/common/include/tfe_kafka_logger.h
@@ -12,6 +12,7 @@ extern "C"
typedef struct tfe_kafka_logger_s
{
int enable;
+ int vsys_id;
unsigned int local_ip_num;
char local_ip_str[TFE_SYMBOL_MAX];
diff --git a/common/src/tfe_resource.cpp b/common/src/tfe_resource.cpp
index 2940e9f..49241b8 100644
--- a/common/src/tfe_resource.cpp
+++ b/common/src/tfe_resource.cpp
@@ -155,7 +155,7 @@ error_out:
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 brokerlist[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;
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, "KAFKA_BROKERLIST", brokerlist, sizeof(brokerlist), "");
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.");
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 vsystem id : %d", vsystem_id);
TFE_LOG_INFO(logger, "tfe kafka topic : %s", topic_name);
TFE_LOG_INFO(logger, "tfe kafka brokerlist : %s", brokerlist);
diff --git a/conf/tfe/tfe.conf b/conf/tfe/tfe.conf
index 187b565..5e5960a 100644
--- a/conf/tfe/tfe.conf
+++ b/conf/tfe/tfe.conf
@@ -96,6 +96,7 @@ key_log_file=log/sslkeylog.log
# mid cert cache
mc_cache_enable=1
+mc_vsystem_id=1
mc_cache_eth=eth0
mc_cache_broker_list=192.168.40.224:9092
mc_cache_topic=PXY-EXCH-INTERMEDIA-CERT
@@ -167,6 +168,7 @@ stat_file=log/traffic_mirror.status
[kafka]
enable=1
+vsystem_id=1
NIC_NAME=enp2s0
kafka_brokerlist=192.168.40.224:9092
kafka_topic=PROXY-EVENT
diff --git a/platform/src/ssl_fetch_cert.cpp b/platform/src/ssl_fetch_cert.cpp
index b88fb5f..1d5d5c2 100644
--- a/platform/src/ssl_fetch_cert.cpp
+++ b/platform/src/ssl_fetch_cert.cpp
@@ -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 enable = 0;
+ int enable = 0, vsystem_id = 0;
char nic_name[TFE_SYMBOL_MAX] = {0};
char broker_list[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};
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_topic", topic_name, sizeof(topic_name), "PXY-EXCH-INTERMEDIA-CERT");
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:
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)
+ {
+ g_kafka_logger->vsys_id=vsystem_id;
return 0;
+ }
else
+ {
return -1;
+ }
}
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();
cJSON_AddStringToObject(obj, "sni", sni);
cJSON_AddStringToObject(obj, "fingerprint", fingerprint);
+ cJSON_AddNumberToObject(obj, "vsys_id", g_kafka_logger->vsys_id);
cJSON_AddStringToObject(obj, "cert", cert);
cJSON_AddStringToObject(obj, "tfe_ip", g_kafka_logger->local_ip_str);
dup = cJSON_Duplicate(obj, 1);
diff --git a/plugin/business/doh/src/logger.cpp b/plugin/business/doh/src/logger.cpp
index d54edf8..f0632ed 100644
--- a/plugin/business/doh/src/logger.cpp
+++ b/plugin/business/doh/src/logger.cpp
@@ -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_stream_dir", 3); //1:c2s, 2:s2c, 3:double
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_AddStringToObject(common_obj, "common_device_id", handle->device_id);
cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num);
diff --git a/plugin/business/tsg-http/src/tsg_logger.cpp b/plugin/business/tsg-http/src/tsg_logger.cpp
index 2d0b5aa..3564b95 100644
--- a/plugin/business/tsg-http/src/tsg_logger.cpp
+++ b/plugin/business/tsg-http/src/tsg_logger.cpp
@@ -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_stream_dir", 3); //1:c2s, 2:s2c, 3:double
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_AddStringToObject(common_obj, "common_device_id", handle->device_id);
cJSON_AddNumberToObject(common_obj, "common_c2s_byte_num", c2s_byte_num);