From 6497d84b2f81fd8b3e9b522e2ade4a12d7a89282 Mon Sep 17 00:00:00 2001 From: synacker Date: Sat, 13 Jan 2024 19:10:57 +0300 Subject: [PATCH 1/2] Added pcapng support as option --- conanfile.py | 24 +++++++----------------- src/Daggy/CConsoleDaggy.cpp | 7 ++++++- src/Daggy/CMakeLists.txt | 10 +++++++--- src/Daggy/Precompiled.hpp | 2 ++ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/conanfile.py b/conanfile.py index 49aa20ea..b6379f39 100644 --- a/conanfile.py +++ b/conanfile.py @@ -37,16 +37,10 @@ class DaggyConan(ConanFile): description = "Data Aggregation Utility and C/C++ developer library for data streams catching." settings = "os", "compiler", "build_type", "arch" options = { - "with_ssh2": [True, False], - "with_yaml": [True, False], - "with_console": [True, False], "shared": [True, False], "fPIC": [True, False] } default_options = { - "with_ssh2": True, - "with_yaml": True, - "with_console": True, "shared": True, "fPIC": False } @@ -79,15 +73,10 @@ def build_requirements(self): self.tool_requires("gtest/1.13.0") def requirements(self): - self.requires("qt/6.6.0") + self.requires("qt/6.6.1") self.requires("kainjow-mustache/4.1") - - if self.options.with_yaml: - self.requires("yaml-cpp/0.8.0") - - if self.options.with_ssh2: - self.requires("libssh2/1.11.0") - + self.requires("yaml-cpp/0.8.0") + self.requires("libssh2/1.11.0") self.requires("pcapplusplus/23.09") @@ -117,9 +106,10 @@ def generate(self): tc = CMakeToolchain(self) tc.cache_variables["CMAKE_INSTALL_LIBDIR"] = self.cpp.libdirs[0] - tc.cache_variables["SSH2_SUPPORT"] = self.options.with_ssh2 - tc.cache_variables["YAML_SUPPORT"] = self.options.with_yaml - tc.cache_variables["CONSOLE"] = self.options.with_console + tc.cache_variables["SSH2_SUPPORT"] = True + tc.cache_variables["YAML_SUPPORT"] = True + tc.cache_variables["CONSOLE"] = True + tc.cache_variables["PCAPNG_SUPPORT"] = True tc.cache_variables["PACKAGE_DEPS"] = True tc.cache_variables["BUILD_TESTING"] = True tc.cache_variables["CONAN_BUILD"] = True diff --git a/src/Daggy/CConsoleDaggy.cpp b/src/Daggy/CConsoleDaggy.cpp index f539f381..5237acf9 100644 --- a/src/Daggy/CConsoleDaggy.cpp +++ b/src/Daggy/CConsoleDaggy.cpp @@ -170,7 +170,11 @@ CConsoleDaggy::Settings CConsoleDaggy::parse() const command_line_parser.addOption(input_format_option); command_line_parser.addOption(input_from_stdin_option); command_line_parser.addOption(auto_complete_timeout); + +#ifdef PCAPNG_SUPPORT command_line_parser.addOption(fix_pcap_option); +#endif + command_line_parser.addHelpOption(); command_line_parser.addVersionOption(); command_line_parser.addPositionalArgument("file", "data aggregation sources file", "*.yaml|*.yml|*.json"); @@ -230,7 +234,7 @@ void CConsoleDaggy::fixPcaps() const { if (!settings_.fix_pcap) return; - +#ifdef PCAPNG_SUPPORT auto output_folder = QDir(QDir::cleanPath(settings_.output_folder + QDir::separator() + session_)); QDirIterator pcap_files(output_folder.absolutePath(), {"*.pcap"}); while (pcap_files.hasNext()) @@ -258,6 +262,7 @@ void CConsoleDaggy::fixPcaps() const output_folder.remove(pcap_file); console_aggreagator_->printAppMessage(QString("fix pcap %1").arg(pcap_name)); } +#endif } daggy::Core* CConsoleDaggy::daggyCore() const diff --git a/src/Daggy/CMakeLists.txt b/src/Daggy/CMakeLists.txt index bb02f212..dff88f52 100644 --- a/src/Daggy/CMakeLists.txt +++ b/src/Daggy/CMakeLists.txt @@ -1,5 +1,7 @@ set(TARGET daggy) +option(PCAPNG_SUPPORT "pcap to pcapng convertor" ON) + find_package(Qt6 COMPONENTS Core REQUIRED) add_executable(${TARGET}) @@ -27,9 +29,11 @@ endif() target_link_libraries(${TARGET} PRIVATE DaggyCore) - -find_package(PcapPlusPlus REQUIRED) -target_link_libraries(${TARGET} PRIVATE PcapPlusPlus::PcapPlusPlus) +if (PCAPNG_SUPPORT) + add_compile_definitions(PCAPNG_SUPPORT) + find_package(PcapPlusPlus REQUIRED) + target_link_libraries(${TARGET} PRIVATE PcapPlusPlus::PcapPlusPlus) +endif() if (CONAN_BUILD) find_package(kainjow_mustache REQUIRED) diff --git a/src/Daggy/Precompiled.hpp b/src/Daggy/Precompiled.hpp index 3586580f..c41ca916 100644 --- a/src/Daggy/Precompiled.hpp +++ b/src/Daggy/Precompiled.hpp @@ -25,8 +25,10 @@ #include #endif +#ifdef PCAPNG_SUPPORT #include #include +#endif #ifdef Q_OS_WIN #include From 8c2638e76deee507dae84ac502f2ed8af89a9535 Mon Sep 17 00:00:00 2001 From: synacker Date: Sat, 13 Jan 2024 19:48:14 +0300 Subject: [PATCH 2/2] Fixed compilation and version parameters --- .github/workflows/daggy-github-actions.yaml | 4 ++-- CI/conan/profiles/macos-clang14_x64 | 8 ++++++++ git_version.py | 1 + src/Daggy/CConsoleDaggy.cpp | 2 ++ src/DaggyCore/tests/local/CMakeLists.txt | 1 - src/cmake/version.cmake | 2 +- 6 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 CI/conan/profiles/macos-clang14_x64 diff --git a/.github/workflows/daggy-github-actions.yaml b/.github/workflows/daggy-github-actions.yaml index 701d6f67..9fe4f048 100644 --- a/.github/workflows/daggy-github-actions.yaml +++ b/.github/workflows/daggy-github-actions.yaml @@ -194,13 +194,13 @@ jobs: run: conan config install CI/conan - name: Conan install - run: conan install . --build=missing --profile:build=macos-clang13_x64 --profile:host=macos-clang13_x64 -of . + run: conan install . --build=missing --profile:build=macos-clang13_x64 --profile:host=macos-clang14_x64 -of . - name: Conan remove build folders run: conan cache clean "*" --source --build --temp --download - name: Conan build - run: conan build . --profile:build=macos-clang13_x64 --profile:host=macos-clang13_x64 --build=missing -of . + run: conan build . --profile:build=macos-clang13_x64 --profile:host=macos-clang14_x64 --build=missing -of . - name: daggy version working-directory: build/Release diff --git a/CI/conan/profiles/macos-clang14_x64 b/CI/conan/profiles/macos-clang14_x64 new file mode 100644 index 00000000..349e8d4e --- /dev/null +++ b/CI/conan/profiles/macos-clang14_x64 @@ -0,0 +1,8 @@ +[settings] +os=Macos +arch=x86_64 +compiler=apple-clang +compiler.version=14 +compiler.cppstd=17 +compiler.libcxx=libc++ +build_type=Release \ No newline at end of file diff --git a/git_version.py b/git_version.py index ed5b1d7e..a5d4ba54 100644 --- a/git_version.py +++ b/git_version.py @@ -56,6 +56,7 @@ def build(self): @property def branch(self): stream = os.popen("git branch --show-current") + return stream.read().strip() @property diff --git a/src/Daggy/CConsoleDaggy.cpp b/src/Daggy/CConsoleDaggy.cpp index 5237acf9..ace80d69 100644 --- a/src/Daggy/CConsoleDaggy.cpp +++ b/src/Daggy/CConsoleDaggy.cpp @@ -42,6 +42,8 @@ CConsoleDaggy::CConsoleDaggy(QObject* parent) qApp->setApplicationName("daggy"); qApp->setApplicationVersion(DAGGY_VERSION_STANDARD); qApp->setOrganizationName(DAGGY_VENDOR); + qApp->setApplicationVersion(DAGGY_VERSION_FULL); + qApp->setOrganizationDomain("daggy.dev"); connect(this, &CConsoleDaggy::interrupt, this, &CConsoleDaggy::stop, Qt::QueuedConnection); connect(qApp, &QCoreApplication::aboutToQuit, this, &CConsoleDaggy::fixPcaps); diff --git a/src/DaggyCore/tests/local/CMakeLists.txt b/src/DaggyCore/tests/local/CMakeLists.txt index d51d7a3b..3863e34b 100644 --- a/src/DaggyCore/tests/local/CMakeLists.txt +++ b/src/DaggyCore/tests/local/CMakeLists.txt @@ -17,7 +17,6 @@ set(SOURCES qt6_add_executable(${TARGET} ${SOURCES}) include(rpath_bin) add_test(NAME ${TARGET} COMMAND ${TARGET} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) -message("!!!!!!!!!!!!!!!!!111111111111111 PATH $ENV{PATH}:${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") set_tests_properties(${TARGET} PROPERTIES ENVIRONMENT "PATH=$ENV{PATH}:${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}") target_link_libraries(${TARGET} PRIVATE DaggyCore Qt6::Test) diff --git a/src/cmake/version.cmake b/src/cmake/version.cmake index b48e65c1..9f9cd0c1 100644 --- a/src/cmake/version.cmake +++ b/src/cmake/version.cmake @@ -63,7 +63,7 @@ macro(SET_GIT_VERSION) string(REGEX REPLACE "^v" "" VERSION ${VERSION_TAG}) set(VERSION ${VERSION}.${VERSION_BUILD}) set(VERSION_FULL ${VERSION}-${VERSION_BRANCH}) - if (VERSION_BRANCH STREQUAL ${VERSION_BRANCH} OR VERSION_BRANCH MATCHES "release/.*") + if (VERSION_BRANCH STREQUAL ${GIT_DEFAULT_BRANCH} OR VERSION_BRANCH MATCHES "release/.*") set(VERSION_STANDARD ${VERSION}) else() set(VERSION_STANDARD ${VERSION_FULL})