Compare commits
14 Commits
v3.0.0.20.
...
v3.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a25c20cea | ||
|
|
ab097e3bff | ||
|
|
badd5547da | ||
|
|
95bdca7514 | ||
|
|
9e4ed53bb1 | ||
|
|
4942106aab | ||
|
|
28cfd57e98 | ||
|
|
dab58fabe1 | ||
|
|
3d2324bb43 | ||
|
|
453c5330c0 | ||
|
|
aafcea896f | ||
|
|
2e50b5347f | ||
|
|
ea8e0f6fbe | ||
|
|
1c9d36df0a |
@@ -3,7 +3,7 @@ variables:
|
||||
GIT_STRATEGY: "clone"
|
||||
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||
INSTALL_PREFIX: "/home/mesasoft/sapp_run/"
|
||||
INSTALL_DEPENDENCY_LIBRARY: libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel sapp-devel framework_env libMESA_prof_load-devel http-devel dns-devel ftp-devel mail-devel ssl-devel librdkafka-devel libmaatframe-devel tsg_master-devel libdocumentanalyze-devel
|
||||
INSTALL_DEPENDENCY_LIBRARY: libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel sapp-devel framework_env libMESA_prof_load-devel http-devel dns-devel ftp-devel mail-devel ssl-devel librdkafka-devel libmaatframe-devel tsg_master-devel libdocumentanalyze-devel libasan
|
||||
|
||||
stages:
|
||||
- build
|
||||
@@ -47,6 +47,11 @@ develop_build_debug:
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
ASAN_OPTION: ADDRESS
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: tsg-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: tsg-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: "fw_dns_plug-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
@@ -61,6 +66,10 @@ develop_build_release:
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: tsg-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: tsg-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: "fw_dns_plug-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
@@ -70,12 +79,12 @@ develop_build_release:
|
||||
- /^master.*$/i
|
||||
|
||||
|
||||
release_build_release:
|
||||
release_build_debug:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD: 1
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: tsg-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: tsg-stable-x86_64.el7
|
||||
extends: .build_by_travis
|
||||
@@ -86,13 +95,15 @@ release_build_release:
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release_devel:
|
||||
release_build_release:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
ENABLE_DEVEL_SWITCH: "ON"
|
||||
PACKAGE: 1
|
||||
UPLOAD: 1
|
||||
UPLOAD_RPM: 1
|
||||
UPLOAD_SYMBOL_FILES: 1
|
||||
SYMBOL_TARGET: fw_dns_plug
|
||||
PULP3_REPO_NAME: tsg-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: tsg-stable-x86_64.el7
|
||||
extends: .build_by_travis
|
||||
|
||||
@@ -34,41 +34,4 @@ set(CMAKE_INSTALL_PREFIX /home/mesasoft/sapp_run)
|
||||
|
||||
add_subdirectory (src)
|
||||
|
||||
set(CONFLIST /plug/conflist.inf)
|
||||
set(MASTER_INF "./plug/business/fw_dns_plug/fw_dns_plug.inf")
|
||||
set(MAIN_CONF /tsgconf/main.conf)
|
||||
|
||||
file(WRITE ${PROJECT_SOURCE_DIR}/install.sh "#!/bin/sh\r\n")
|
||||
file(WRITE ${PROJECT_SOURCE_DIR}/uninstall.sh "#!/bin/sh\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "DST=\${RPM_INSTALL_PREFIX}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "DST=\${RPM_INSTALL_PREFIX}\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "mkdir -p \${DST}/plug/business/\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "mkdir -p \${DST}/plug/business/\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "touch \${DST}${CONFLIST}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "touch \${DST}${CONFLIST}\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "mkdir -p \${DST}/tsgconf/\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "mkdir -p \${DST}/tsgconf/\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "touch \${DST}${MAIN_CONF}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "touch \${DST}${MAIN_CONF}\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "if [[ -z `grep -rn 'fw_dns_plug.inf' \${DST}${CONFLIST}` ]];then\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "\tsed -i '/\\[business\\]/a\\${MASTER_INF}' \${DST}${CONFLIST}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "fi\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "sed -i '/fw_dns_plug.inf/d' \${DST}${CONFLIST}\r\n")
|
||||
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "if [[ -z `grep -rn '\\[DNS_PLUG\\]' \${DST}${MAIN_CONF}` ]];then\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "\tsed -i '1i\\\\[DNS_PLUG\\]' \${DST}${MAIN_CONF}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "\tsed -i '/\\[DNS_PLUG\\]/a\\LOG_LEVEL=30' \${DST}${MAIN_CONF}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "\tsed -i '/\\[DNS_PLUG\\]/a\\LOG_PATH=./tsglog/fw_dns_plug/fw_dns_plug' \${DST}${MAIN_CONF}\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/install.sh "fi\r\n")
|
||||
file(APPEND ${PROJECT_SOURCE_DIR}/uninstall.sh "sed -i '/\\[DNS_PLUG\\]/,+2d' \${DST}${MAIN_CONF}\r\n")
|
||||
|
||||
SET(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/install.sh")
|
||||
SET(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/uninstall.sh")
|
||||
|
||||
include(Package)
|
||||
|
||||
22
ci/travis.sh
22
ci/travis.sh
@@ -37,13 +37,19 @@ if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
|
||||
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
||||
source /etc/profile.d/framework.sh
|
||||
fi
|
||||
|
||||
if [ $ASAN_OPTION ];then
|
||||
source /opt/rh/devtoolset-7/enable
|
||||
fi
|
||||
|
||||
mkdir build || true
|
||||
cd build
|
||||
|
||||
cmake3 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
|
||||
-DENABLE_DEVEL=$ENABLE_DEVEL_SWITCH \
|
||||
-DASAN_OPTION=$ASAN_OPTION \
|
||||
-DVERSION_DAILY_BUILD=$TESTING_VERSION_BUILD \
|
||||
..
|
||||
|
||||
make
|
||||
@@ -52,13 +58,15 @@ if [ -n "${PACKAGE}" ]; then
|
||||
make package
|
||||
fi
|
||||
|
||||
if [ -n "${UPLOAD}" ]; then
|
||||
if [ -n "${UPLOAD_RPM}" ]; then
|
||||
cp ~/rpm_upload_tools.py ./
|
||||
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
|
||||
fi
|
||||
|
||||
#if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
||||
# rpm -i tfe*debuginfo*.rpm
|
||||
# cp /usr/lib/debug/opt/tsg/tfe/bin/tfe.debug /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||
# sentry-cli upload-dif -t elf /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA}
|
||||
#fi
|
||||
if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
|
||||
rpm -i $SYMBOL_TARGET*debuginfo*.rpm
|
||||
_symbol_file=`find /usr/lib/debug/ -name "$SYMBOL_TARGET*.so*.debug"`
|
||||
cp $_symbol_file ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
|
||||
sentry-cli upload-dif -t elf ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
|
||||
fi
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}")
|
||||
execute_process(COMMAND bash -c "echo -ne \"`uname -r | awk -F'.' '{print $5\".\"$6\".\"$7}'`\"" OUTPUT_VARIABLE SYSTEM_VERSION)
|
||||
|
||||
#execute_process(COMMAND sh changelog.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
|
||||
#SET(CPACK_RPM_CHANGELOG_FILE ${PROJECT_SOURCE_DIR}/cmake/changelog.txt)
|
||||
execute_process(COMMAND sh changelog.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
|
||||
SET(CPACK_RPM_CHANGELOG_FILE ${CMAKE_BINARY_DIR}/changelog.txt)
|
||||
|
||||
# RPM Build
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
@@ -25,23 +25,28 @@ set(CPACK_RPM_PACKAGE_RELEASE_LIBRARY "on")
|
||||
set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
|
||||
set(CPACK_RPM_PACKAGE_DEBUG 1)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQ "no")
|
||||
|
||||
set(CPACK_RPM_COMPONENT_INSTALL ON)
|
||||
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
|
||||
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
||||
set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
|
||||
|
||||
set(CPACK_COMPONENT_LIBRARY_REQUIRED TRUE)
|
||||
set(CPACK_RPM_LIBRARY_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||
set(CPACK_RPM_LIBRARY_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
set(CPACK_RPM_LIBRARY_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
|
||||
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||
set(CPACK_RPM_LIBRARIES_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
set(CPACK_RPM_LIBRARIES_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
|
||||
set(CPACK_COMPONENT_LIBRARY_GROUP "library")
|
||||
set(CPACK_COMPONENT_PROFILE_GROUP "library")
|
||||
set(CPACK_COMPONENT_LIBRARIES_GROUP "libraries")
|
||||
set(CPACK_COMPONENT_PROFILE_GROUP "libraries")
|
||||
|
||||
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
||||
|
||||
set(CPACK_COMPONENTS_ALL LIBRARY PROFILE)
|
||||
set(CPACK_COMPONENTS_ALL LIBRARIES PROFILE)
|
||||
|
||||
SET(CPACK_RPM_LIBRARIES_PRE_INSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/cmake/PreInstall.sh")
|
||||
SET(CPACK_RPM_LIBRARIES_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_SOURCE_DIR}/cmake/PreUninstall.sh")
|
||||
|
||||
set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
|
||||
14
cmake/PreInstall.sh
Normal file
14
cmake/PreInstall.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
DST=${RPM_INSTALL_PREFIX}
|
||||
mkdir -p ${DST}/plug/business/
|
||||
touch ${DST}/plug/conflist.inf
|
||||
mkdir -p ${DST}/tsgconf/
|
||||
touch ${DST}/tsgconf/main.conf
|
||||
if [[ -z `grep -rn 'fw_dns_plug.inf' ${DST}/plug/conflist.inf` ]];then
|
||||
sed -i '/\[business\]/a\./plug/business/fw_dns_plug/fw_dns_plug.inf' ${DST}/plug/conflist.inf
|
||||
fi
|
||||
if [[ -z `grep -rn '\[DNS_PLUG\]' ${DST}/tsgconf/main.conf` ]];then
|
||||
sed -i '1i\\[DNS_PLUG\]' ${DST}/tsgconf/main.conf
|
||||
sed -i '/\[DNS_PLUG\]/a\LOG_LEVEL=30' ${DST}/tsgconf/main.conf
|
||||
sed -i '/\[DNS_PLUG\]/a\LOG_PATH=./tsglog/fw_dns_plug/fw_dns_plug' ${DST}/tsgconf/main.conf
|
||||
fi
|
||||
12
cmake/PreUninstall.sh
Normal file
12
cmake/PreUninstall.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
if [ $1 == 0 ]; then
|
||||
DST=${RPM_INSTALL_PREFIX}
|
||||
|
||||
mkdir -p ${DST}/plug/business/
|
||||
touch ${DST}/plug/conflist.inf
|
||||
mkdir -p ${DST}/tsgconf/
|
||||
touch ${DST}/tsgconf/main.conf
|
||||
|
||||
sed -i '/fw_dns_plug.inf/d' ${DST}/plug/conflist.inf
|
||||
sed -i '/\[DNS_PLUG\]/,+2d' ${DST}/tsgconf/main.conf
|
||||
fi
|
||||
@@ -19,6 +19,11 @@ include(${__VERSION_CONFIG})
|
||||
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VCS_TAG}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VCS_TAG}")
|
||||
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VCS_TAG}")
|
||||
string(REGEX REPLACE "[T\\:\\+\\-]" "" VERSION_DATE "${VCS_DATE}")
|
||||
|
||||
if(VERSION_DAILY_BUILD)
|
||||
set(VERSION_PATCH ${VERSION_PATCH}.${VERSION_DATE})
|
||||
endif()
|
||||
|
||||
if(NOT VERSION_MAJOR)
|
||||
set(VERSION_MAJOR 1)
|
||||
@@ -38,16 +43,12 @@ set(VERSION_BUILD "${VCS_SHORT_HASH}")
|
||||
# print information
|
||||
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
|
||||
|
||||
if(NOT DEFINE_GIT_VERSION)
|
||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" OFF)
|
||||
|
||||
set(GIT_VERSION
|
||||
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
|
||||
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to TRUE or FALSE" TRUE)
|
||||
|
||||
if(DEFINE_GIT_VERSION)
|
||||
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
||||
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" ON)
|
||||
endif()
|
||||
set(GIT_VERSION
|
||||
"${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
|
||||
string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
|
||||
|
||||
add_definitions(-DGIT_VERSION=${GIT_VERSION})
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
work_path=$1
|
||||
branch=`git status | grep branch | awk '{print $NF}'`
|
||||
git log --branches=$branch --no-merges --date=local --show-signature --pretty="* %ad %an %ae %nhash: %H%ncommit:%n%B" | awk -F"-" '{print "- "$0}' | sed 's/- \*/\*/g' | sed 's/- $//g' | sed 's/-/ -/g' | sed 's/[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//g' > changelog.txt
|
||||
git log --branches=$branch --no-merges --date=local --show-signature --pretty="* %ad %an %ae %nhash: %H%ncommit:%n%B" | awk -F"-" '{print "- "$0}' | sed 's/- \*/\*/g' | sed 's/- $//g' | sed 's/-/ -/g' | sed 's/[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//g' > $work_path/changelog.txt
|
||||
|
||||
@@ -8,12 +8,12 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
include_directories(/opt/MESA/include/)
|
||||
include_directories(/opt/MESA/include/tsg/)
|
||||
|
||||
set(FW_DNS_PLUG_DEPEND_DYN_LIB MESA_handle_logger MESA_prof_load maatframe pthread MESA_field_stat2)
|
||||
set(FW_DNS_PLUG_DEPEND_DYN_LIB maatframe pthread MESA_field_stat2)
|
||||
|
||||
add_library(fw_dns_plug SHARED ${SRC})
|
||||
target_link_libraries(fw_dns_plug ${FW_DNS_PLUG_DEPEND_DYN_LIB})
|
||||
set_target_properties(fw_dns_plug PROPERTIES PREFIX "")
|
||||
|
||||
install(TARGETS fw_dns_plug LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/business/fw_dns_plug COMPONENT LIBRARY)
|
||||
install(TARGETS fw_dns_plug LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/business/fw_dns_plug COMPONENT LIBRARIES)
|
||||
install(FILES ../bin/fw_dns_plug.inf DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/business/fw_dns_plug COMPONENT PROFILE)
|
||||
|
||||
|
||||
@@ -9,10 +9,37 @@
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "tsg_rule.h"
|
||||
#include "tsg_label.h"
|
||||
#include "tsg_send_log.h"
|
||||
#include "fw_dns_plug.h"
|
||||
#include "tsg_statistic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char * GIT_VERSION_##v = NULL
|
||||
#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
|
||||
|
||||
/* VERSION TAG */
|
||||
#ifdef GIT_VERSION
|
||||
GIT_VERSION_EXPEND(GIT_VERSION);
|
||||
#else
|
||||
static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
|
||||
#endif
|
||||
#undef GIT_VERSION_CATTER
|
||||
#undef GIT_VERSION_EXPEND
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PRINTADDR
|
||||
#define PRINTADDR(a, b) ((b)<RLOG_LV_FATAL ? printaddr(&(a->addr), a->threadnum) : "")
|
||||
#endif
|
||||
|
||||
|
||||
char *g_fw_dns_conffile=(char *)"tsgconf/main.conf";
|
||||
char FW_DNS_PLUG_VERSION_20191220=0;
|
||||
struct _fw_dns_plug g_fw_dns_plug_info;
|
||||
@@ -89,7 +116,7 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
p_result->service_defined,
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
printaddr(&a_stream->addr, a_stream->threadnum)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -108,7 +135,7 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
tmp_buff,
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
printaddr(&a_stream->addr, a_stream->threadnum)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +151,7 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
(tmp_buff==NULL) ? p_result->service_defined : tmp_buff,
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
printaddr(&a_stream->addr, a_stream->threadnum)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
|
||||
if(tmp_buff!=NULL)
|
||||
@@ -133,7 +160,7 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
tmp_buff=NULL;
|
||||
}
|
||||
|
||||
return PROT_STATE_GIVEME;
|
||||
return PROT_STATE_GIVEME|PROT_STATE_DROPPKT;
|
||||
}
|
||||
|
||||
item=cJSON_GetObjectItem(object, "method");
|
||||
@@ -145,9 +172,19 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
switch(method_type)
|
||||
{
|
||||
case TSG_METHOD_TYPE_DROP:
|
||||
state=PROT_STATE_DROPME|PROT_STATE_DROPPKT;
|
||||
state=PROT_STATE_GIVEME|PROT_STATE_DROPPKT;
|
||||
break;
|
||||
case TSG_METHOD_TYPE_REDIRECTION:
|
||||
if(g_fw_dns_plug_info.mode==0 && dns_info->hdr_info.qr==1) //mirror
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if(g_fw_dns_plug_info.mode==1 && dns_info->hdr_info.qr==0) //inline or transparent
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
answer_array=get_answer_records(object, dns_info->query_question.qtype);
|
||||
if(answer_array!=NULL)
|
||||
{
|
||||
@@ -207,10 +244,27 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
payload_len=build_cheat_pkt(cheat_pkt_payload, MAX_CHEAT_PKT_PAYLOAD_LEN, &dns_info->query_question, cheat_opt, used_num);
|
||||
if(payload_len==-1)
|
||||
{
|
||||
MESA_handle_runtime_log(g_fw_dns_plug_info.logger,
|
||||
RLOG_LV_FATAL,
|
||||
"DO_ACTION",
|
||||
"Hit policy_id: %d service: %d action: %d build_cheat_pkt ret: %d addr: %s",
|
||||
p_result->config_id,
|
||||
p_result->service_id,
|
||||
p_result->action,
|
||||
payload_len,
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(dns_info->hdr_info.qr==0)
|
||||
{
|
||||
senddir = MESA_dir_reverse(a_stream->routedir);
|
||||
}
|
||||
else
|
||||
{
|
||||
senddir = a_stream->routedir;
|
||||
}
|
||||
ret=MESA_inject_pkt(a_stream, (const char *)cheat_pkt_payload, payload_len, (const char *)a_packet, senddir);
|
||||
if(ret<0)
|
||||
{
|
||||
@@ -223,11 +277,11 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
dns_info->query_question.qtype,
|
||||
p_result->config_id,
|
||||
p_result->service_id,
|
||||
printaddr(&a_stream->addr, a_stream->threadnum)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
}
|
||||
|
||||
state=PROT_STATE_DROPME|PROT_STATE_DROPPKT;
|
||||
state=PROT_STATE_GIVEME|PROT_STATE_DROPPKT;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -241,9 +295,9 @@ static char fw_dns_action(struct streaminfo *a_stream, dns_info_t *dns_info, Maa
|
||||
(tmp_buff==NULL) ? p_result->service_defined : tmp_buff,
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
printaddr(&a_stream->addr, a_stream->threadnum)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
state=PROT_STATE_GIVEME;
|
||||
state=PROT_STATE_GIVEME|PROT_STATE_DROPPKT;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -302,10 +356,11 @@ static int fw_dns_send_log(struct streaminfo *a_stream, dns_info_t *dns_info, st
|
||||
}
|
||||
|
||||
cname=cJSON_PrintUnformatted(cname_array);
|
||||
if(strlen(cname)>0)
|
||||
if(cname!=NULL && strlen(cname)>0)
|
||||
{
|
||||
TLD_append(handle, (char *)"dns_cname", (void *)cname, TLD_TYPE_STRING);
|
||||
free(cname);
|
||||
cJSON_free(cname);
|
||||
cname=NULL;
|
||||
}
|
||||
cJSON_Delete(cname_array);
|
||||
cname_array=NULL;
|
||||
@@ -314,7 +369,11 @@ static int fw_dns_send_log(struct streaminfo *a_stream, dns_info_t *dns_info, st
|
||||
get_rr_str2json(object, dns_info, &dns_sec);
|
||||
rr_buf=cJSON_PrintUnformatted(object);
|
||||
TLD_append(handle, (char *)"dns_rr", (void *)rr_buf, TLD_TYPE_STRING);
|
||||
free(rr_buf);
|
||||
|
||||
cJSON_Delete(object);
|
||||
object=NULL;
|
||||
|
||||
cJSON_free(rr_buf);
|
||||
rr_buf=NULL;
|
||||
|
||||
TLD_append(handle, (char *)"dns_sub", (void *)(long)dns_sec, TLD_TYPE_LONG);
|
||||
@@ -332,20 +391,27 @@ static int fw_dns_send_log(struct streaminfo *a_stream, dns_info_t *dns_info, st
|
||||
|
||||
extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,const void *a_packet)
|
||||
{
|
||||
int ret=0,hit_num=0;
|
||||
int i=0,ret=0,hit_num=0;
|
||||
scan_status_t mid=NULL;
|
||||
int category_id_num=0;
|
||||
char state=PROT_STATE_GIVEME;
|
||||
unsigned int category_id[MAX_CATEGORY_ID_NUM]={0};
|
||||
struct Maat_rule_t result[MAX_RESULT_NUM], *p_result=NULL;
|
||||
dns_info_t *dns_info=(dns_info_t *)session_info->app_info;
|
||||
|
||||
if(dns_info==NULL || strlen((char *)dns_info->query_question.qname)==0)
|
||||
if(dns_info==NULL || a_stream==NULL)
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
if(strlen((char *)dns_info->query_question.qname)==0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_fw_dns_plug_info.logger,
|
||||
RLOG_LV_FATAL,
|
||||
RLOG_LV_DEBUG,
|
||||
"DNS_PLUG",
|
||||
"Qname is %s, addr: %s",
|
||||
(dns_info==NULL) ? "NULL" : ((strlen((char *)dns_info->query_question.qname)==0) ? "NULL" : (char *)dns_info->query_question.qname),
|
||||
printaddr(&a_stream->addr, thread_seq)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
return state;
|
||||
}
|
||||
@@ -362,7 +428,7 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
result[hit_num].action,
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
printaddr(&a_stream->addr, thread_seq)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
hit_num+=ret;
|
||||
}
|
||||
@@ -375,7 +441,7 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
ret,
|
||||
printaddr(&a_stream->addr, thread_seq)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -389,7 +455,8 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
NULL,
|
||||
MAX_RESULT_NUM-hit_num,
|
||||
&mid,
|
||||
thread_seq);
|
||||
thread_seq
|
||||
);
|
||||
|
||||
if(ret>0)
|
||||
{
|
||||
@@ -402,7 +469,7 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
result[hit_num].config_id,
|
||||
result[hit_num].service_id,
|
||||
result[hit_num].action,
|
||||
printaddr(&a_stream->addr, thread_seq)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
hit_num+=ret;
|
||||
}
|
||||
@@ -415,11 +482,45 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
(char *)dns_info->query_question.qname,
|
||||
dns_info->query_question.qtype,
|
||||
ret,
|
||||
printaddr(&a_stream->addr, thread_seq)
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
category_id_num=tsg_get_fqdn_category_id(g_tsg_maat_feather, (char *)dns_info->query_question.qname, category_id, MAX_CATEGORY_ID_NUM, g_fw_dns_plug_info.logger, thread_seq);
|
||||
for(i=0; i< category_id_num; i++)
|
||||
{
|
||||
ret=Maat_scan_intval(g_tsg_maat_feather, g_fw_dns_plug_info.table_qname_id, (unsigned int)category_id[i], result+hit_num,MAX_RESULT_NUM-hit_num, &mid, thread_seq);
|
||||
if(ret>0)
|
||||
{
|
||||
MESA_handle_runtime_log(g_fw_dns_plug_info.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_FQDN_CAT_ID",
|
||||
"Hit qname: %s category id: %d policy_id: %d service: %d action: %d addr: %s",
|
||||
(char *)dns_info->query_question.qname,
|
||||
category_id[i],
|
||||
result[hit_num].config_id,
|
||||
result[hit_num].service_id,
|
||||
result[hit_num].action,
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
hit_num+=ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_handle_runtime_log(g_fw_dns_plug_info.logger,
|
||||
RLOG_LV_DEBUG,
|
||||
"SCAN_DOMAIN",
|
||||
"Scan domain: %s category id: %d ret: %d addr: %s",
|
||||
(char *)dns_info->query_question.qname,
|
||||
category_id[i],
|
||||
ret,
|
||||
PRINTADDR(a_stream, g_fw_dns_plug_info.level)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(hit_num>0)
|
||||
{
|
||||
p_result=tsg_fetch_deny_rule(result, hit_num);
|
||||
@@ -446,20 +547,19 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
|
||||
|
||||
extern "C" int FW_DNS_PLUG_INIT(void)
|
||||
{
|
||||
int level=30,ret=0;
|
||||
char log_path[256]={0};
|
||||
int ret=0,len=0;
|
||||
memset(&g_fw_dns_plug_info, 0, sizeof(g_fw_dns_plug_info));
|
||||
|
||||
MESA_load_profile_int_def(g_fw_dns_conffile, "DNS_PLUG", "LOG_LEVEL", &level, 30);
|
||||
MESA_load_profile_string_def(g_fw_dns_conffile, "DNS_PLUG", "LOG_PATH", log_path, sizeof(log_path), "tsglog/fw_dns_plug/fw_dns_plug");
|
||||
MESA_load_profile_int_def(g_fw_dns_conffile, "DNS_PLUG", "LOG_LEVEL", &g_fw_dns_plug_info.level, RLOG_LV_FATAL);
|
||||
MESA_load_profile_string_def(g_fw_dns_conffile, "DNS_PLUG", "LOG_PATH", g_fw_dns_plug_info.log_path, sizeof(g_fw_dns_plug_info.log_path), "tsglog/fw_dns_plug/fw_dns_plug");
|
||||
|
||||
|
||||
MESA_load_profile_string_def(g_fw_dns_conffile, "DNS_PLUG", "TABLE_QNAME", g_fw_dns_plug_info.table_qname, MAX_TABLE_NAME_LEN, "TSG_FIELD_DNS_QNAME");
|
||||
|
||||
g_fw_dns_plug_info.logger=MESA_create_runtime_log_handle(log_path, level);
|
||||
g_fw_dns_plug_info.logger=MESA_create_runtime_log_handle(g_fw_dns_plug_info.log_path, g_fw_dns_plug_info.level);
|
||||
if(g_fw_dns_plug_info.logger==NULL)
|
||||
{
|
||||
printf("MESA_create_runtime_log_handle failed, log_path: %s level: %d", (log_path==NULL) ? NULL : log_path, level);
|
||||
printf("MESA_create_runtime_log_handle failed, log_path: %s level: %d", (g_fw_dns_plug_info.log_path==NULL) ? NULL : g_fw_dns_plug_info.log_path, g_fw_dns_plug_info.level);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -476,6 +576,20 @@ extern "C" int FW_DNS_PLUG_INIT(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
len=sizeof(g_fw_dns_plug_info.s_mode);
|
||||
ret=sapp_get_platform_opt(SPO_DEPLOYMENT_MODE_STR, g_fw_dns_plug_info.s_mode, &len);
|
||||
if(ret>=0)
|
||||
{
|
||||
if((memcmp(g_fw_dns_plug_info.s_mode, "mirror", strlen(g_fw_dns_plug_info.s_mode)))==0)
|
||||
{
|
||||
g_fw_dns_plug_info.mode=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_fw_dns_plug_info.mode=1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
|
||||
struct _fw_dns_plug
|
||||
{
|
||||
int mode;
|
||||
int level;
|
||||
int table_qname_id;
|
||||
char table_qname[MAX_TABLE_NAME_LEN];
|
||||
char s_mode[MAX_TABLE_NAME_LEN];
|
||||
char log_path[MAX_TABLE_NAME_LEN*2];
|
||||
void *logger;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user