summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-08-19 19:14:42 +0800
committeryangwei <[email protected]>2024-08-19 19:14:42 +0800
commit302f64435ea2b1a4e987263e04449c592274085f (patch)
treea86ccafbe4bc896363337b0c940da0f6b86e0530
parente68b8a857c20a6f5d32f8e65dbe4db1aaaf40541 (diff)
🐞 fix(remove dependency for MESA prof_load and logger): define in source code temporarily
-rw-r--r--decoders/glimpse_detector/CMakeLists.txt2
-rw-r--r--decoders/glimpse_detector/app_l7_protocol.cpp53
-rw-r--r--decoders/glimpse_detector/openvpn_identify.cpp1
-rw-r--r--decoders/glimpse_detector/quic_identify.cpp2
-rw-r--r--test/glimpse_detector/gtest_glimpse_detector_main.cpp14
5 files changed, 38 insertions, 34 deletions
diff --git a/decoders/glimpse_detector/CMakeLists.txt b/decoders/glimpse_detector/CMakeLists.txt
index 9a99f69..55f2646 100644
--- a/decoders/glimpse_detector/CMakeLists.txt
+++ b/decoders/glimpse_detector/CMakeLists.txt
@@ -4,7 +4,7 @@ add_subdirectory(libprotoident)
add_library(glimpse_detector app_l7_protocol.cpp quic_identify.cpp openvpn_identify.cpp)
target_include_directories(glimpse_detector PUBLIC ${CMAKE_SOURCE_DIR}/deps/)
-target_link_libraries(glimpse_detector libprotoident MESA_handle_logger MESA_prof_load)
+target_link_libraries(glimpse_detector libprotoident)
set_target_properties(glimpse_detector PROPERTIES LINK_FLAGS
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.map")
diff --git a/decoders/glimpse_detector/app_l7_protocol.cpp b/decoders/glimpse_detector/app_l7_protocol.cpp
index cdf2fb5..bd1f995 100644
--- a/decoders/glimpse_detector/app_l7_protocol.cpp
+++ b/decoders/glimpse_detector/app_l7_protocol.cpp
@@ -13,8 +13,8 @@
#include "uthash/uthash.h"
-#include <MESA/MESA_prof_load.h>
-#include <MESA/MESA_handle_logger.h>
+//#include <MESA/MESA_prof_load.h>
+//#include <MESA/MESA_handle_logger.h>
#include "stellar/utils.h"
@@ -376,7 +376,7 @@ static int l7_protocol_mapper(struct glimpse_detector_schema *g_app_proto_para,
char type_name[32]={0};
struct l7_protocol_hash *name2lpi=NULL;
struct l7_protocol_hash *l7_protocol=NULL;
- struct l7_protocol_hash *out=NULL, *tmp=NULL;
+ struct l7_protocol_hash *out=NULL;
fp=fopen(filename, "r");
if(fp==NULL)
@@ -406,7 +406,7 @@ static int l7_protocol_mapper(struct glimpse_detector_schema *g_app_proto_para,
HASH_FIND(hh, name2lpi, l7_protocol->name, strlen(l7_protocol->name), out);
if(out==NULL)
{
- MESA_handle_runtime_log(g_app_proto_para->logger, RLOG_LV_FATAL, "INIT_HASH", "Protocol %s identified without registered LPI ID", l7_protocol->name);
+ //MESA_handle_runtime_log(g_app_proto_para->logger, RLOG_LV_FATAL, "INIT_HASH", "Protocol %s identified without registered LPI ID", l7_protocol->name);
free(l7_protocol);
continue;
}
@@ -464,6 +464,7 @@ static int l7_protocol_mapper(struct glimpse_detector_schema *g_app_proto_para,
HASH_CLEAR(hh, name2lpi);
+#if 0
HASH_ITER(hh, g_app_proto_para->name_by_id, out ,tmp)
{
MESA_handle_runtime_log(g_app_proto_para->logger,
@@ -475,6 +476,7 @@ static int l7_protocol_mapper(struct glimpse_detector_schema *g_app_proto_para,
out->protocol_id
);
}
+#endif
return ret;
}
@@ -644,9 +646,10 @@ static int app_glimpse_detector(struct session *sess, struct traffic_context *co
}
new_protocol_id=get_protocol_id(g_app_proto_para->name_by_id, plpi_mod);
+#if 0
if(new_protocol_id==(unsigned short)-1)
{
-
+
if(plpi_mod->protocol!=LPI_PROTO_UNKNOWN && plpi_mod->protocol!=LPI_PROTO_UDP && plpi_mod->protocol!=LPI_PROTO_UNSUPPORTED)
{
MESA_handle_runtime_log(g_app_proto_para->logger,
@@ -660,7 +663,6 @@ static int app_glimpse_detector(struct session *sess, struct traffic_context *co
session_get0_readable_addr(sess)
);
}
-
return 1;
}
else
@@ -676,6 +678,8 @@ static int app_glimpse_detector(struct session *sess, struct traffic_context *co
session_get0_readable_addr(sess)
);
}
+#endif
+
l7_protocol = (struct l7_protocol_label *)session_exdata_get(sess, g_app_proto_para->l7_app_id_exdata_idx);
if(l7_protocol==NULL)
{
@@ -693,7 +697,7 @@ static int app_glimpse_detector(struct session *sess, struct traffic_context *co
{
FREE(msg);
}
- MESA_handle_runtime_log(g_app_proto_para->logger, RLOG_LV_DEBUG, "ADD_PROJECT", "%s identified, ID %d addr: %s", plpi_mod->name, new_protocol_id, session_get0_readable_addr(sess));
+ //MESA_handle_runtime_log(g_app_proto_para->logger, RLOG_LV_DEBUG, "ADD_PROJECT", "%s identified, ID %d addr: %s", plpi_mod->name, new_protocol_id, session_get0_readable_addr(sess));
}
if (context->pkt_cnt >= g_app_proto_para->max_pkts || (plpi_mod->category != LPI_CATEGORY_TUNNELLING && plpi_mod->category != LPI_CATEGORY_NAT && plpi_mod->protocol != LPI_PROTO_RDP && plpi_mod->protocol != LPI_PROTO_UDP_RDP && plpi_mod->protocol != LPI_PROTO_UDP_RTP && plpi_mod->protocol != LPI_PROTO_UDP_RTCP))
@@ -749,7 +753,7 @@ static void glimpse_detector_on_session_msg(struct session *sess, int topic_id _
{
if(context->is_identify==0)
{
- MESA_handle_runtime_log(glimpse_detector_env->logger, RLOG_LV_INFO, "UNKNOWN", "addr: %s", session_get0_readable_addr(sess));
+ //MESA_handle_runtime_log(glimpse_detector_env->logger, RLOG_LV_INFO, "UNKNOWN", "addr: %s", session_get0_readable_addr(sess));
}
FREE(context);
session_exdata_set(sess, glimpse_detector_env->plugin_exdata_idx, NULL);
@@ -766,10 +770,10 @@ extern "C" void APP_GLIMPSE_DETECTOR_UNLOAD(void *plugin_env)
struct glimpse_detector_schema *glimpse_detector_env=(struct glimpse_detector_schema *)plugin_env;
lpi_free_library();
free_l7_protocol_mapper(glimpse_detector_env->name_by_id);
- if(glimpse_detector_env->logger)
- {
- MESA_destroy_runtime_log_handle(glimpse_detector_env->logger);
- }
+ //if(glimpse_detector_env->logger)
+ //{
+ // MESA_destroy_runtime_log_handle(glimpse_detector_env->logger);
+ //}
FREE(plugin_env);
}
}
@@ -779,17 +783,20 @@ extern "C" void * APP_GLIMPSE_DETECTOR_LOAD(struct stellar *st)
int ret=0;
struct glimpse_detector_schema *glimpse_detector_env=CALLOC(struct glimpse_detector_schema, 1);
glimpse_detector_env->st=st;
- MESA_load_profile_short_def(g_app_proto_conffile, "PROTO_IDENTIFY", "LOG_LEVEL", (short *)&glimpse_detector_env->level, 30);
- MESA_load_profile_int_def(g_app_proto_conffile, "PROTO_IDENTIFY", "MAX_IDENTIFY_PACKETS", &glimpse_detector_env->max_pkts, 16);
- MESA_load_profile_string_def(g_app_proto_conffile, "PROTO_IDENTIFY", "LOG_PATH", glimpse_detector_env->log_path, sizeof(glimpse_detector_env->log_path), log_path);
- MESA_load_profile_string_def(g_app_proto_conffile, "SYSTEM", "APP_IDENTIFY_RESULT_BRIDGE", glimpse_detector_env->l7_bridge_name, sizeof(glimpse_detector_env->l7_bridge_name), "APP_IDENTIFY_RESULT_BRIDGE");
- MESA_load_profile_string_def(g_app_proto_conffile, "SYSTEM", "L7_PROTOCOL_FILE", glimpse_detector_env->l7_protocol_file, sizeof(glimpse_detector_env->l7_protocol_file), l7_protocol_file);
-
- glimpse_detector_env->logger=MESA_create_runtime_log_handle(glimpse_detector_env->log_path, glimpse_detector_env->level);
- if(glimpse_detector_env->logger==NULL)
- {
- goto INIT_ERROR;
- }
+ //MESA_load_profile_short_def(g_app_proto_conffile, "PROTO_IDENTIFY", "LOG_LEVEL", (short *)&glimpse_detector_env->level, 30);
+ glimpse_detector_env->max_pkts=16;
+ strcpy(glimpse_detector_env->l7_bridge_name,"APP_IDENTIFY_RESULT_BRIDGE");
+ strcpy( glimpse_detector_env->l7_protocol_file, l7_protocol_file);
+ //MESA_load_profile_int_def(g_app_proto_conffile, "PROTO_IDENTIFY", "MAX_IDENTIFY_PACKETS", &glimpse_detector_env->max_pkts, 16);
+ //MESA_load_profile_string_def(g_app_proto_conffile, "PROTO_IDENTIFY", "LOG_PATH", glimpse_detector_env->log_path, sizeof(glimpse_detector_env->log_path), log_path);
+ //MESA_load_profile_string_def(g_app_proto_conffile, "SYSTEM", "APP_IDENTIFY_RESULT_BRIDGE", glimpse_detector_env->l7_bridge_name, sizeof(glimpse_detector_env->l7_bridge_name), "APP_IDENTIFY_RESULT_BRIDGE");
+ //MESA_load_profile_string_def(g_app_proto_conffile, "SYSTEM", "L7_PROTOCOL_FILE", glimpse_detector_env->l7_protocol_file, sizeof(glimpse_detector_env->l7_protocol_file), l7_protocol_file);
+
+ //glimpse_detector_env->logger=MESA_create_runtime_log_handle(glimpse_detector_env->log_path, glimpse_detector_env->level);
+ //if(glimpse_detector_env->logger==NULL)
+ //{
+ // goto INIT_ERROR;
+ //}
ret=lpi_init_library(1); // 1, 2 or 3
if(ret<0)
{
diff --git a/decoders/glimpse_detector/openvpn_identify.cpp b/decoders/glimpse_detector/openvpn_identify.cpp
index 9c06e89..fdf4871 100644
--- a/decoders/glimpse_detector/openvpn_identify.cpp
+++ b/decoders/glimpse_detector/openvpn_identify.cpp
@@ -24,7 +24,6 @@
#include <stdint.h>
#include <arpa/inet.h>
-#include <MESA/stream.h>
#include "app_l7_protocol.h"
/*
* OpenVPN TCP / UDP Detection - 128/160 hmac
diff --git a/decoders/glimpse_detector/quic_identify.cpp b/decoders/glimpse_detector/quic_identify.cpp
index 7e88311..2bda374 100644
--- a/decoders/glimpse_detector/quic_identify.cpp
+++ b/decoders/glimpse_detector/quic_identify.cpp
@@ -1,6 +1,4 @@
#include <arpa/inet.h>
-#include "MESA/stream.h"
-
#include "app_l7_protocol.h"
#define GQUIC_PUBLIC_FLAG_VERSION 0x01
diff --git a/test/glimpse_detector/gtest_glimpse_detector_main.cpp b/test/glimpse_detector/gtest_glimpse_detector_main.cpp
index f37d656..8df1eef 100644
--- a/test/glimpse_detector/gtest_glimpse_detector_main.cpp
+++ b/test/glimpse_detector/gtest_glimpse_detector_main.cpp
@@ -14,7 +14,7 @@
#include "app_l7_protocol.h"
#include "cJSON.h"
-#include "MESA_prof_load.h"
+//#include "MESA_prof_load.h"
#include "stellar/stellar.h"
#include "stellar/session.h"
@@ -165,12 +165,12 @@ extern "C" void *APP_TEST_PLUG_INIT(struct stellar *st)
{
struct app_test_plugin_env *env = (struct app_test_plugin_env *)calloc(1, sizeof(struct app_test_plugin_env));
env->st=st;
- char l7_label_name[256]="";
- char l7_bridge_name[256]="";
- char l7_proto_name[256]="";
- MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "L7_LABEL_NAME", l7_label_name, sizeof(l7_label_name), "L7_PROTOCOL_LABEL");
- MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "APP_BRIDGE_NAME", l7_bridge_name, sizeof(l7_bridge_name), "APP_BRIDGE");
- MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "L7_PROTOCOL_FILE", l7_proto_name, sizeof(l7_proto_name), "./tsgconf/tsg_l7_protocol.conf");
+ //const char *l7_label_name=(const char*)"L7_PROTOCOL_LABEL";
+ //const char *l7_bridge_name=(const char*)"APP_BRIDGE";
+ const char *l7_proto_name=(const char*)"./tsgconf/tsg_l7_protocol.conf";
+ //MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "L7_LABEL_NAME", l7_label_name, sizeof(l7_label_name), "L7_PROTOCOL_LABEL");
+ //MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "APP_BRIDGE_NAME", l7_bridge_name, sizeof(l7_bridge_name), "APP_BRIDGE");
+ //MESA_load_profile_string_def("./tsgconf/main.conf", "SYSTEM", "L7_PROTOCOL_FILE", l7_proto_name, sizeof(l7_proto_name), "./tsgconf/tsg_l7_protocol.conf");
env->l7_exdata_idx= stellar_exdata_new_index(st, "L7_PROTOCOL", stellar_exdata_free_default, NULL);
env->test_exdata_idx= stellar_exdata_new_index(st, "APP_PROTO_TEST", stellar_exdata_free_default, NULL);
if(env->l7_exdata_idx<0 || env->test_exdata_idx<0)