9 Commits

Author SHA1 Message Date
刘学利
453c5330c0 Merge branch 'fix-log-level' into 'master'
Fix log level

See merge request tango/fw_dns_plug!4
2020-09-18 12:12:57 +08:00
刘学利
aafcea896f Fix log level 2020-09-18 12:12:57 +08:00
刘学利
2e50b5347f Merge branch 'develop' into 'master'
支持上传yum源(https://repo.geedge.net/pulp/content/7/x86_64/stable/tsg/)

See merge request tango/fw_dns_plug!3
2020-05-01 16:23:24 +08:00
liuxueli
1e14cf83ca 支持上传yum源(https://repo.geedge.net/pulp/content/7/x86_64/stable/tsg/)
rpm中增加changelog信息
2020-05-01 16:18:09 +08:00
刘学利
ea8e0f6fbe Merge branch 'develop' into 'master'
修复内存泄漏

See merge request tango/fw_dns_plug!2
2020-04-08 17:15:32 +08:00
liuxueli
5b6d67901e 修复内存泄漏 2020-01-16 15:16:44 +08:00
刘学利
1c9d36df0a Merge branch 'develop' into 'master'
Develop

See merge request tango/fw_dns_plug!1
2020-01-07 17:49:18 +08:00
liuxueli
0d8e315ad5 修复笔误 2020-01-07 17:46:51 +08:00
liuxueli
f4a4fff3c1 阻断方式由总控提供函数接口实现 2019-12-20 11:09:56 +08:00
15 changed files with 288 additions and 203 deletions

View File

@@ -1,123 +1,104 @@
image: "docker:stable" image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
services:
- docker:dind
variables: variables:
GIT_STRATEGY: "clone" GIT_STRATEGY: "clone"
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG 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
stages: stages:
- build - build
- package
- release .build_by_travis:
- docker
.build_before_script:
before_script: before_script:
- mkdir -p /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/$CI_PROJECT_NAMESPACE/ - mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
- ln -s $CI_PROJECT_DIR /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/$CI_PROJECT_PATH - ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
- cd /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX/$CI_PROJECT_PATH - cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
- chmod +x ./ci/travis.sh
.build_fw_dns_plug:
extends: .build_before_script
image: git.mesalab.cn:7443/tango/tsg_master:master
script: script:
- source /etc/profile.d/MESA.sh - yum makecache
- mkdir -p build - ./ci/travis.sh
- cd build - cd build
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE tags:
- make - share
- make package
.package_fw_dns_plug:
extends: .build_before_script
image: git.mesalab.cn:7443/tango/tsg_master:master
script:
- source /etc/profile.d/MESA.sh
- mkdir -p build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- make package
build: branch_build_debug:
stage: build stage: build
extends: .build_fw_dns_plug extends: .build_by_travis
tags:
- share
variables: variables:
BUILD_TYPE: "Debug" BUILD_TYPE: Debug
artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
paths:
- ./build/*.rpm
except: except:
- /^develop.*$/i
- /^master.*$/i
- tags - tags
fw_dns_plug_debug: branch_build_release:
stage: package stage: build
extends: .package_fw_dns_plug
tags:
- share
variables: variables:
BUILD_TYPE: "Debug" BUILD_TYPE: RelWithDebInfo
extends: .build_by_travis
except:
- /^develop.*$/i
- /^master.*$/i
- tags
develop_build_debug:
stage: build
extends: .build_by_travis
variables:
BUILD_TYPE: Debug
PACKAGE: 1
artifacts: artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" name: "fw_dns_plug-$CI_COMMIT_REF_NAME-debug"
paths: paths:
- ./build/*.rpm - build/*.rpm
only: only:
- tags - /^develop.*$/i
- /^master.*$/i
fw_dns_plug_release:
stage: package develop_build_release:
extends: .package_fw_dns_plug stage: build
tags: extends: .build_by_travis
- share
variables: variables:
BUILD_TYPE: "Release" BUILD_TYPE: RelWithDebInfo
PACKAGE: 1
artifacts: artifacts:
name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME" name: "fw_dns_plug-$CI_COMMIT_REF_NAME-release"
paths: paths:
- ./build/*.rpm - build/*.rpm
only: only:
- tags - /^develop.*$/i
- /^master.*$/i
fw_dns_plug_release-release:
stage: release
image: git.mesalab.cn:7443/tango/tsg_master:master release_build_release:
tags: stage: build
- share
variables: variables:
ARTIFACTS_JOB: "fw_dns_plug_release" BUILD_TYPE: RelWithDebInfo
PROJECT_NAME: "fw_dns_plug" PACKAGE: 1
USER_DEFINE: "release" UPLOAD: 1
PULP3_REPO_NAME: tsg-stable-x86_64.el7
PULP3_DIST_NAME: tsg-stable-x86_64.el7
extends: .build_by_travis
artifacts:
name: "fw_dns_plug-$CI_COMMIT_REF_NAME-release"
paths:
- build/*.rpm
only: only:
- tags - tags
script:
- /bin/bash -x ./autorelease.sh $CI_API_V4_URL $CI_PROJECT_URL $CI_PROJECT_ID $CI_TOKEN $CI_COMMIT_TAG $ARTIFACTS_JOB $PROJECT_NAME $USER_DEFINE release_build_release_devel:
stage: build
fw_dns_plug_debug-release:
stage: release
image: git.mesalab.cn:7443/tango/tsg_master:master
tags:
- share
variables: variables:
ARTIFACTS_JOB: "fw_dns_plug_debug" BUILD_TYPE: RelWithDebInfo
PROJECT_NAME: "fw_dns_plug" ENABLE_DEVEL_SWITCH: "ON"
USER_DEFINE: "release" PACKAGE: 1
UPLOAD: 1
PULP3_REPO_NAME: tsg-stable-x86_64.el7
PULP3_DIST_NAME: tsg-stable-x86_64.el7
extends: .build_by_travis
artifacts:
name: "fw_dns_plug-$CI_COMMIT_REF_NAME-release"
paths:
- build/*.rpm
only: only:
- tags - tags
script:
- /bin/bash -x ./autorelease.sh $CI_API_V4_URL $CI_PROJECT_URL $CI_PROJECT_ID $CI_TOKEN $CI_COMMIT_TAG $ARTIFACTS_JOB $PROJECT_NAME $USER_DEFINE
build-docker:
stage: docker
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
tags:
- share
only:
- master

View File

@@ -1,5 +1,6 @@
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8)
set(lib_name fw_dns_plug)
project(fw_dns_plug) project(fw_dns_plug)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
@@ -33,41 +34,4 @@ set(CMAKE_INSTALL_PREFIX /home/mesasoft/sapp_run)
add_subdirectory (src) 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) include(Package)

View File

@@ -2,7 +2,7 @@
PLUGNAME=FW_DNS_PLUG PLUGNAME=FW_DNS_PLUG
SO_PATH=./plug/business/fw_dns_plug/fw_dns_plug.so SO_PATH=./plug/business/fw_dns_plug/fw_dns_plug.so
INIT_FUNC=FW_DNS_PLUG_INIT INIT_FUNC=FW_DNS_PLUG_INIT
DESTROY_FUNC=FW_DNS_PLUG_DESTORY DESTROY_FUNC=FW_DNS_PLUG_DESTROY
[DNS] [DNS]
FUNC_FLAG=DNS_ALL FUNC_FLAG=DNS_ALL

48
ci/get-nprocessors.sh Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Copyright 2017 Google Inc.
# All Rights Reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This file is typically sourced by another script.
# if possible, ask for the precise number of processors,
# otherwise take 2 processors as reasonable default; see
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
if [ -x /usr/bin/getconf ]; then
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
else
NPROCESSORS=2
fi
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
# crashes if parallelized too much (maybe memory consumption problem),
# so limit to 4 processors for the time being.
if [ $NPROCESSORS -gt 4 ] ; then
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
NPROCESSORS=4
fi

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
set -evx
echo "machine ${PULP3_SERVER_URL}\nlogin ${PULP3_SERVER_LOGIN}\npassword ${PULP3_SERVER_PASSWORD}\n" > ~/.netrc

64
ci/travis.sh Normal file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env sh
set -evx
chmod +x ci/get-nprocessors.sh
. ci/get-nprocessors.sh
# if possible, ask for the precise number of processors,
# otherwise take 2 processors as reasonable default; see
# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization
if [ -x /usr/bin/getconf ]; then
NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN)
else
NPROCESSORS=2
fi
# as of 2017-09-04 Travis CI reports 32 processors, but GCC build
# crashes if parallelized too much (maybe memory consumption problem),
# so limit to 4 processors for the time being.
if [ $NPROCESSORS -gt 4 ] ; then
echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4."
NPROCESSORS=4
fi
# Tell make to use the processors. No preceding '-' required.
MAKEFLAGS="j${NPROCESSORS}"
export MAKEFLAGS
env | sort
# Set default values to OFF for these variables if not specified.
: "${NO_EXCEPTION:=OFF}"
: "${NO_RTTI:=OFF}"
: "${COMPILER_IS_GNUCXX:=OFF}"
# Install dependency from YUM
if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
yum install -y $INSTALL_DEPENDENCY_LIBRARY
source /etc/profile.d/framework.sh
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 \
..
make
if [ -n "${PACKAGE}" ]; then
make package
fi
if [ -n "${UPLOAD}" ]; 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

View File

@@ -1,41 +1,54 @@
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}-debug") set(MY_RPM_NAME_PREFIX "${lib_name}-debug")
else() else()
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) set(MY_RPM_NAME_PREFIX "${lib_name}")
endif() endif()
message(STATUS "Package: ${CPACK_PACKAGE_NAME}") message(STATUS "Package: ${MY_RPM_NAME_PREFIX}")
set(CPACK_PACKAGE_VECDOR "MESA") set(CPACK_PACKAGE_VECDOR "MESA")
set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}") set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) 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)
set(CPACK_COMPONENTS_ALL devel) execute_process(COMMAND sh changelog.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
set(CPACK_RPM_PACKAGE_DEBUG 1) SET(CPACK_RPM_CHANGELOG_FILE ${PROJECT_SOURCE_DIR}/cmake/changelog.txt)
set(CPACK_RPM_COMPONENT_INSTALL OFF)
set(CPACK_RPM_DEVEL_FILE_NAME "${PROJECT_NAME}-devel.rpm")
set(CPACK_RPM_DEVEL_DEBUGINFO_FILE_NAME "${PROJECT_NAME}-devel-debuginfo.rpm")
# RPM Build # RPM Build
set(CPACK_GENERATOR "RPM") set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_VENDOR "MESA") set(CPACK_RPM_PACKAGE_VENDOR "MESA")
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no") set(CPACK_RPM_PACKAGE_AUTOREQPROV "yes")
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON) set(CPACK_RPM_PACKAGE_RELEASE_LIBRARY "on")
set(CPACK_RPM_DEBUGINFO_PACKAGE ON) set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
set(CPACK_RPM_PACKAGE_DEBUG 1)
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_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_LIBRARIES_GROUP "libraries")
set(CPACK_COMPONENT_PROFILE_GROUP "libraries")
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
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}") set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
# Must uninstall the debug package before install release package # Must uninstall the debug package before install release package
if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CPACK_RPM_PACKAGE_CONFLICTS ${MY_RPM_NAME_PREFIX})
set(CPACK_RPM_PACKAGE_CONFLICTS "${PROJECT_NAME}-debug")
else()
set(CPACK_RPM_PACKAGE_CONFLICTS ${PROJECT_NAME})
# set(CPACK_STRIP_FILES TRUE)
endif()
# set(CPACK_STRIP_FILES TRUE)
include(CPack) include(CPack)

14
cmake/PreInstall.sh Normal file
View 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
View 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

View File

@@ -38,16 +38,12 @@ set(VERSION_BUILD "${VCS_SHORT_HASH}")
# print information # print information
message(STATUS "Version: ${VERSION}-${VERSION_BUILD}") message(STATUS "Version: ${VERSION}-${VERSION_BUILD}")
if(NOT DEFINE_GIT_VERSION) option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to TRUE or FALSE" TRUE)
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})
if(DEFINE_GIT_VERSION) if(DEFINE_GIT_VERSION)
add_definitions(-DGIT_VERSION=${GIT_VERSION}) set(GIT_VERSION
option(DEFINE_GIT_VERSION "Set DEFINE_GIT_VERSION to OFF" ON) "${VERSION}-${CMAKE_BUILD_TYPE}-${VERSION_BUILD}-${VCS_BRANCH}-${VCS_TAG}-${VCS_DATE}")
endif() string(REGEX REPLACE "[-:+/\\.]" "_" GIT_VERSION ${GIT_VERSION})
add_definitions(-DGIT_VERSION=${GIT_VERSION})
endif() endif()

4
cmake/changelog.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
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

View File

@@ -8,12 +8,12 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(/opt/MESA/include/) include_directories(/opt/MESA/include/)
include_directories(/opt/MESA/include/tsg/) 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}) add_library(fw_dns_plug SHARED ${SRC})
target_link_libraries(fw_dns_plug ${FW_DNS_PLUG_DEPEND_DYN_LIB}) target_link_libraries(fw_dns_plug ${FW_DNS_PLUG_DEPEND_DYN_LIB})
set_target_properties(fw_dns_plug PROPERTIES PREFIX "") set_target_properties(fw_dns_plug PROPERTIES PREFIX "")
install(TARGETS fw_dns_plug DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/business/fw_dns_plug) 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) install(FILES ../bin/fw_dns_plug.inf DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/business/fw_dns_plug COMPONENT PROFILE)

View File

@@ -11,40 +11,12 @@
#include "tsg_rule.h" #include "tsg_rule.h"
#include "tsg_send_log.h" #include "tsg_send_log.h"
#include "fw_dns_plug.h" #include "fw_dns_plug.h"
#include "tsg_statistic.h"
char *g_fw_dns_conffile=(char *)"tsgconf/main.conf"; char *g_fw_dns_conffile=(char *)"tsgconf/main.conf";
char FW_DNS_PLUG_VERSION_20191209=0; char FW_DNS_PLUG_VERSION_20191220=0;
struct _fw_dns_plug g_fw_dns_plug_info; struct _fw_dns_plug g_fw_dns_plug_info;
enum TSG_ETHOD_TYPE
{
TSG_METHOD_TYPE_UNKNOWN=0,
TSG_METHOD_TYPE_DROP,
TSG_METHOD_TYPE_REDIRECTION,
TSG_METHOD_TYPE_MAX
};
const struct _str2index method2index[TSG_METHOD_TYPE_MAX]={ {TSG_METHOD_TYPE_UNKNOWN, 7, (char *)"unknown"},
{TSG_METHOD_TYPE_DROP, 4, (char *)"drop"},
{TSG_METHOD_TYPE_REDIRECTION, 8, (char *)"redirect"}
};
int tsg_get_method_id(char *method)
{
int i=0;
for(i=0; i<TSG_METHOD_TYPE_MAX; i++)
{
if(method2index[i].len==(int)strlen(method) && (strncasecmp(method2index[i].type, method, method2index[i].len))==0)
{
return method2index[i].index;
}
}
return -1;
}
static int get_answer_ttl(cJSON *object) static int get_answer_ttl(cJSON *object)
{ {
int min=0; int min=0;
@@ -342,6 +314,10 @@ static int fw_dns_send_log(struct streaminfo *a_stream, dns_info_t *dns_info, st
get_rr_str2json(object, dns_info, &dns_sec); get_rr_str2json(object, dns_info, &dns_sec);
rr_buf=cJSON_PrintUnformatted(object); rr_buf=cJSON_PrintUnformatted(object);
TLD_append(handle, (char *)"dns_rr", (void *)rr_buf, TLD_TYPE_STRING); TLD_append(handle, (char *)"dns_rr", (void *)rr_buf, TLD_TYPE_STRING);
cJSON_Delete(object);
object=NULL;
free(rr_buf); free(rr_buf);
rr_buf=NULL; rr_buf=NULL;
@@ -354,7 +330,7 @@ static int fw_dns_send_log(struct streaminfo *a_stream, dns_info_t *dns_info, st
log_msg.result_num=result_num; log_msg.result_num=result_num;
tsg_send_log(g_tsg_log_instance, handle, &log_msg, thread_seq); tsg_send_log(g_tsg_log_instance, handle, &log_msg, thread_seq);
tsg_set_policy_flow(a_stream, result, a_stream->threadnum);
return 0; return 0;
} }
@@ -366,10 +342,15 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
struct Maat_rule_t result[MAX_RESULT_NUM], *p_result=NULL; struct Maat_rule_t result[MAX_RESULT_NUM], *p_result=NULL;
dns_info_t *dns_info=(dns_info_t *)session_info->app_info; 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)
{
return state;
}
if(strlen((char *)dns_info->query_question.qname)==0)
{ {
MESA_handle_runtime_log(g_fw_dns_plug_info.logger, MESA_handle_runtime_log(g_fw_dns_plug_info.logger,
RLOG_LV_FATAL, RLOG_LV_DEBUG,
"DNS_PLUG", "DNS_PLUG",
"Qname is %s, addr: %s", "Qname is %s, addr: %s",
(dns_info==NULL) ? "NULL" : ((strlen((char *)dns_info->query_question.qname)==0) ? "NULL" : (char *)dns_info->query_question.qname), (dns_info==NULL) ? "NULL" : ((strlen((char *)dns_info->query_question.qname)==0) ? "NULL" : (char *)dns_info->query_question.qname),
@@ -463,6 +444,11 @@ extern "C" char FW_DNS_PLUG_ENTRY(stSessionInfo* session_info, void **pme, int
} }
} }
if(mid!=NULL)
{
Maat_clean_status(&mid);
mid=NULL;
}
return state; return state;
} }
@@ -503,7 +489,7 @@ extern "C" int FW_DNS_PLUG_INIT(void)
} }
extern "C" void FW_DNS_PLUG_DESTORY(void) extern "C" void FW_DNS_PLUG_DESTROY(void)
{ {
return ; return ;
} }

View File

@@ -15,7 +15,7 @@
fw_dns_rule_t g_fw_dns_rule_info; fw_dns_rule_t g_fw_dns_rule_info;
char FW_DNS_RULE_VERSION_20191201=0; char FW_DNS_RULE_VERSION_20191201=0;
struct _str2index str2index[]={{DNS_TYPE_CNAME, 5, (char *)"CNAME"}, struct _dns_str2idx str2index[]={{DNS_TYPE_CNAME, 5, (char *)"CNAME"},
{DNS_TYPE_MX, 2, (char *)"MX"}, {DNS_TYPE_MX, 2, (char *)"MX"},
{DNS_TYPE_A, 1, (char *)"A"}, {DNS_TYPE_A, 1, (char *)"A"},
{DNS_TYPE_NS, 2, (char *)"NS"}, {DNS_TYPE_NS, 2, (char *)"NS"},
@@ -28,7 +28,7 @@ int fw_dns_type2index(char *type)
{ {
int i=0; int i=0;
for(i=0; i<(int)(sizeof(str2index)/sizeof(struct _str2index)); i++) for(i=0; i<(int)(sizeof(str2index)/sizeof(struct _dns_str2idx)); i++)
{ {
if(str2index[i].len==(int)strlen(type) && (strncasecmp(str2index[i].type, type, str2index[i].len))==0) if(str2index[i].len==(int)strlen(type) && (strncasecmp(str2index[i].type, type, str2index[i].len))==0)
{ {

View File

@@ -5,7 +5,7 @@
#define MAX_TABLE_NAME_LEN 32 #define MAX_TABLE_NAME_LEN 32
struct _str2index struct _dns_str2idx
{ {
int index; int index;
int len; int len;