From b7717058fe92b1cfc39b0188f3054848c81c0941 Mon Sep 17 00:00:00 2001 From: vaguue Date: Tue, 13 Aug 2024 20:23:54 +0300 Subject: [PATCH] testing ci --- .github/workflows/ci.yaml | 16 +++++++++++++++- CMakeLists.txt | 13 +++++++++++++ cxx/common.hpp | 2 -- lib/layers/ARP.js | 2 +- lib/layers/Ethernet.js | 2 +- lib/layers/IPv4.js | 2 +- lib/layers/Payload.js | 2 +- lib/layers/TCP.js | 2 +- lib/layers/TLV.js | 2 +- lib/layers/exampleLayer.js | 2 +- 10 files changed, 35 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3332215..dc42aa3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -73,10 +73,24 @@ jobs: - name: Submodule update run: git submodule update --init --recursive shell: bash - - name: Build and Text + + - name: Build and Test (Windows) + if: matrix.os == 'windows-latest' + run: npm i && PCAP_ROOT="$(pwd)/build/Release/npcap" npm run build && npm run test + shell: bash + + - name: Build and Test + if: matrix.os != 'windows-latest' run: npm i && npm run build && npm run test shell: bash + + - name: Prebuild (Windows) + if: matrix.os == 'windows-latest' + run: PCAP_ROOT="$(pwd)/build/Release/npcap" npm run precompile && ls prebuilds && zip -r prebuilds-${{ matrix.os }}.zip prebuilds + shell: bash + - name: Prebuild + if: matrix.os != 'windows-latest' run: npm run precompile && ls prebuilds && zip -r prebuilds-${{ matrix.os }}.zip prebuilds shell: bash - name: ls diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c45f1c..39caae1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,19 @@ add_library(${PROJECT_NAME} SHARED ${CMAKE_JS_SRC}) target_include_directories(${PROJECT_NAME} PRIVATE "${NODE_ADDON_API_DIR}") target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/cxx") +if(DEFINED ENV{PCAP_ROOT}) + set(PCAP_ROOT $ENV{PCAP_ROOT}) + message("PCAP_ROOT: ${PCAP_ROOT}") + add_definitions(-DPCAP_ROOT="${PCAP_ROOT}") +else() + message(WARNING "PCAP_ROOT is not set in the environment. Default paths will be used.") +endif() + +if(PCAP_ROOT) + target_include_directories(${PROJECT_NAME} PRIVATE "${PCAP_ROOT}/Include") + target_link_libraries(${PROJECT_NAME} PRIVATE "${PCAP_ROOT}/Lib/Packet.lib" "${PCAP_ROOT}/Lib/wpcap.lib") +endif() + # PcapPlusPlus add_subdirectory(cxx_modules/PcapPlusPlus) add_dependencies(${PROJECT_NAME} Pcap++) diff --git a/cxx/common.hpp b/cxx/common.hpp index 5e6e6ff..973f772 100644 --- a/cxx/common.hpp +++ b/cxx/common.hpp @@ -17,8 +17,6 @@ * and JS <=> C++ specific functions. */ -#define DEBUG - #ifdef DEBUG #define DEBUG_OUTPUT(x) std::cout << "[over-the-wire::cxx] " << (x) << std::endl; #else diff --git a/lib/layers/ARP.js b/lib/layers/ARP.js index 4677ee6..da3c71a 100644 --- a/lib/layers/ARP.js +++ b/lib/layers/ARP.js @@ -60,7 +60,7 @@ class ARP extends ARPHeader { * @param {Buffer|Object} data - Input buffer or object with protocol fields. * @param {LayerOptions} opts - Options for the layer. */ - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { super(data); mixins.ctor(this, data, opts); } diff --git a/lib/layers/Ethernet.js b/lib/layers/Ethernet.js index b42a502..7608d38 100644 --- a/lib/layers/Ethernet.js +++ b/lib/layers/Ethernet.js @@ -51,7 +51,7 @@ class Ethernet extends EthernetHeader { * @param {Buffer|Object} data - Input buffer or object with protocol fields. * @param {Object} opts - Options for the layer. */ - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { super(data); mixins.ctor(this, data, opts); } diff --git a/lib/layers/IPv4.js b/lib/layers/IPv4.js index 6dbd8b1..2089966 100644 --- a/lib/layers/IPv4.js +++ b/lib/layers/IPv4.js @@ -91,7 +91,7 @@ class IPv4 extends IPv4Header { * @param {Buffer|Object} data - Input buffer or object with protocol fields. * @param {Object} opts - Options for the layer. */ - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { super(data); mixins.ctor(this, data, opts); diff --git a/lib/layers/Payload.js b/lib/layers/Payload.js index 8c0ab72..ef5b7be 100644 --- a/lib/layers/Payload.js +++ b/lib/layers/Payload.js @@ -8,7 +8,7 @@ const { OsiModelLayers } = require('./osi'); class Payload { name = 'Payload'; - constructor(data, { prev = null, allocated = null } = {}) { + constructor(data = {}, { prev = null, allocated = null } = {}) { this.prev = prev; this.next = null; diff --git a/lib/layers/TCP.js b/lib/layers/TCP.js index 837a5e8..bc6000f 100644 --- a/lib/layers/TCP.js +++ b/lib/layers/TCP.js @@ -78,7 +78,7 @@ const flagKeys = flagNames.map(e => e + 'Flag'); class TCP extends TCPHeader { name = 'TCP'; - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { super(data); mixins.ctor(this, data, opts); diff --git a/lib/layers/TLV.js b/lib/layers/TLV.js index 86a597f..e3302ad 100644 --- a/lib/layers/TLV.js +++ b/lib/layers/TLV.js @@ -24,7 +24,7 @@ const { TLVRecord_8, TLVPadding_8 } = compile(` `); class TLV_8 extends TLVRecord_8 { - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { super(data); if (!Buffer.isBuffer(data) && typeof data == 'object' && data?.value) { this.value = data.value; diff --git a/lib/layers/exampleLayer.js b/lib/layers/exampleLayer.js index 6661467..25831c9 100644 --- a/lib/layers/exampleLayer.js +++ b/lib/layers/exampleLayer.js @@ -11,7 +11,7 @@ class Layer { * @param {Buffer|Object} data - Input buffer or object with protocol fields. * @param {Object} opts - Options for the layer. */ - constructor(data, opts = {}) { + constructor(data = {}, opts = {}) { /** * Underlying buffer synced with the properties. * @type {Buffer}