diff --git a/CMakeLists.txt b/CMakeLists.txt index 879fe12..e7b90cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include(Version) set(CMAKE_MACOSX_RPATH 0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") include_directories(${PROJECT_SOURCE_DIR}/inc/) include_directories(/opt/MESA/include/) @@ -28,6 +29,8 @@ elseif(ENABLE_SANITIZE_THREAD) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan") endif() +set(CMAKE_INSTALL_PREFIX /home/mesasoft/sapp_run) + add_subdirectory (src) set(CONFLIST /plug/platform/conflist_platform.inf) @@ -35,20 +38,28 @@ file(WRITE ${PROJECT_SOURCE_DIR}/install.sh "#!/bin/sh\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "DST=\${RPM_INSTALL_PREFIX}\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "mkdir -p \${DST}/plug/platform/\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "touch \${DST}${CONFLIST}\r\n") + +file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "if [[ -z `grep -rn 'POLICY_PRIORITY' ${DST}/conf/project_list.conf` ]];then\r\n") +file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "echo 'POLICY_PRIORITY struct' >> \${DST}/conf/project_list.conf\r\nfi\r\n") + file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "if [[ -z `grep -rn 'tsg_master.inf' \${DST}${CONFLIST}` ]];then\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "echo './plug/platform/tsg_master/tsg_master.inf' >> \${DST}/plug/platform/conflist_platform.inf\r\nfi\r\n") + SET(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/install.sh") file(WRITE ${PROJECT_SOURCE_DIR}/uninstall.sh "#!/bin/sh\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "DST=\${RPM_INSTALL_PREFIX}\r\n") file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "mkdir -p \${DST}/plug/platform/\r\n") + file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "sed -i '/tsg_master/d' \${DST}/plug/platform/conflist_platform.inf\r\n") +file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "sed -i '/POLICY_PRIORITY/d' \${DST}/conf/project_list.conf\r\n") + SET(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/uninstall.sh") -install(FILES inc/soq_sendlog.h DESTINATION /opt/MESA/include/soq) -install(FILES inc/soq_types.h DESTINATION /opt/MESA/include/soq) -install(FILES inc/t1_public.h DESTINATION /opt/MESA/include/soq) -install(FILES inc/t2_public.h DESTINATION /opt/MESA/include/soq) -install(FILES ddp/inc/ddp.h DESTINATION /opt/MESA/include/soq) +install(FILES bin/main.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf) +install(FILES bin/tsg_tableinfo.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/tsgconf) +install(FILES inc/tsg_send_log.h DESTINATION /opt/MESA/include/tsg) +install(FILES inc/tsg_types.h DESTINATION /opt/MESA/include/tsg) +install(FILES inc/tsg_rule.h DESTINATION /opt/MESA/include/tsg) include(Package) diff --git a/inc/tsg_rule.h b/inc/tsg_rule.h index bbd3667..7f2ff3f 100644 --- a/inc/tsg_rule.h +++ b/inc/tsg_rule.h @@ -9,6 +9,25 @@ extern "C" { #endif +typedef enum _tsg_protocol +{ + PROTO_UNKONWN=0, + PROTO_IPv4=1, + PROTO_IPv6, + PROTO_TCP, + PROTO_UDP, + PROTO_HTTP, + PROTO_MAIL, + PROTO_DNS, + PROTO_FTP, + PROTO_SSL, + PROTO_SIP, + PROTO_BGP, + PROTO_STREAMING_MEDIA, + PROTO_MAX +}tsg_protocol_t; + + #define MAX_DOAMIN_LEN 2048 struct _identify_info diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp index ec658ab..d104cb6 100644 --- a/src/tsg_entry.cpp +++ b/src/tsg_entry.cpp @@ -276,7 +276,7 @@ extern "C" int TSG_MASTER_INIT() -extern "C" int T2_MASTER_UNLOAD() +extern "C" int TSG_MASTER_UNLOAD() { return 0; } diff --git a/src/tsg_rule.cpp b/src/tsg_rule.cpp index 7a1c296..8f71b7c 100644 --- a/src/tsg_rule.cpp +++ b/src/tsg_rule.cpp @@ -19,7 +19,7 @@ int tsg_rule_init(const char* conffile, void *logger) { unsigned short redis_port = 0; int ret=0,scan_detail=0,effect_interval=60; - const char* instance_name=NULL,*module="MAAT"; + const char* instance_name="TSG",*module="MAAT"; int factor=0, redis_port_num=0,redis_index=0; char redis_ip[16]={0}, effective_flag[1024]={0}; int maat_mode=0,maat_stat_on=0,maat_perf_on=0,thread_max=0; @@ -41,6 +41,7 @@ int tsg_rule_init(const char* conffile, void *logger) thread_max=get_thread_count(); g_tsg_maat_feather=Maat_feather(thread_max, table_info, logger); + if(maat_mode==2) { MESA_load_profile_string_def(conffile,module,"REDIS_IP", redis_ip, sizeof(redis_ip),""); diff --git a/src/tsg_send_log.cpp b/src/tsg_send_log.cpp index 636fb5d..c6f210b 100644 --- a/src/tsg_send_log.cpp +++ b/src/tsg_send_log.cpp @@ -279,7 +279,7 @@ tsg_log_instance_t tsg_sendlog_init(const char *conffile) MESA_load_profile_string_def(conffile, "TSG_LOG", "COMMON_FIELD_FILE", _instance->common_field_file, sizeof(_instance->common_field_file), NULL); MESA_load_profile_string_def(conffile, "TSG_LOG", "BROKER_LIST", _instance->broker_list, sizeof(_instance->broker_list), NULL); - MESA_load_profile_int_def(conffile, "TSG_LOG", "LEVEL",&(level), 30); + MESA_load_profile_int_def(conffile, "TSG_LOG", "LOG_LEVEL",&(level), 30); MESA_load_profile_string_def(conffile, "TSG_LOG", "LOG_PATH", log_path, sizeof(log_path), NULL); _instance->logger=MESA_create_runtime_log_handle(log_path, level); @@ -306,7 +306,7 @@ tsg_log_instance_t tsg_sendlog_init(const char *conffile) if(!(kafka_handle=rd_kafka_new(RD_KAFKA_PRODUCER, rdkafka_conf, kafka_errstr, sizeof(kafka_errstr)))) { - MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "CABOT_INIT", "rd_kafka_new is error"); + MESA_handle_runtime_log(_instance->logger, RLOG_LV_FATAL, "KAFKA_INIT", "rd_kafka_new is error"); return NULL; } diff --git a/src/tsg_send_log_internal.h b/src/tsg_send_log_internal.h index e18bd5d..7162b42 100644 --- a/src/tsg_send_log_internal.h +++ b/src/tsg_send_log_internal.h @@ -49,6 +49,47 @@ struct _tsg_log_instance id2field_t *service2topic; }; +typedef enum _tsg_log_field_id +{ + LOG_COMMON_SERVICE, + LOG_COMMON_DIRECTION, + LOG_COMMON_L4_PROTOCOL, + LOG_COMMON_ADDRESS_TYPE, + LOG_COMMON_SCHAME_TYPE, + LOG_COMMON_POLICY_ID, + LOG_COMMON_USER_TAG, + LOG_COMMON_ACTION, + LOG_COMMON_USER_REGION, + LOG_COMMON_CLIENT_IP, + LOG_COMMON_CLIENT_PORT, + LOG_COMMON_ENTRANCE_ID, + LOG_COMMON_DEVICE_ID, + LOG_COMMON_LINK_ID, + LOG_COMMON_ISP, + LOG_COMMON_ENCAPSULATION, + LOG_COMMON_SLED_IP, + LOG_COMMON_SERVER_IP, + LOG_COMMON_SERVER_PORT, + LOG_COMMON_APP_LABEL, + LOG_COMMON_APP_ID, + LOG_COMMON_PROTOCOL_ID, + LOG_COMMON_C2S_PKT_NUM, + LOG_COMMON_S2C_PKT_NUM, + LOG_COMMON_C2S_BYTE_NUM, + LOG_COMMON_S2C_BYTE_NUM, + LOG_COMMON_START_TIME, + LOG_COMMON_END_TIME, + LOG_COMMON_CON_DURATION_MS, + LOG_COMMON_STREAM_DIR, + LOG_COMMON_ADDRESS_LIST, + LOG_COMMON_HAS_DUP_TRAFFIC, + LOG_COMMON_STREAM_ERROR, + LOG_COMMON_STREAM_TRACE_ID, + LOG_HTTP_HOST, + LOG_SSL_SNI, + LOG_COMMON_MAX +}tsg_log_field_id_t; + char *log_field_id2name(tsg_log_instance_t instance, tsg_log_field_id_t id); tsg_log_instance_t tsg_sendlog_init(const char *filename);