Skip to content

Commit

Permalink
Merge pull request #65 from synacker/feature/pcapng
Browse files Browse the repository at this point in the history
Added pcapng support as option
  • Loading branch information
synacker authored Jan 13, 2024
2 parents 434ed8e + 8c2638e commit 9820487
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/daggy-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions CI/conan/profiles/macos-clang14_x64
Original file line number Diff line number Diff line change
@@ -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
24 changes: 7 additions & 17 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")


Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions git_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def build(self):
@property
def branch(self):
stream = os.popen("git branch --show-current")

return stream.read().strip()

@property
Expand Down
9 changes: 8 additions & 1 deletion src/Daggy/CConsoleDaggy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -170,7 +172,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");
Expand Down Expand Up @@ -230,7 +236,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())
Expand Down Expand Up @@ -258,6 +264,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
Expand Down
10 changes: 7 additions & 3 deletions src/Daggy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set(TARGET daggy)

option(PCAPNG_SUPPORT "pcap to pcapng convertor" ON)

find_package(Qt6 COMPONENTS Core REQUIRED)

add_executable(${TARGET})
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Daggy/Precompiled.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
#include <mustache.hpp>
#endif

#ifdef PCAPNG_SUPPORT
#include <pcapplusplus/PcapFileDevice.h>
#include <pcapplusplus/Logger.h>
#endif

#ifdef Q_OS_WIN
#include <windows.h>
Expand Down
1 change: 0 additions & 1 deletion src/DaggyCore/tests/local/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 9820487

Please sign in to comment.