Compare commits

..
4 Commits
42 changed files with 565 additions and 1033 deletions

No files matched your search

+4 -7
View File
@@ -4,12 +4,9 @@
"dockerfile": "../docker/DockerfileDepsLlvm",
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools"
]
}
},
"settings": {},
"extensions": [
"ms-vscode.cpptools"
],
"forwardPorts": [4222],
}
-22
View File
@@ -1,22 +0,0 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/docker"
schedule:
interval: "weekly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "vcpkg"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "cargo"
directory: "/rust"
schedule:
interval: "weekly"
+4 -5
View File
@@ -15,7 +15,7 @@ jobs:
name: Ubuntu/GCC Autotools build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
@@ -65,7 +65,7 @@ jobs:
name: Ubuntu/GCC Meson build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
@@ -86,7 +86,7 @@ jobs:
name: Ubuntu/GCC minimal build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- name: Install Minimal Dependencies
run: |
@@ -113,7 +113,7 @@ jobs:
name: macOS/Clang build
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- name: Install Homebrew Dependencies
run: brew install msgpack-cxx asio gnutls nettle readline fmt jsoncpp argon2 openssl cppunit
@@ -146,7 +146,6 @@ jobs:
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENDHT_DOWNLOAD_DEPS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DOPENDHT_C=On -DBUILD_TESTING=On \
-DOPENDHT_PEER_DISCOVERY=On -DOPENDHT_PYTHON=Off \
+2 -2
View File
@@ -6,7 +6,7 @@ jobs:
name: Clang Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v4
- name: deps
run: |
sudo apt update && \
@@ -37,6 +37,6 @@ jobs:
- name: cmake
run: |
mkdir build && cd build && \
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DOPENDHT_C=On -DOPENDHT_DOWNLOAD_DEPS=ON -DOPENDHT_PEER_DISCOVERY=On -DOPENDHT_PYTHON=Off -DOPENDHT_TOOLS=On -DOPENDHT_PROXY_SERVER=On -DOPENDHT_PROXY_CLIENT=On -DOPENDHT_PUSH_NOTIFICATIONS=On
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DOPENDHT_C=On -DOPENDHT_PEER_DISCOVERY=On -DOPENDHT_PYTHON=Off -DOPENDHT_TOOLS=On -DOPENDHT_PROXY_SERVER=On -DOPENDHT_PROXY_CLIENT=On -DOPENDHT_PUSH_NOTIFICATIONS=On
- name: scan-build
run: cd build && scan-build --status-bugs make
+1 -3
View File
@@ -22,12 +22,10 @@ jobs:
include:
- language: c-cpp
build-mode: autobuild
- language: actions
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
+24 -148
View File
@@ -25,7 +25,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -41,7 +41,7 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_DEPS }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileDeps
@@ -58,7 +58,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -75,7 +75,7 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
@@ -92,7 +92,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -108,7 +108,7 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_DEPS_LLVM }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileDepsLlvm
@@ -125,7 +125,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -142,7 +142,7 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LLVM }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileLlvm
@@ -159,7 +159,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -176,7 +176,7 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_DHTNODE }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileDhtnode
@@ -193,7 +193,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -210,7 +210,7 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_ALPINE_DEPS }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileDepsAlpine
@@ -227,7 +227,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
@@ -244,7 +244,7 @@ jobs:
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_ALPINE }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
uses: docker/build-push-action@v5
with:
context: .
file: docker/DockerfileAlpine
@@ -256,50 +256,20 @@ jobs:
name: Build Windows MSI Installer
runs-on: windows-latest
env:
VCPKG_VERSION: "2025.07.25"
VCPKG_INSTALLATION_ROOT: "C:\\vcpkg"
VCPKG_VERSION: "2025.04.09"
VCPKG_DISABLE_METRICS: "1"
VCPKG_DEFAULT_TRIPLET: x64-windows
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg_binary_cache
VCPKG_ROOT: "C:\\vcpkg"
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up MSVC developer environment
uses: microsoft/setup-msbuild@v2
- name: Install WIX using .net tools
run: |
dotnet tool install --global wix --version 6.0.1
wix extension add --global WixToolset.UI.wixext/6.0.1
shell: pwsh
- name: Cache vcpkg installed packages
id: cache-vcpkg
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-x64-shared-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}-${{ hashFiles('.github/workflows/windows-build.yml') }}
- name: Setup vcpkg and install dependencies
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
New-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}" -ItemType Directory -Force
New-Item -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" -ItemType Directory -Force
vcpkg install `
--recurse `
--clean-after-build `
--triplet=x64-windows `
--x-install-root=${{ env.VCPKG_INSTALLED_DIR }} `
--x-feature=test
shell: pwsh
- name: Configure CMake for MSI
shell: pwsh
@@ -307,10 +277,7 @@ jobs:
mkdir build -ErrorAction SilentlyContinue
cmake -B build `
-S . `
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_INSTALLATION_ROOT }}/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=x64-windows `
-DVCPKG_INSTALLED_DIR=${{ env.VCPKG_INSTALLED_DIR }} `
-DVCPKG_MANIFEST_FEATURES=test `
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake `
-DCMAKE_BUILD_TYPE=Release `
-DOPENDHT_C=On `
-DOPENDHT_TOOLS=On `
@@ -320,16 +287,12 @@ jobs:
-DOPENDHT_PROXY_CLIENT=On `
-DOPENDHT_HTTP=On `
-DBUILD_TESTING=Off `
-DOPENDHT_CPACK=On `
-A x64
- name: Build with MSVC
shell: pwsh
run: |
cmake --build build --config Release --parallel $([System.Environment]::ProcessorCount)
# Copy vcpkg installed libraries to the build directory
Copy-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}\x64-windows\lib\*.lib" -Destination "build" -Force
Copy-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}\x64-windows\bin\*.dll" -Destination "build" -Force
- name: Package MSI with CPack
shell: pwsh
@@ -355,86 +318,6 @@ jobs:
path: build/${{ steps.cpack_msi.outputs.msi_path }} # Path to the MSI in the build directory
retention-days: 7
build-windows-dhtnode:
name: Build Windows dhtnode
runs-on: windows-latest
env:
VCPKG_VERSION: "2025.07.25"
VCPKG_INSTALLATION_ROOT: "C:\\vcpkg"
VCPKG_DISABLE_METRICS: "1"
VCPKG_DEFAULT_TRIPLET: x64-windows-static-release
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg_binary_cache
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Set up MSVC developer environment
uses: microsoft/setup-msbuild@v2
- name: Cache vcpkg static installed packages
id: cache-vcpkg-static
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-x64-static-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}-${{ hashFiles('.github/workflows/windows-build.yml') }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-x64-static-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-x64-static-
- name: Setup vcpkg and install static dependencies
if: steps.cache-vcpkg-static.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}" -ItemType Directory -Force
New-Item -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" -ItemType Directory -Force
vcpkg install `
--recurse `
--clean-after-build `
--triplet=x64-windows-static-release `
--x-install-root=${{ env.VCPKG_INSTALLED_DIR }} `
--x-feature=test
- name: Configure CMake for Static Build
shell: pwsh
run: |
mkdir build_static -ErrorAction SilentlyContinue
cmake -B build_static `
-S . `
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_INSTALLATION_ROOT }}/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-release `
-DVCPKG_INSTALLED_DIR=${{ env.VCPKG_INSTALLED_DIR }} `
-DVCPKG_MANIFEST_FEATURES=test `
-DCMAKE_BUILD_TYPE=Release `
-DBUILD_SHARED_LIBS=OFF `
-DOPENDHT_PROXY_CLIENT=ON `
-DOPENDHT_PROXY_SERVER=ON `
-DOPENDHT_C=ON `
-DOPENDHT_TOOLS=ON `
-DOPENDHT_PYTHON=OFF `
-DOPENDHT_PEER_DISCOVERY=ON `
-DOPENDHT_HTTP=ON `
-A x64
- name: Build Static dhtnode
shell: pwsh
run: |
cmake --build build_static --config Release --parallel $([System.Environment]::ProcessorCount)
- name: Upload Static dhtnode Artifact
uses: actions/upload-artifact@v4
with:
name: opendht-windows-dhtnode
path: |
build_static/**/*dhtnode.exe
retention-days: 7
build-python-wheels:
name: Build Python Wheels
runs-on: ubuntu-latest
@@ -443,14 +326,14 @@ jobs:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: cmake (for Python wheel)
run: |
mkdir build_python && cd build_python && \
cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=On \
-DOPENDHT_STATIC=Off \
-DOPENDHT_PYTHON=On \
-DOPENDHT_C=Off \
-DOPENDHT_PEER_DISCOVERY=On \
@@ -470,28 +353,22 @@ jobs:
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-windows-msi, build-python-wheels, build-windows-dhtnode]
needs: [build-windows-msi, build-python-wheels]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Download Windows MSI artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@v4
with:
name: opendht-windows-msi
path: downloaded_artifacts/windows_msi
- name: Download Static dhtnode artifact
uses: actions/download-artifact@v5
with:
name: opendht-windows-dhtnode
path: downloaded_artifacts/static_dhtnode
- name: Download Linux Wheels artifact
uses: actions/download-artifact@v5
uses: actions/download-artifact@v4
with:
name: opendht-wheels-linux
path: downloaded_artifacts/linux_wheels
@@ -504,4 +381,3 @@ jobs:
files: |
downloaded_artifacts/linux_wheels/*.whl
downloaded_artifacts/windows_msi/*.msi
downloaded_artifacts/static_dhtnode/**/*dhtnode.exe
+11 -138
View File
@@ -1,6 +1,4 @@
name: Windows Build
permissions:
contents: read
on:
push:
@@ -9,11 +7,10 @@ on:
branches: [ main, master ]
env:
VCPKG_VERSION: "2025.07.25"
VCPKG_VERSION: "2025.04.09"
VCPKG_INSTALLATION_ROOT: "C:\\vcpkg"
VCPKG_DISABLE_METRICS: "1"
VCPKG_INSTALLED_DIR: ${{ github.workspace }}\vcpkg_installed
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}\vcpkg_binary_cache
jobs:
prepare-dependencies:
@@ -27,7 +24,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Set up MSVC
uses: microsoft/setup-msbuild@v2
@@ -36,26 +33,22 @@ jobs:
id: generate_cache_key
shell: pwsh
run: |
$key_value = "${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-shared-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}-${{ hashFiles('.github/workflows/windows-build.yml') }}"
$key_value = "${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}-${{ hashFiles('.github/workflow/windows-build.yml') }}"
echo "key=$key_value" >> $env:GITHUB_OUTPUT
- name: Cache vcpkg installed packages
id: cache-vcpkg
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
path: ${{ env.VCPKG_INSTALLED_DIR }}
key: ${{ steps.generate_cache_key.outputs.key }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-shared-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-shared-
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-
- name: Setup vcpkg and install dependencies
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: |
New-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}" -ItemType Directory -Force
New-Item -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" -ItemType Directory -Force
vcpkg install `
--recurse `
--clean-after-build `
@@ -64,54 +57,6 @@ jobs:
--x-feature=test
shell: pwsh
prepare-static-dependencies:
name: Prepare Windows Static Dependencies
runs-on: windows-latest
outputs:
vcpkg_static_cache_key: ${{ steps.generate_static_cache_key.outputs.key }}
strategy:
matrix:
arch: [x64]
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up MSVC
uses: microsoft/setup-msbuild@v2
- name: Generate Cache Key for Static Libs
id: generate_static_cache_key
shell: pwsh
run: |
$key_value = "${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-static-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}-${{ hashFiles('.github/workflows/windows-build.yml') }}"
echo "key=$key_value" >> $env:GITHUB_OUTPUT
- name: Cache vcpkg static installed packages
id: cache-vcpkg-static
uses: actions/cache@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ steps.generate_static_cache_key.outputs.key }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-static-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-static-
- name: Setup vcpkg and install static dependencies
if: steps.cache-vcpkg-static.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -Path "${{ env.VCPKG_INSTALLED_DIR }}" -ItemType Directory -Force
New-Item -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" -ItemType Directory -Force
vcpkg install `
--recurse `
--clean-after-build `
--triplet=${{ matrix.arch }}-windows-static-release `
--x-install-root=${{ env.VCPKG_INSTALLED_DIR }} `
--x-feature=test
build-windows:
name: Windows MSVC Build
runs-on: windows-latest
@@ -124,7 +69,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Set up MSVC
uses: microsoft/setup-msbuild@v2
@@ -133,13 +78,11 @@ jobs:
id: cache-vcpkg-restore
uses: actions/cache/restore@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
path: ${{ env.VCPKG_INSTALLED_DIR }}
key: ${{ needs.prepare-dependencies.outputs.vcpkg_cache_key }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-shared-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-shared-
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-
- name: Configure CMake
shell: pwsh
@@ -186,76 +129,6 @@ jobs:
build/**/*.lib
retention-days: 7
build-windows-static:
name: Windows Static MSVC Build
runs-on: windows-latest
needs: prepare-static-dependencies
strategy:
matrix:
build_type: [Release]
arch: [x64]
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Set up MSVC
uses: microsoft/setup-msbuild@v2
- name: Restore vcpkg static installed packages
id: cache-vcpkg-static-restore
uses: actions/cache/restore@v4
with:
path: |
${{ env.VCPKG_INSTALLED_DIR }}
${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: ${{ needs.prepare-static-dependencies.outputs.vcpkg_static_cache_key }}
restore-keys: |
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-static-${{ hashFiles('**/vcpkg.json', '**/vcpkg-configuration.json') }}
${{ runner.os }}-vcpkg-${{ env.VCPKG_VERSION }}-${{ matrix.arch }}-static-
- name: Configure CMake for Static Build
shell: pwsh
run: |
mkdir build -ErrorAction SilentlyContinue
cmake -B build `
-S . `
-DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_INSTALLATION_ROOT }}/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static-release `
-DVCPKG_INSTALLED_DIR=${{ env.VCPKG_INSTALLED_DIR }} `
-DVCPKG_MANIFEST_FEATURES=test `
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
-DBUILD_SHARED_LIBS=OFF `
-DBUILD_TESTING=ON `
-DOPENDHT_PROXY_CLIENT=ON `
-DOPENDHT_PROXY_SERVER=ON `
-DOPENDHT_C=ON `
-DOPENDHT_TOOLS=ON `
-DOPENDHT_PYTHON=OFF `
-DOPENDHT_PEER_DISCOVERY=ON `
-DOPENDHT_HTTP=ON `
-A ${{ matrix.arch }}
- name: Build Static
shell: pwsh
run: |
cmake --build build --config ${{ matrix.build_type }} --parallel 4
- name: Test Static Build
shell: pwsh
run: |
cd build
ctest --build-config ${{ matrix.build_type }} --output-on-failure --parallel 4
- name: Upload static build artifacts
uses: actions/upload-artifact@v4
with:
name: opendht-windows-static-${{ matrix.arch }}-${{ matrix.build_type }}
path: |
build/**/*.exe
build/**/*.lib
retention-days: 7
build-windows-mingw:
name: Windows MinGW Build
runs-on: windows-latest
@@ -267,7 +140,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v4
- name: Setup MinGW
uses: msys2/setup-msys2@v2
+291 -407
View File
@@ -1,16 +1,13 @@
cmake_minimum_required (VERSION 3.21..3.31)
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
endif() # MSVC build workaround for STATIC mode
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.30 AND NOT POLICY CMP0167)
cmake_policy(SET CMP0167 OLD)
endif()
set (opendht_VERSION_MAJOR 3)
set (opendht_VERSION_MINOR 5.1)
set (opendht_VERSION_MINOR 4.0)
set (opendht_VERSION ${opendht_VERSION_MAJOR}.${opendht_VERSION_MINOR})
set (PACKAGE_VERSION ${opendht_VERSION})
set (VERSION "${opendht_VERSION}")
@@ -20,23 +17,20 @@ project (opendht
HOMEPAGE_URL "https://opendht.net/"
)
include(CMakePackageConfigHelpers)
include(CMakeDependentOption)
include(CheckIncludeFileCXX)
set(POSSIBLE_PKGCONFIG OFF)
if(NOT MSVC)
include(FindPkgConfig)
set(POSSIBLE_PKGCONFIG ON)
endif()
include(FindPkgConfig)
include(cmake/CheckAtomic.cmake)
include(FetchContent)
include(CTest)
# Options
option (BUILD_SHARED_LIBS "Build shared library" ON)
option (OPENDHT_USE_PKGCONFIG "Use pkg-config to find installed libraries where possible" ${POSSIBLE_PKGCONFIG})
CMAKE_DEPENDENT_OPTION (OPENDHT_STATIC "Build static library" OFF BUILD_SHARED_LIBS ON)
option (OPENDHT_PYTHON "Build Python bindings" OFF)
option (OPENDHT_TOOLS "Build DHT tools" ON)
option (OPENDHT_EXAMPLES "Build DHT examples" OFF)
option (OPENDHT_SYSTEMD "Install systemd module" OFF)
option (OPENDHT_SYSTEMD_UNIT_FILE_LOCATION "Where to install systemd unit file")
option (OPENDHT_SANITIZE "Build with address sanitizer and stack protector" OFF)
@@ -48,20 +42,18 @@ option (OPENDHT_PROXY_OPENSSL "Build DHT proxy with OpenSSL" ON)
CMAKE_DEPENDENT_OPTION(OPENDHT_HTTP "Build embedded http(s) client" OFF "NOT OPENDHT_PROXY_SERVER;NOT OPENDHT_PROXY_CLIENT" ON)
option (OPENDHT_PEER_DISCOVERY "Enable multicast peer discovery" ON)
option (OPENDHT_IO_URING "Use io_uring if available on the system (Linux only)" OFF)
option (OPENDHT_INDEX "Build DHT indexing feature" OFF)
option (OPENDHT_INDEX "Build DHT indexation feature" OFF)
option (OPENDHT_TESTS_NETWORK "Enable unit tests that require network access" ON)
option (OPENDHT_C "Build C bindings" OFF)
option (OPENDHT_CPACK "Add CPack support" OFF)
option (OPENDHT_DOWNLOAD_DEPS "Fetch automatically the missing dependency libraries from the network" ON)
find_package(Doxygen QUIET)
if (DOXYGEN_FOUND)
option (OPENDHT_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
endif ()
find_package(Doxygen)
option (OPENDHT_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND})
# Build flags
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED on)
if(MSVC AND NOT BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if(MSVC AND NOT BUILD_SHARED_LIBS AND NOT CMAKE_MSVC_RUNTIME_LIBRARY)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
@@ -80,92 +72,100 @@ if (NOT HAVE_CXX_ATOMICS_WITHOUT_LIB
link_libraries (atomic)
endif ()
if(WIN32)
include(cmake/WindowsUtils.cmake)
get_WIN32_WINNT(WINNT_VERSION)
message(STATUS "Windows NT version detection: ${WINNT_VERSION}")
# Prevents MinGW from problems linking Windows networking and IPC functions on Windows 10/11
# if _WIN32_WINNT is not defined correctly
if(NOT MSVC)
add_definitions(-D_WIN32_WINNT=${WINNT_VERSION} -DWINVER=${WINNT_VERSION})
if (WIN32)
if(CMAKE_SYSTEM_VERSION AND CMAKE_SYSTEM_VERSION VERSION_LESS_EQUAL "6.3")
set(WINVER 0x0603) # Minimum supported is Windows 8.1
else()
set(WINVER 0x0A00) # Windows 10/11 by default
endif()
set(CMAKE_DEBUG_POSTFIX "")
add_definitions(-DWINVER=${WINVER} -D_WIN32_WINNT=${WINVER})
endif()
# Dependencies
if(OPENDHT_DOWNLOAD_DEPS)
message(STATUS "Dependency downloader fallback activated")
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
endif()
if (WIN32)
set(MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE) # MSVC CMake cache workaround
endif ()
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
if (NOT MSVC)
# Initialize pkg-config substitution variables for llhttp before any detection
set(http_lib "")
set(llhttp_lib "")
# Generalized UNIX/MSYS2 build pipeline
set (THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package (Threads)
if (OPENDHT_USE_PKGCONFIG)
find_package (PkgConfig REQUIRED)
# GNUTLS
pkg_search_module (GnuTLS REQUIRED IMPORTED_TARGET gnutls)
# libnettle
pkg_search_module (Nettle REQUIRED IMPORTED_TARGET nettle)
# libargon2
pkg_search_module (argon2 REQUIRED IMPORTED_TARGET libargon2)
set(argon2_lib ", libargon2")
# jsoncpp
pkg_search_module (Jsoncpp IMPORTED_TARGET jsoncpp)
if(Jsoncpp_FOUND)
if(APPLE)
set(JSONCPP_LIBRARIES PkgConfig::Jsoncpp)
else()
set(JSONCPP_LIBRARIES ${Jsoncpp_LIBRARIES})
endif()
set(JSONCPP_INCLUDE_DIRS ${Jsoncpp_INCLUDE_DIRS})
set(JSONCPP_FOUND ${Jsoncpp_FOUND})
include_directories(${JSONCPP_INCLUDE_DIRS})
find_package (PkgConfig REQUIRED)
pkg_search_module (GnuTLS REQUIRED IMPORTED_TARGET gnutls)
pkg_search_module (Nettle REQUIRED IMPORTED_TARGET nettle)
check_include_file_cxx(msgpack.hpp HAVE_MSGPACKCXX)
if (NOT HAVE_MSGPACKCXX)
find_package(msgpack QUIET CONFIG NAMES msgpack msgpackc-cxx)
if (NOT msgpack_FOUND)
find_package(msgpack REQUIRED CONFIG NAMES msgpack-cxx)
set(MSGPACK_TARGET "msgpack-cxx")
else()
set(MSGPACK_TARGET "msgpackc-cxx")
endif()
# libfmt
pkg_search_module (fmt REQUIRED IMPORTED_TARGET fmt)
# libreadline
if (OPENDHT_TOOLS AND NOT APPLE)
pkg_search_module(readline REQUIRED IMPORTED_TARGET readline)
message(STATUS "libreadline: version ${readline_VERSION}")
set(READLINE_VERSION ${readline_VERSION})
if(READLINE_VERSION VERSION_LESS 6)
message(SEND_ERROR "libreadline: required version 6.0 or later")
endif()
set(READLINE_LIBRARIES ${readline_LIBRARIES})
endif ()
# ASIO
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
pkg_search_module(asio IMPORTED_TARGET asio)
if (NOT asio_FOUND)
find_path(ASIO_INCLUDE_DIR asio.hpp REQUIRED)
endif()
message(STATUS "Found ASIO: ${ASIO_INCLUDE_DIR}")
endif ()
endif()
if (OPENDHT_TOOLS)
find_package (Readline 6 REQUIRED)
set(readline_LIBRARIES ${READLINE_LIBRARIES})
endif ()
pkg_search_module(argon2 REQUIRED IMPORTED_TARGET libargon2)
set(argon2_lib ", libargon2")
pkg_search_module(Jsoncpp IMPORTED_TARGET jsoncpp)
if (Jsoncpp_FOUND)
add_definitions(-DOPENDHT_JSONCPP)
set(jsoncpp_lib ", jsoncpp")
list (APPEND opendht_SOURCES
src/base64.h
src/base64.cpp
)
endif()
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
find_path(ASIO_INCLUDE_DIR asio.hpp REQUIRED)
message(STATUS "Found ASIO ${ASIO_INCLUDE_DIR}")
else()
message(STATUS "ASIO not required")
endif ()
find_package(fmt)
if (OPENDHT_HTTP)
find_package(Restinio REQUIRED)
# llhttp
if (OPENDHT_HTTP)
pkg_search_module(LLHTTP IMPORTED_TARGET llhttp libllhttp)
if (LLHTTP_FOUND)
message(STATUS "Found llhttp: ${LLHTTP_FOUND} ${LLHTTP_INCLUDE_DIR} (module: ${LLHTTP_MODULE_NAME})")
set(llhttp_target PkgConfig::LLHTTP)
set(llhttp_lib ", ${LLHTTP_MODULE_NAME}")
pkg_search_module(LLHTTP IMPORTED_TARGET llhttp libllhttp)
if (LLHTTP_FOUND)
message(STATUS "Found llhttp ${LLHTTP_INCLUDE_DIRS}")
set(llhttp_target PkgConfig::LLHTTP)
else()
find_path(LLHTTP_INCLUDE_DIR llhttp.h)
find_library(LLHTTP_LIBRARY NAMES llhttp libllhttp)
if (LLHTTP_INCLUDE_DIR AND LLHTTP_LIBRARY)
message(STATUS "Found llhttp ${LLHTTP_INCLUDE_DIR} ${LLHTTP_LIBRARY}")
add_library(llhttp_static STATIC IMPORTED)
set_target_properties(llhttp_static PROPERTIES
IMPORTED_LOCATION ${LLHTTP_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${LLHTTP_INCLUDE_DIR}
)
set(llhttp_target llhttp_static)
else()
message(STATUS "llhttp not found with pkgconfig")
FetchContent_Declare(llhttp-local URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v9.2.1.tar.gz")
if (BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
else()
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(BUILD_STATIC_LIBS ON CACHE INTERNAL "")
endif()
FetchContent_MakeAvailable(llhttp-local)
if (BUILD_SHARED_LIBS)
set(llhttp_target llhttp_shared)
else()
set(llhttp_target llhttp_static)
endif()
endif()
else ()
set(OPENDHT_PROXY_OPENSSL OFF)
endif ()
endif()
set(http_lib "-lllhttp")
if (NOT Jsoncpp_FOUND)
message(SEND_ERROR "Jsoncpp is required for DHT proxy support")
endif()
if (OPENDHT_PROXY_OPENSSL)
# https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
pkg_search_module(OPENSSL REQUIRED IMPORTED_TARGET openssl)
if (OPENSSL_FOUND)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIRS}")
@@ -175,204 +175,102 @@ if (NOT MSVC)
endif()
endif()
else ()
find_package(GnuTLS REQUIRED)
include_directories(${GNUTLS_INCLUDE_DIR})
# jsoncpp
find_package(jsoncpp CONFIG REQUIRED)
set(JSONCPP_FOUND TRUE)
# libfmt
find_package(fmt CONFIG REQUIRED)
# libargon2
find_path(ARGON2_INCLUDE_DIR argon2.h REQUIRED)
set(argon2_lib ", libargon2")
# libreadline
if (OPENDHT_TOOLS)
find_package (Readline 6 REQUIRED)
endif ()
# ASIO
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
find_path(ASIO_INCLUDE_DIR asio.hpp REQUIRED)
message(STATUS "Found ASIO ${ASIO_INCLUDE_DIR}")
else()
message(STATUS "ASIO not required")
endif ()
# llhttp
if (OPENDHT_HTTP)
find_package(llhttp CONFIG REQUIRED)
set(llhttp_target llhttp::llhttp_static)
set(http_lib "-lllhttp")
if (OPENDHT_PROXY_OPENSSL)
find_package(openssl REQUIRED)
endif()
else ()
set(OPENDHT_PROXY_OPENSSL OFF)
endif ()
endif ()
# File-based searches
# msgpack
check_include_file_cxx(msgpack.hpp HAVE_MSGPACKCXX)
if (NOT HAVE_MSGPACKCXX)
find_package(msgpack QUIET CONFIG NAMES msgpack msgpackc-cxx)
if (NOT msgpack_FOUND)
find_package(msgpack QUIET CONFIG NAMES msgpack-cxx)
if (msgpack_FOUND)
set(MSGPACK_TARGET "msgpack-cxx")
else()
if(OPENDHT_DOWNLOAD_DEPS)
# Workaround for msgpack-cxx
FetchContent_Declare(msgpack-c
GIT_REPOSITORY "https://github.com/msgpack/msgpack-c.git"
GIT_TAG "cpp-7.0.0"
FIND_PACKAGE_ARGS NAMES msgpack-c
)
set(MSGPACK_USE_BOOST OFF CACHE INTERNAL "Workaround for Boost")
FetchContent_MakeAvailable(msgpack-c)
find_package(msgpack-c CONFIG REQUIRED)
include_directories(${MSGPACK_INCLUDEDIR} ${msgpack-c_SOURCE_DIR}/include)
else()
message(SEND_ERROR "msgpack not found and the fallback downloader is not set! Please install msgpack or use OPENDHT_DOWNLOAD_DEPS option")
endif()
endif ()
else()
set(MSGPACK_TARGET "msgpackc-cxx")
endif()
endif()
# llhttp
if (OPENDHT_HTTP AND NOT LLHTTP_FOUND)
find_path(LLHTTP_INCLUDE_DIR llhttp.h)
find_library(LLHTTP_LIBRARY NAMES llhttp libllhttp)
if (LLHTTP_INCLUDE_DIR AND LLHTTP_LIBRARY)
message(STATUS "Found llhttp ${LLHTTP_INCLUDE_DIR} ${LLHTTP_LIBRARY}")
add_library(llhttp_static STATIC IMPORTED)
set_target_properties(llhttp_static PROPERTIES
IMPORTED_LOCATION ${LLHTTP_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${LLHTTP_INCLUDE_DIR}
)
set(llhttp_target llhttp_static)
if (NOT llhttp_lib)
set(http_lib "-lllhttp")
endif()
elseif (OPENDHT_DOWNLOAD_DEPS)
message(STATUS "Fallback mode specified, downloading llhttp")
FetchContent_Declare(llhttp-local REQUIRED
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v9.2.1.tar.gz"
)
if (BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
else()
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
set(BUILD_STATIC_LIBS ON CACHE INTERNAL "")
endif()
FetchContent_MakeAvailable(llhttp-local)
include_directories(${llhttp-local_SOURCE_DIR}/include)
link_directories(${llhttp-local_BINARY_DIR}) # MacOS library search workaround
if (BUILD_SHARED_LIBS)
set(llhttp_target llhttp_shared)
else()
set(llhttp_target llhttp_static)
endif()
if (NOT llhttp_lib)
set(http_lib "-lllhttp")
endif()
else()
message(SEND_ERROR "llhttp not found and fallback downloader disabled. Install llhttp or use OPENDHT_DOWNLOAD_DEPS option")
endif ()
endif ()
# restinio: does not provide pkg-config PC file
if(OPENDHT_HTTP)
find_package(Restinio REQUIRED)
set(restinio_target "")
endif()
# System-specific pipeline setup
if(APPLE)
if (OPENDHT_TOOLS)
find_package (Readline 6 REQUIRED)
endif ()
endif()
else () # MSVC
include_directories(src/compat/msvc)
include_directories(src/compat/win32)
find_package(argon2 CONFIG QUIET)
if (NOT argon2_FOUND)
find_package(unofficial-argon2 CONFIG REQUIRED)
endif()
include_directories(${ARGON2_INCLUDEDIR})
set(argon2_lib ", libargon2")
find_package(GnuTLS REQUIRED)
include_directories(${GNUTLS_INCLUDE_DIR})
find_package(msgpack-cxx CONFIG REQUIRED)
get_target_property(MSGPACK_INCLUDEDIR msgpack-cxx INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${MSGPACK_INCLUDEDIR})
find_package(jsoncpp CONFIG REQUIRED)
set(JSONCPP_FOUND TRUE)
include_directories(${JSONCPP_INCLUDE_DIRS})
find_package(fmt CONFIG REQUIRED)
include_directories(${FMT_INCLUDEDIR})
if(OPENDHT_TOOLS)
find_package(unofficial-readline-win32 CONFIG REQUIRED)
include_directories(${READLINE_INCLUDEDIR})
endif()
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
find_package(asio CONFIG REQUIRED)
find_path(ASIO_INCLUDE_DIR asio.hpp REQUIRED HINTS ${ASIO_INCLUDE_DIRS}/asio/include)
message(STATUS "Found ASIO ${ASIO_INCLUDE_DIR}")
else()
message(STATUS "ASIO not required")
endif ()
if (OPENDHT_HTTP)
find_package(restinio CONFIG REQUIRED)
set(restinio_target restinio::restinio)
find_package(llhttp CONFIG REQUIRED)
set(http_lib "-lllhttp")
if (OPENDHT_PROXY_OPENSSL)
find_package(OpenSSL REQUIRED)
set(openssl_lib ", openssl")
endif()
else()
set(OPENDHT_PROXY_OPENSSL OFF)
endif()
message(STATUS "Discovering external non-CMake libraries")
find_library(NETTLE_LIBRARY NAMES nettle libnettle REQUIRED)
find_library(HOGWEED_LIBRARY NAMES hogweed REQUIRED)
find_library(TASN_LIBRARY NAMES tasn1 REQUIRED)
find_path(NETTLE_INCLUDE_DIR nettle/aes.h REQUIRED)
add_library(nettle_lib STATIC IMPORTED)
set_target_properties(nettle_lib PROPERTIES
IMPORTED_LOCATION ${NETTLE_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${NETTLE_INCLUDE_DIR}
)
add_library(hogweed_lib STATIC IMPORTED)
set_target_properties(hogweed_lib PROPERTIES
IMPORTED_LOCATION ${HOGWEED_LIBRARY}
)
add_library(tasn1_lib STATIC IMPORTED)
set_target_properties(tasn1_lib PROPERTIES
IMPORTED_LOCATION ${TASN_LIBRARY}
)
endif ()
endif ()
else ()
# MSVC build - check if using vcpkg first
if (DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
# Using vcpkg - use find_package for dependencies
find_package(msgpack-cxx CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
find_package(jsoncpp CONFIG REQUIRED)
# Find GnuTLS and Nettle libraries (vcpkg doesn't provide CMake targets for these)
find_library(GNUTLS_LIBRARY NAMES gnutls REQUIRED)
find_library(NETTLE_LIBRARY NAMES nettle REQUIRED)
find_library(HOGWEED_LIBRARY NAMES hogweed REQUIRED)
find_library(TASN_LIBRARY NAMES tasn1 REQUIRED)
find_library(ARGON2_LIBRARY NAMES argon2 REQUIRED)
find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h REQUIRED)
find_path(NETTLE_INCLUDE_DIR nettle/aes.h REQUIRED)
find_path(ARGON2_INCLUDE_DIR argon2.h REQUIRED)
# Create imported targets for these libraries
add_library(gnutls_lib STATIC IMPORTED)
set_target_properties(gnutls_lib PROPERTIES
IMPORTED_LOCATION ${GNUTLS_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${GNUTLS_INCLUDE_DIR}
)
add_library(nettle_lib STATIC IMPORTED)
set_target_properties(nettle_lib PROPERTIES
IMPORTED_LOCATION ${NETTLE_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${NETTLE_INCLUDE_DIR}
)
add_library(hogweed_lib STATIC IMPORTED)
set_target_properties(hogweed_lib PROPERTIES
IMPORTED_LOCATION ${HOGWEED_LIBRARY}
)
# Definitions
if(JSONCPP_FOUND)
add_definitions(-DOPENDHT_JSONCPP)
set(jsoncpp_lib ", jsoncpp")
list (APPEND opendht_SOURCES
src/base64.h
src/base64.cpp
)
endif()
add_library(tasn1_lib STATIC IMPORTED)
set_target_properties(tasn1_lib PROPERTIES
IMPORTED_LOCATION ${TASN_LIBRARY}
)
add_library(argon2_lib STATIC IMPORTED)
set_target_properties(argon2_lib PROPERTIES
IMPORTED_LOCATION ${ARGON2_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${ARGON2_INCLUDE_DIR}
)
add_definitions(-DOPENDHT_JSONCPP)
list (APPEND opendht_SOURCES
src/base64.h
src/base64.cpp
)
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
find_package(asio CONFIG REQUIRED)
find_package(llhttp CONFIG REQUIRED)
find_package(restinio CONFIG REQUIRED)
if (OPENDHT_PROXY_OPENSSL)
find_package(OpenSSL REQUIRED)
endif ()
endif ()
if (OPENDHT_TOOLS)
find_package(unofficial-readline-win32 CONFIG)
if (unofficial-readline-win32_FOUND)
set(readline_LIBRARIES unofficial::readline-win32::readline)
else()
set (readline_LIBRARIES "readline")
message(WARNING "unofficial-readline-win32 not found, trying to use system readline")
endif()
endif ()
else()
# Traditional MSVC dependency path
set (WIN32_DEP_DIR ${PROJECT_SOURCE_DIR}/../)
include_directories(${WIN32_DEP_DIR}/../msvc/include) # SMP gnutls
include_directories(${WIN32_DEP_DIR}/argon2/include)
include_directories(${WIN32_DEP_DIR}/jsoncpp/include)
list (APPEND opendht_SOURCES
src/base64.h
src/base64.cpp
)
add_definitions(-DOPENDHT_JSONCPP)
include_directories(${WIN32_DEP_DIR}/msgpack-c/include)
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
include_directories(
${WIN32_DEP_DIR}/asio/asio/include
${WIN32_DEP_DIR}/openssl/include
${WIN32_DEP_DIR}/restinio/dev
${WIN32_DEP_DIR}/fmt/include
${WIN32_DEP_DIR}/llhttp/include
)
endif ()
endif()
endif ()
if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
add_definitions(-DASIO_STANDALONE)
@@ -382,7 +280,7 @@ if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
endif()
if (NOT MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-return-type -Wno-deprecated -Wno-deprecated-declarations -Wno-unknown-pragmas -Wall -Wextra -Wnon-virtual-dtor -pedantic-errors -fvisibility=hidden")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wall -Wextra -Wnon-virtual-dtor -pedantic-errors -fvisibility=hidden")
if (OPENDHT_SANITIZE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fstack-protector-strong")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fstack-protector-strong")
@@ -454,11 +352,11 @@ list (APPEND opendht_SOURCES
list (APPEND opendht_HEADERS
include/opendht.h
include/opendht/def.h
include/opendht/rng.h
include/opendht/infohash.h
include/opendht/utils.h
include/opendht/sockaddr.h
include/opendht/rng.h
include/opendht/crypto.h
include/opendht/infohash.h
include/opendht/default_types.h
include/opendht/node.h
include/opendht/value.h
@@ -484,7 +382,7 @@ if (OPENDHT_PEER_DISCOVERY)
add_definitions(-DOPENDHT_PEER_DISCOVERY)
endif()
if (OPENDHT_PYTHON AND NOT OPENDHT_INDEX)
if (OPENDHT_PYTHON)
message("Indexation enabled since it is required for Python support")
set(OPENDHT_INDEX ON)
endif()
@@ -519,7 +417,7 @@ endif ()
if (OPENDHT_HTTP)
if (OPENDHT_PUSH_NOTIFICATIONS)
message(STATUS "Using push notification capability")
message("Using push notification")
add_definitions(-DOPENDHT_PUSH_NOTIFICATIONS)
endif ()
list (APPEND opendht_HEADERS
@@ -538,126 +436,126 @@ if (MSVC)
endif ()
# Targets
add_library(opendht ${opendht_SOURCES} ${opendht_HEADERS})
target_include_directories(opendht
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
# if (MSVC)
# if (OPENDHT_STATIC)
# if (OPENDHT_TOOLS)
# function (add_obj_lib name libfile)
# add_library(${name} OBJECT IMPORTED)
# set_property(TARGET ${name} PROPERTY IMPORTED_OBJECTS ${libfile})
# endfunction ()
# add_obj_lib (win32_json ${WIN32_DEP_DIR}/../msvc/lib/x64/lib_json.lib)
# add_obj_lib (win32_gnutls ${WIN32_DEP_DIR}/../msvc/lib/x64/libgnutls.lib)
# add_obj_lib (win32_argon2 ${WIN32_DEP_DIR}/argon2/vs2015/Argon2Ref/vs2015/build/Argon2Ref.lib)
# list (APPEND obj_libs
# $<TARGET_OBJECTS:win32_json>
# $<TARGET_OBJECTS:win32_gnutls>
# $<TARGET_OBJECTS:win32_argon2>
# )
# if (OPENDHT_HTTP)
# add_obj_lib (win32_fmt ${WIN32_DEP_DIR}/fmt/msvc/Release/fmt.lib)
# add_obj_lib (win32_llhttp ${WIN32_DEP_DIR}/llhttp/build/Release/llhttp.lib)
# add_obj_lib (win32_ssl ${WIN32_DEP_DIR}/openssl/libssl_static.lib)
# add_obj_lib (win32_crypto ${WIN32_DEP_DIR}/openssl/libcrypto_static.lib)
# list (APPEND obj_libs
# $<TARGET_OBJECTS:win32_fmt>
# $<TARGET_OBJECTS:win32_llhttp>
# $<TARGET_OBJECTS:win32_ssl>
# $<TARGET_OBJECTS:win32_crypto>
# )
# endif ()
# else ()
# list (APPEND win32_Libs
# ${PROJECT_SOURCE_DIR}/../../msvc/lib/x64/libgnutls.lib
# ${PROJECT_SOURCE_DIR}/../../msvc/lib/x64/lib_json.lib
# ${PROJECT_SOURCE_DIR}/../argon2/vs2015/Argon2Ref/vs2015/build/Argon2Ref.lib
# )
# list (APPEND win32_Libs
# ${PROJECT_SOURCE_DIR}/../fmt/msvc/Release/fmt.lib
# ${PROJECT_SOURCE_DIR}/../llhttp/build/Release/llhttp.lib
# ${PROJECT_SOURCE_DIR}/../openssl/libssl.lib
# ${PROJECT_SOURCE_DIR}/../openssl/libcrypto.lib
# )
# endif ()
# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4006")
# endif()
# endif ()
add_library (opendht
${opendht_SOURCES}
${opendht_HEADERS}
${obj_libs}
)
set_target_properties (opendht PROPERTIES OUTPUT_NAME "opendht")
set_target_properties(opendht PROPERTIES OUTPUT_NAME "opendht")
# Linker pipelines
if (MSVC)
message(STATUS "Build pipeline: Windows/MSVC + vcpkg")
message(STATUS "Used GnuTLS library: ${GNUTLS_LIBRARIES}")
message(STATUS "Used NETTLE library: ${NETTLE_LIBRARY}")
target_link_libraries(opendht
PRIVATE
unofficial::argon2::libargon2
nettle_lib
hogweed_lib
tasn1_lib
PUBLIC
${GNUTLS_LIBRARIES}
wsock32
ws2_32
)
if (OPENDHT_TOOLS)
target_link_libraries(opendht PUBLIC unofficial::readline-win32::readline)
endif()
target_link_libraries(opendht PUBLIC msgpack-cxx JsonCpp::JsonCpp fmt::fmt)
if (NOT HAVE_MSGPACKCXX)
target_link_libraries(opendht PUBLIC ${MSGPACK_TARGET})
endif()
if (APPLE)
target_link_libraries(opendht PRIVATE "-framework CoreFoundation" "-framework Security")
endif()
if (WIN32)
target_link_libraries(opendht PUBLIC ws2_32 wsock32)
if (OPENDHT_HTTP)
target_link_libraries(opendht
PUBLIC restinio::restinio
PRIVATE llhttp::llhttp_static)
if (OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif()
target_link_libraries(opendht PUBLIC llhttp::llhttp_static)
target_link_libraries(opendht PRIVATE crypt32)
endif()
else()
if (APPLE)
message(STATUS "Build pipeline: Apple/Darwin")
target_link_libraries(opendht PRIVATE "-framework CoreFoundation" "-framework Security")
endif ()
# Generalized UNIX/MSYS2 build pipeline
if (OPENDHT_USE_PKGCONFIG)
endif()
if (MSVC)
if (DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
# Using vcpkg - link with vcpkg targets
target_link_libraries(opendht
PRIVATE
PkgConfig::argon2
PkgConfig::Nettle
PUBLIC
${CMAKE_THREAD_LIBS_INIT}
PkgConfig::GnuTLS
PkgConfig::fmt
${JSONCPP_LIBRARIES}
msgpack-cxx
fmt::fmt
JsonCpp::JsonCpp
gnutls_lib
PRIVATE
argon2_lib
nettle_lib
hogweed_lib
tasn1_lib
)
if(OPENDHT_TOOLS)
message(STATUS ${READLINE_LIBRARIES})
target_link_libraries(opendht PUBLIC ${READLINE_LIBRARIES})
endif()
if(OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY)
if (asio_FOUND)
target_link_libraries(opendht PUBLIC PkgConfig::asio)
if (OPENDHT_HTTP)
target_link_libraries(opendht
PUBLIC restinio::restinio
PRIVATE llhttp::llhttp_static)
if (OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif()
endif()
if (OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC PkgConfig::OPENSSL)
endif()
else(OPENDHT_USE_PKGCONFIG)
target_link_libraries(opendht
PRIVATE
argon2
nettle
PUBLIC
${CMAKE_THREAD_LIBS_INIT}
${GNUTLS_LIBRARIES}
jsoncpp
)
if(BUILD_SHARED_LIBS)
target_link_libraries(opendht PUBLIC fmt::fmt)
else()
target_link_libraries(opendht PUBLIC fmt::fmt-header-only)
endif()
if(OPENDHT_TOOLS)
target_link_libraries(opendht PUBLIC ${READLINE_LIBRARIES})
endif()
if (OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif()
endif(OPENDHT_USE_PKGCONFIG)
if (NOT HAVE_MSGPACKCXX)
target_link_libraries(opendht PUBLIC ${MSGPACK_TARGET})
endif()
if(OPENDHT_HTTP)
target_link_libraries(opendht
PUBLIC # Required for linking tests
${llhttp_target}
${restinio_target}
if (OPENDHT_STATIC)
target_link_libraries(opendht PUBLIC ${Win32_STATIC_LIBRARIES} ${Win32_IMPORT_LIBRARIES})
endif()
else()
target_link_libraries(opendht
PRIVATE
PkgConfig::argon2
PkgConfig::Nettle
PUBLIC
${CMAKE_THREAD_LIBS_INIT}
PkgConfig::GnuTLS
fmt::fmt
)
if (OPENDHT_HTTP)
target_link_libraries(opendht PUBLIC ${llhttp_target})
endif()
if (Jsoncpp_FOUND)
target_link_libraries(opendht PUBLIC PkgConfig::Jsoncpp)
endif()
if (OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC PkgConfig::OPENSSL)
endif()
if (OPENDHT_IO_URING AND liburing_FOUND)
set(iouring_lib ", liburing")
target_link_libraries(opendht PUBLIC PkgConfig::liburing)
target_compile_definitions(opendht PUBLIC ASIO_HAS_IO_URING ASIO_DISABLE_EPOLL)
endif()
# System-specific linker pipelines
if (WIN32 AND MINGW) # MSYS2
message(STATUS "Build pipeline: Windows/MSYS2-MinGW")
target_link_libraries(opendht PUBLIC wsock32 ws2_32)
if(OPENDHT_PROXY_OPENSSL)
target_link_libraries(opendht PUBLIC Crypt32)
endif()
else() # UNIX / LLVM
message(STATUS "Build pipeline: UNIX generalized")
endif()
endif()
if (BUILD_SHARED_LIBS)
set_target_properties (opendht PROPERTIES IMPORT_SUFFIX "_import.lib")
set_target_properties (opendht PROPERTIES SOVERSION ${opendht_VERSION_MAJOR} VERSION ${opendht_VERSION})
target_compile_definitions(opendht PRIVATE OPENDHT_BUILD)
target_compile_definitions(opendht PRIVATE OPENDHT_BUILD)
target_compile_definitions(opendht PUBLIC opendht_EXPORTS)
endif ()
@@ -667,7 +565,7 @@ install (TARGETS opendht
RUNTIME_DEPENDENCY_SET opendht_rdeps
EXPORT opendht
)
if (WIN32)
if (WIN32 AND DEFINED CMAKE_TOOLCHAIN_FILE AND CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
install(RUNTIME_DEPENDENCY_SET opendht_rdeps
PRE_EXCLUDE_REGEXES
"api-ms-win-.*\\.dll"
@@ -707,12 +605,9 @@ if (OPENDHT_C)
)
target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD)
target_link_libraries(opendht-c PRIVATE opendht)
if(OPENDHT_TOOLS)
target_link_libraries(opendht-c PUBLIC ${READLINE_LIBRARIES})
endif()
if (BUILD_SHARED_LIBS)
target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD)
target_compile_definitions(opendht-c PUBLIC opendht_c_EXPORTS)
target_compile_definitions(opendht-c PUBLIC opendht_EXPORTS)
set_target_properties (opendht-c PROPERTIES SOVERSION ${opendht_VERSION_MAJOR} VERSION ${opendht_VERSION})
endif()
install (TARGETS opendht-c DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht-c)
@@ -741,7 +636,6 @@ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/opendhtConfigVersi
VERSION ${opendht_VERSION}
COMPATIBILITY AnyNewerVersion
)
# PkgConfig module
configure_file (
opendht.pc.in
@@ -754,9 +648,6 @@ install (DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install (EXPORT opendht DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/opendht FILE opendhtConfig.cmake)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendhtConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/opendht)
if(MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:opendht> CONFIGURATIONS "RelWithDebInfo" "Debug" DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
# Unit tests
if (BUILD_TESTING)
@@ -805,13 +696,6 @@ if (BUILD_TESTING)
${CMAKE_THREAD_LIBS_INIT}
${cppunit_LIBRARIES}
)
if (OPENDHT_PROXY_OPENSSL)
if (WIN32 AND MINGW) # MSYS2
target_link_libraries(opendht_unit_tests PRIVATE ${OPENSSL_LIBRARIES})
elseif(NOT MSVC) # Clang on UNIX-pkgconfig
target_link_libraries(opendht_unit_tests PRIVATE PkgConfig::OPENSSL)
endif()
endif()
add_test(TEST opendht_unit_tests)
endif()
+16 -92
View File
@@ -12,34 +12,7 @@
"generator": "Unix Makefiles",
"inherits": "default",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
},
{
"name": "unix-make-full",
"description": "Unix Makefiles (Full build)",
"inherits": "unix-make",
"cacheVariables": {
"OPENDHT_C": true,
"OPENDHT_PROXY_CLIENT": true,
"OPENDHT_PROXY_SERVER": true,
"OPENDHT_PUSH_NOTIFICATIONS": true,
"OPENDHT_PYTHON": true,
"OPENDHT_INDEX": true,
"BUILD_TESTING": true,
"OPENDHT_EXAMPLES": true
}
},
{
"name": "unix-make-release",
"description": "Unix Makefiles (Release build)",
"inherits": "unix-make-full",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": true,
"BUILD_TESTING": false,
"OPENDHT_SANITIZE": false,
"OPENDHT_EXAMPLES": false
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
@@ -47,21 +20,7 @@
"generator": "Ninja",
"inherits": "default",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": true
}
},
{
"name": "ninja-release",
"inherits": "ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": true,
"BUILD_TESTING": false,
"OPENDHT_SANITIZE": false,
"OPENDHT_CPACK": true,
"OPENDHT_C": true,
"OPENDHT_PROXY_CLIENT": true,
"OPENDHT_PROXY_SERVER": true
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
@@ -81,25 +40,17 @@
"inherits": "msvc",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"BUILD_SHARED_LIBS": true,
"BUILD_SHARED_LIBS": "On",
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_MANIFEST_MODE": true
}
},
{
"name": "vcpkg_manifest_static",
"inherits": "vcpkg_manifest",
"cacheVariables": {
"BUILD_SHARED_LIBS": false,
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
}
},
{
"name": "vcpkg_local",
"inherits": "msvc",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"BUILD_SHARED_LIBS": true,
"BUILD_SHARED_LIBS": "On",
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TESTING": true,
"VCPKG_MANIFEST_MODE": false
@@ -119,21 +70,25 @@
},
{
"name": "vcpkg_release_full",
"inherits": "vcpkg_release",
"inherits": "vcpkg_manifest",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"VCPKG_TARGET_TRIPLET": "x64-windows-release",
"VCPKG_OVERLAY_TRIPLETS": "x64-windows-release;x64-windows-rel;x64-windows",
"BUILD_TESTING": false,
"OPENDHT_PROXY_CLIENT": true,
"OPENDHT_PROXY_SERVER": true,
"OPENDHT_C": true,
"OPENDHT_CPACK": true
}
},
{
"name": "vcpkg_release_static",
"inherits": "vcpkg_manifest_static",
"inherits": "vcpkg_manifest",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": "Off",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-release",
"VCPKG_OVERLAY_TRIPLETS": "x64-windows-static-release;x64-windows-static-rel;x64-windows-static",
"BUILD_TESTING": false,
"OPENDHT_CPACK": true,
"OPENDHT_C": false
@@ -141,10 +96,12 @@
},
{
"name": "vcpkg_release_static_full",
"inherits": "vcpkg_manifest_static",
"inherits": "vcpkg_manifest",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": "Off",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-release",
"VCPKG_OVERLAY_TRIPLETS": "x64-windows-static-release;x64-windows-static-rel;x64-windows-static",
"BUILD_TESTING": false,
"OPENDHT_PROXY_CLIENT": true,
"OPENDHT_PROXY_SERVER": true,
@@ -181,7 +138,7 @@
"inherits": "vcpkg_local",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": false,
"BUILD_SHARED_LIBS": "Off",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-release",
"VCPKG_OVERLAY_TRIPLETS": "x64-windows-static-release;x64-windows-static-rel;x64-windows-static",
"BUILD_TESTING": false,
@@ -194,7 +151,7 @@
"inherits": "vcpkg_local",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": false,
"BUILD_SHARED_LIBS": "Off",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-release",
"VCPKG_OVERLAY_TRIPLETS": "x64-windows-static-release;x64-windows-static-rel;x64-windows-static",
"BUILD_TESTING": false,
@@ -203,38 +160,5 @@
"OPENDHT_CPACK": true
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default",
"hidden": true
},
{
"name": "unix-make",
"inherits": "default",
"configurePreset": "unix-make"
},
{
"name": "ninja",
"inherits": "default",
"configurePreset": "ninja"
},
{
"name": "msvc",
"inherits": "default",
"configurePreset": "msvc"
},
{
"name": "vcpkg-dev",
"inherits": "default",
"configurePreset": "vcpkg_manifest"
},
{
"name": "vcpkg-release-static",
"inherits": "default",
"configurePreset": "vcpkg_release_static_full",
"configuration": "Release"
}
]
}
-9
View File
@@ -268,11 +268,6 @@ dht_publickey* dht_certificate_get_publickey(const dht_certificate* c) {
return reinterpret_cast<dht_publickey*>(new PubkeySp(cert->getSharedPublicKey()));
}
#ifdef __cplusplus
} // extern "C"
// Function with internal C++ linkage
#endif
// dht::crypto::Identity
inline dht::crypto::Identity dht_identity_from_c(const dht_identity* cid) {
dht::crypto::Identity id {};
@@ -290,10 +285,6 @@ inline dht_identity dht_identity_to_c(const dht::crypto::Identity& id) {
return cid;
}
#ifdef __cplusplus
extern "C" {
#endif
OPENDHT_C_PUBLIC dht_identity dht_identity_generate(const char* common_name, const dht_identity* ca) {
return dht_identity_to_c(dht::crypto::generateIdentity(common_name, dht_identity_from_c(ca)));
}
-21
View File
@@ -1,21 +0,0 @@
# Windows utility functions and macros
# Determine Windows NT version for compatibility
# https://stackoverflow.com/a/40217291/9560245
macro(get_WIN32_WINNT version)
if(CMAKE_SYSTEM_VERSION)
set(ver ${CMAKE_SYSTEM_VERSION})
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver})
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if("${verMajor}" MATCHES "10")
set(verMajor "A")
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
endif()
# Remove all remaining '.' characters.
string(REPLACE "." "" ver ${ver})
# Prepend each digit with a zero.
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif()
endmacro()
+16 -21
View File
@@ -1,7 +1,7 @@
dnl define macros
m4_define([opendht_major_version], 3)
m4_define([opendht_minor_version], 5)
m4_define([opendht_patch_version], 1)
m4_define([opendht_minor_version], 4)
m4_define([opendht_patch_version], 0)
m4_define([opendht_version],
[opendht_major_version.opendht_minor_version.opendht_patch_version])
@@ -56,25 +56,21 @@ dnl Check for Doxygen
AC_ARG_ENABLE([doc], AS_HELP_STRING([--enable-doc], [Enable documentation generation (doxygen)]))
AS_IF([test "x$enable_doc" = "xyes"], [
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AS_IF([test -z "$DOXYGEN"],
[AC_MSG_ERROR([Doxygen is required to generate the documentation.])])
AS_IF([test -z "$DOXYGEN"], [AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])])
])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
dnl Check for Python
AC_ARG_ENABLE([python], [AS_HELP_STRING([--disable-python], [Disable python binding])])
AS_IF([test "x$enable_python" = "xyes"], [
AM_COND_IF([ENABLE_INDEXATION], [
AM_PATH_PYTHON([3.3],, [:])
AS_IF([test -n "$PYTHON"],[
echo 'import Cython' | $PYTHON
AS_IF([test $? == 0],
[CYTHON=yes],
[AC_MSG_ERROR([Cython not found, but required for Python support.])])
AC_CHECK_PROGS([PIP], [pip3])
AS_IF([test -z "$PIP"],
[AC_MSG_WARN([pip not found - continuing without python uninstall support])])])
], [AC_MSG_ERROR([Python support requires DHT indexation to be turned on.])])])
AC_ARG_ENABLE([python], [AS_HELP_STRING([--disable-python], [Disble python binding])])
AS_IF([test "x$enable_python" != "xno"], [
AM_PATH_PYTHON([3.3],, [:])
AS_IF([test -n "$PYTHON"],[
echo 'import Cython' | $PYTHON
AS_IF([test $? == 0],[CYTHON=yes],[AC_MSG_WARN([Cython not found - continuing without python support])])
AC_CHECK_PROGS([PIP], [pip3])
AS_IF([test -z "$PIP"],[AC_MSG_WARN([pip not found - continuing without python uninstall support])])
])
])
AM_CONDITIONAL([USE_CYTHON], [test -n "$CYTHON"])
AM_CONDITIONAL([HAVE_PIP], [test -n "$PIP"])
@@ -87,7 +83,6 @@ case "${host_os}" in
;;
linux*)
SYS=linux
CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200809L"
;;
darwin*)
SYS=darwin
@@ -159,7 +154,7 @@ AS_IF([test "x$have_jsoncpp" = "xyes"], [
AM_COND_IF(PROXY_CLIENT_OR_SERVER, AC_MSG_ERROR(["JsonCpp is required for proxy/push notification support"]))
])
AC_ARG_WITH([openssl], AS_HELP_STRING([--without-openssl], [Build without OpenSSL support]))
AC_ARG_WITH([openssl], AS_HELP_STRING([--without-openssl], [Build with OpenSSL support]))
AS_IF([test "x$with_openssl" != "xno"],
[PKG_CHECK_MODULES([OpenSSL], [openssl >= 1.1], [have_openssl=yes], [have_openssl=no])],
[have_openssl=no])
@@ -192,8 +187,8 @@ CXXFLAGS="${CXXFLAGS} -DMSGPACK_NO_BOOST -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_
AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT node)]),,build_tools=yes)
AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes)
AM_COND_IF([ENABLE_TOOLS], [
AC_CHECK_HEADERS([readline/readline.h readline/history.h], [],
[AC_MSG_ERROR([Unable to find readline.h. Readline is required for the tools.])
AC_CHECK_HEADERS([readline/readline.h readline/history.h], [], [
AC_MSG_ERROR([unable to find readline.h])
])
])
+1 -1
View File
@@ -12,5 +12,5 @@ if (OPENDHT_DOCUMENTATION)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}/opendht)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc/opendht)
endif()
+1 -1
View File
@@ -1,6 +1,6 @@
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps:latest
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
COPY . opendht
+3 -3
View File
@@ -1,11 +1,11 @@
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps-alpine:latest AS build
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
COPY . opendht
RUN mkdir /install
ENV DESTDIR=/install
ENV DESTDIR /install
RUN cd opendht && mkdir build && cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
@@ -19,7 +19,7 @@ RUN cd opendht && mkdir build && cd build \
-DOPENDHT_SYSTEMD=On \
&& make -j8 && make install
FROM alpine:3.22 AS install
FROM alpine:3.19 AS install
COPY --from=build /install /
RUN apk add --no-cache \
libstdc++ \
+17
View File
@@ -0,0 +1,17 @@
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps-bionic:latest
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
COPY . opendht
RUN cd opendht && mkdir build && cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=On \
-DOPENDHT_C=On \
-DOPENDHT_PEER_DISCOVERY=On \
-DOPENDHT_PYTHON=On \
-DOPENDHT_TOOLS=On \
-DOPENDHT_PROXY_SERVER=On \
-DOPENDHT_PROXY_CLIENT=On \
&& make -j8 && make install \
&& cd ../.. && rm -rf opendht
+6 -4
View File
@@ -1,6 +1,6 @@
FROM ubuntu:24.04
FROM ubuntu:22.04
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
RUN apt-get update && apt-get install -y \
dialog apt-utils \
@@ -8,14 +8,16 @@ RUN apt-get update && apt-get install -y \
&& echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get update && apt-get install -y \
build-essential pkg-config cmake git wget meson \
build-essential pkg-config cmake git wget \
libtool autotools-dev autoconf \
python3-dev python3-setuptools python3-build python3-virtualenv cython3 \
python3-pip python3-dev python3-setuptools python3-build python3-virtualenv \
libncurses5-dev libreadline-dev nettle-dev libcppunit-dev \
libgnutls28-dev libuv1-dev libjsoncpp-dev libargon2-dev \
libssl-dev libfmt-dev libasio-dev libmsgpack-dev \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN pip3 install meson Cython
RUN mkdir /usr/include/nonstd \
&& wget https://raw.githubusercontent.com/martinmoene/expected-lite/master/include/nonstd/expected.hpp \
-O /usr/include/nonstd/expected.hpp
+2 -2
View File
@@ -1,6 +1,6 @@
FROM alpine:3.22
FROM alpine:3.19
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
RUN apk add --no-cache \
build-base cmake ninja git wget \
+36
View File
@@ -0,0 +1,36 @@
FROM ubuntu:18.04
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
RUN echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
RUN apt-get update && apt-get install -y \
apt-transport-https build-essential pkg-config git wget libncurses5-dev libreadline-dev nettle-dev \
libgnutls28-dev libuv1-dev python3-dev python3-setuptools libcppunit-dev libjsoncpp-dev \
libargon2-0-dev \
autotools-dev autoconf libfmt-dev libmsgpack-dev libssl-dev python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN pip3 install --upgrade cmake meson Cython
# libasio-dev (1.10) is too old
RUN echo "** Building a recent version of asio ***" \
&& wget https://github.com/aberaud/asio/archive/a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571.tar.gz \
&& tar -xvf a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571.tar.gz && cd asio-a7d66ef4017d8f1b7f2cef1bb4ba8e23b0961571/asio \
&& ./autogen.sh && ./configure --prefix=/usr --without-boost --disable-examples --disable-tests \
&& make install \
&& cd ../../ && rm -rf asio*
RUN mkdir /usr/include/nonstd \
&& wget https://raw.githubusercontent.com/martinmoene/expected-lite/master/include/nonstd/expected.hpp \
-O /usr/include/nonstd/expected.hpp
RUN echo "*** Downloading RESTinio ***" \
&& mkdir restinio && cd restinio \
&& wget https://github.com/Stiffstream/restinio/releases/download/v.0.7.3/restinio-0.7.3.tar.bz2 \
&& ls -l && tar -xjf restinio-0.7.3.tar.bz2 \
&& cd restinio-0.7.3/dev \
&& cmake -DCMAKE_INSTALL_PREFIX=/usr -DRESTINIO_TEST=Off -DRESTINIO_SAMPLE=Off -DRESTINIO_BENCHMARK=Off \
-DRESTINIO_WITH_SOBJECTIZER=Off -DRESTINIO_DEP_STANDALONE_ASIO=system -DRESTINIO_DEP_LLHTTP=system \
-DRESTINIO_DEP_FMT=system -DRESTINIO_DEP_EXPECTED_LITE=system . \
&& make -j2 && make install \
&& cd ../../ && rm -rf restinio*
+1 -1
View File
@@ -1,6 +1,6 @@
FROM ubuntu:20.04
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
RUN apt-get update && apt-get install -y \
dialog apt-utils \
+3 -3
View File
@@ -1,6 +1,6 @@
FROM ubuntu:24.04
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
RUN apt-get update && apt-get install -y \
dialog apt-utils \
@@ -19,8 +19,8 @@ RUN apt-get update \
RUN pip3 install Cython --break-system-packages
ENV CC=cc
ENV CXX=c++
ENV CC cc
ENV CXX c++
RUN mkdir /usr/include/nonstd \
&& wget https://raw.githubusercontent.com/martinmoene/expected-lite/master/include/nonstd/expected.hpp \
+2 -2
View File
@@ -1,6 +1,6 @@
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps-focal:latest
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps-bionic:latest
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
COPY . opendht
+1 -1
View File
@@ -1,6 +1,6 @@
FROM ghcr.io/savoirfairelinux/opendht/opendht-deps-llvm:latest
LABEL maintainer="Adrien Béraud <adrien.beraud@savoirfairelinux.com>"
LABEL org.opencontainers.image.source=https://github.com/savoirfairelinux/opendht
LABEL org.opencontainers.image.source https://github.com/savoirfairelinux/opendht
COPY . opendht
+35 -3
View File
@@ -124,7 +124,7 @@ public:
}
};
struct OPENDHT_PUBLIC ServerStats {
struct ServerStats {
/** Current number of listen operations */
size_t listenCount {0};
/** Current number of permanent put operations (hash used) */
@@ -149,12 +149,44 @@ public:
/** Node Info **/
std::shared_ptr<NodeInfo> nodeInfo {};
std::string toString() const;
std::string toString() const {
auto ret = fmt::format("Listens: {}, Puts: {}, PushListeners: {}\n"
"Push requests in the last {}: [Android: {}], [iOS: {}], [Unified: {}]\n"
"Requests: {} per second.",
listenCount, putCount, pushListenersCount,
print_duration(lastUpdated - serverStartTime),
androidPush.toString(), iosPush.toString(), unifiedPush.toString(),
requestRate);
if (nodeInfo) {
auto& ipv4 = nodeInfo->ipv4;
if (ipv4.table_depth > 1)
ret += fmt::format("IPv4 Network estimation: {}\n", ipv4.getNetworkSizeEstimation());
auto& ipv6 = nodeInfo->ipv6;
if (ipv6.table_depth > 1)
ret += fmt::format("IPv6 Network estimation: {}\n", ipv6.getNetworkSizeEstimation());
}
return ret;
}
/**
* Build a json object from a NodeStats
*/
Json::Value toJson() const;
Json::Value toJson() const {
Json::Value result;
result["listenCount"] = static_cast<Json::UInt64>(listenCount);
result["putCount"] = static_cast<Json::UInt64>(putCount);
result["totalPermanentPuts"] = static_cast<Json::UInt64>(totalPermanentPuts);
result["pushListenersCount"] = static_cast<Json::UInt64>(pushListenersCount);
result["serverStartTime"] = static_cast<Json::LargestInt>(to_time_t(serverStartTime));
result["lastUpdated"] = static_cast<Json::LargestInt>(to_time_t(lastUpdated));
result["androidPush"] = androidPush.toJson();
result["iosPush"] = iosPush.toJson();
result["unifiedPush"] = unifiedPush.toJson();
result["requestRate"] = requestRate;
if (nodeInfo)
result["nodeInfo"] = nodeInfo->toJson();
return result;
}
};
std::shared_ptr<ServerStats> stats() const { return stats_; }
+2 -3
View File
@@ -1,6 +1,5 @@
project('opendht', 'c', 'cpp', 'cython',
version: '3.5.1',
meson_version: '>=1.1.0',
version: '3.4.0',
default_options: [
'cpp_std=c++17',
'warning_level=3'
@@ -14,7 +13,7 @@ openssl = dependency('openssl', required: get_option('proxy_client'))
jsoncpp = dependency('jsoncpp', required: get_option('proxy_client'))
fmt = dependency('fmt')
llhttp = dependency('llhttp', 'libllhttp', required: get_option('proxy_client'))
io_uring = host_machine.system() == 'linux' ? dependency('liburing', required: false) : disabler()
io_uring = dependency('liburing', required: false)
deps = [fmt, gnutls, nettle, msgpack, argon2, openssl, jsoncpp, llhttp, io_uring]
conf_data = configuration_data()
+1 -1
View File
@@ -8,5 +8,5 @@ Version: @VERSION@
Libs: -L${libdir} -lopendht
Libs.private: @http_lib@ -pthread
Requires: gnutls >= 3.3@jsoncpp_lib@@openssl_lib@
Requires.private: nettle >= 2.4@argon2_lib@@llhttp_lib@@iouring_lib@
Requires.private: nettle >= 2.4@argon2_lib@@iouring_lib@
Cflags: -I${includedir}
+9 -15
View File
@@ -1,25 +1,19 @@
set(CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
configure_file(setup.py.in setup.py)
configure_file(pyproject.toml pyproject.toml COPYONLY)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
add_custom_target(python
COMMAND ${Python3_EXECUTABLE} -m build .
add_custom_target(python ALL
COMMAND python3 setup.py build
DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml)
install(CODE [[
execute_process(
COMMAND "${Python3_EXECUTABLE}" -m pip install --no-deps .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE _pip_result
OUTPUT_FILE "toto" )
if(NOT _pip_result EQUAL 0)
message(FATAL_ERROR "pip install failed with code ${_pip_result}")
endif()
]])
add_custom_target(dist
COMMAND python3 -m build
DEPENDS opendht opendht_cpp.pxd opendht.pyx pyproject.toml)
install(CODE "execute_process(COMMAND python3 setup.py install --root=\$ENV{DESTDIR}/ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
if (OPENDHT_TOOLS)
install(PROGRAMS tools/dhtcluster.py DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME dhtcluster)
endif()
endif()
+3 -3
View File
@@ -8,7 +8,7 @@ noinst_HEADERS = \
PYTHON_INSTALL_RECORD = $(builddir)/install_record.txt
pybuild.stamp:
LDFLAGS="-L$(top_srcdir)/src/.libs" $(PYTHON) -m build .
LDFLAGS="-L$(top_srcdir)/src/.libs" $(PYTHON) setup.py build_ext --inplace
echo stamp > pybuild.stamp
CLEANFILES = pybuild.stamp
@@ -18,8 +18,7 @@ clean-local:
rm -rf $(builddir)/build $(builddir)/*.so $(PYTHON_INSTALL_RECORD)
install-exec-local:
$(PYTHON) -m pip install --no-deps --no-build-isolation . \
--root=$(DESTDIR)/ --prefix=$(prefix)
$(PYTHON) setup.py install --root=$(DESTDIR)/ --record $(PYTHON_INSTALL_RECORD)
rm -rf $(builddir)/build
if HAVE_PIP
@@ -28,3 +27,4 @@ uninstall-local:
endif
endif
+12 -5
View File
@@ -5,20 +5,27 @@
# distutils: libraries = opendht gnutls
# cython: language_level=3
#
# Copyright (C) 2014-2025 Savoir-faire Linux Inc.
# Copyright (c) 2015-2023 Savoir-faire Linux Inc.
# Author(s): Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
# Adrien Béraud <adrien.beraud@savoirfairelinux.com>
# Simon Désaulniers <sim.desaulniers@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# This wrapper is written for Cython 0.22
#
# This file is part of OpenDHT Python Wrapper.
#
# OpenDHT Python Wrapper is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# OpenDHT Python Wrapper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# along with OpenDHT Python Wrapper. If not, see <https://www.gnu.org/licenses/>.
from libcpp.map cimport map as map
from libcpp cimport bool
+7 -5
View File
@@ -1,17 +1,19 @@
# Copyright (C) 2014-2025 Savoir-faire Linux Inc.
# Copyright (c) 2015-2023 Savoir-faire Linux Inc.
# Author(s): Adrien Béraud <adrien.beraud@savoirfairelinux.com>
# Simon Désaulniers <sim.desaulniers@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# along with this program; If not, see <https://www.gnu.org/licenses/>.
from libc.stdint cimport *
from libcpp cimport bool, nullptr_t, nullptr
+22 -13
View File
@@ -1,17 +1,25 @@
# Copyright (C) 2014-2025 Savoir-faire Linux Inc.
# Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
# Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# A Python3 wrapper to access to OpenDHT API
# This wrapper is written for Cython 0.22
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# This file is part of OpenDHT Python Wrapper.
#
# OpenDHT Python Wrapper is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenDHT Python Wrapper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenDHT Python Wrapper. If not, see <https://www.gnu.org/licenses/>.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from setuptools import setup, Extension
from Cython.Build import cythonize
@@ -22,13 +30,14 @@ setup(name="opendht",
description="Python wrapper for OpenDHT",
url='https://github.com/savoirfairelinux/opendht',
author="Adrien Béraud, Guillaume Roguez, Simon Désaulniers",
license="GPL-3.0-or-later",
license="GPLv3",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Distributed Computing',
'Topic :: System :: Networking',
'Topic :: System :: Networking'
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
],
@@ -36,11 +45,11 @@ setup(name="opendht",
ext_modules = cythonize(Extension(
"opendht",
["@CURRENT_SOURCE_DIR@/opendht.pyx"],
include_dirs = ['@PROJECT_SOURCE_DIR@/include'],
language="c++",
extra_compile_args=["-std=c++17"],
extra_link_args=["-std=c++17"],
libraries=["opendht"],
include_dirs = ['@PROJECT_SOURCE_DIR@/include'],
library_dirs = ['@CURRENT_BINARY_DIR@', '@PROJECT_BINARY_DIR@']
))
)
+6 -5
View File
@@ -1,18 +1,19 @@
#!/usr/bin/env python3
# Copyright (C) 2014-2025 Savoir-faire Linux Inc.
# Copyright (c) 2015-2023 Savoir-faire Linux Inc.
# Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
#
# This program is free software: you can redistribute it and/or modify
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# along with this program; If not, see <http://www.gnu.org/licenses/>.
import time, sys, os
from pprint import pprint
+2
View File
@@ -51,4 +51,6 @@
typedef int mode_t;
#include <BaseTsd.h>
#define usleep(x) Sleep((x) / 1000)
#endif
-41
View File
@@ -100,47 +100,6 @@ private:
std::shared_ptr<Logger> m_logger;
};
std::string
DhtProxyServer::ServerStats::toString() const
{
auto ret = fmt::format("Listens: {}, Puts: {}, PushListeners: {}\n"
"Push requests in the last {}: [Android: {}], [iOS: {}], [Unified: {}]\n"
"Requests: {} per second.",
listenCount, putCount, pushListenersCount,
print_duration(lastUpdated - serverStartTime),
androidPush.toString(), iosPush.toString(), unifiedPush.toString(),
requestRate);
if (nodeInfo) {
auto& ipv4 = nodeInfo->ipv4;
if (ipv4.table_depth > 1)
ret += fmt::format("IPv4 Network estimation: {}\n", ipv4.getNetworkSizeEstimation());
auto& ipv6 = nodeInfo->ipv6;
if (ipv6.table_depth > 1)
ret += fmt::format("IPv6 Network estimation: {}\n", ipv6.getNetworkSizeEstimation());
}
return ret;
}
Json::Value
DhtProxyServer::ServerStats::toJson() const
{
Json::Value result;
result["listenCount"] = static_cast<Json::UInt64>(listenCount);
result["putCount"] = static_cast<Json::UInt64>(putCount);
result["totalPermanentPuts"] = static_cast<Json::UInt64>(totalPermanentPuts);
result["pushListenersCount"] = static_cast<Json::UInt64>(pushListenersCount);
result["serverStartTime"] = static_cast<Json::LargestInt>(to_time_t(serverStartTime));
result["lastUpdated"] = static_cast<Json::LargestInt>(to_time_t(lastUpdated));
result["androidPush"] = androidPush.toJson();
result["iosPush"] = iosPush.toJson();
result["unifiedPush"] = unifiedPush.toJson();
result["requestRate"] = requestRate;
if (nodeInfo)
result["nodeInfo"] = nodeInfo->toJson();
return result;
}
restinio::request_handling_status_t
DhtProxyServer::serverError(restinio::request_t& request) {
auto response = initHttpResponse(request.create_response(restinio::status_internal_server_error()));
-7
View File
@@ -20,13 +20,6 @@
#include "config.h"
#endif
#if defined(_WIN32) && (_WIN32_WINNT < 0x0502) && (NTDDI_VERSION >= NTDDI_VISTA)
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <winsock2.h>
#include <ws2tcpip.h>
#include <io.h>
#endif // inet_pton() workaround for MSVC in Windows 10/11
#include "utils.h"
#include "sockaddr.h"
#include "default_types.h"
+1 -1
View File
@@ -73,7 +73,7 @@ std::ostream& operator<< (std::ostream& s, const Value& v)
s << "data(" << v.user_type << "):";
if (v.user_type == "text/plain") {
s << '"';
s.write(reinterpret_cast<const char*>(v.data.data()), v.data.size());
s.write((const char*)v.data.data(), v.data.size());
s << '"';
} else if (v.data.size() < 1024) {
s << toHex(v.data.data(), v.data.size());
+1 -1
View File
@@ -328,7 +328,7 @@ DhtRunnerTester::testIdOps() {
cv.notify_all();
});
node1.putEncrypted(key, node2.getPublicKey(), std::make_shared<dht::Value>("yo"), [&](bool ok){
node1.putEncrypted(key, node2.getPublicKey(), dht::Value("yo"), [&](bool ok){
CPPUNIT_ASSERT(ok);
std::lock_guard<std::mutex> lk(mutex);
valueCount++;
+7 -15
View File
@@ -9,19 +9,18 @@ function (configure_tool name extra_files)
add_dependencies(${name} opendht)
if (MSVC)
target_sources(${name} PRIVATE ${MSC_COMPAT_SOURCES})
target_link_libraries (${name} PUBLIC opendht wsock32 ws2_32)
target_link_libraries (${name} PUBLIC opendht)
target_include_directories (${name} PRIVATE SYSTEM ${MSC_COMPAT_DIR} ${MSVC_COMPAT_DIR})
else()
target_link_libraries (${name} LINK_PUBLIC opendht ${READLINE_LIBRARIES})
target_link_libraries (${name} LINK_PUBLIC opendht ${readline_LIBRARIES})
target_include_directories (${name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif ()
endfunction ()
configure_tool (dhtnode tools_common.h)
if (OPENDHT_EXAMPLES)
configure_tool (dhtscanner tools_common.h)
configure_tool (dhtchat tools_common.h)
endif ()
configure_tool (dhtscanner tools_common.h)
configure_tool (dhtchat tools_common.h)
if (NOT MSVC)
configure_tool (perftest tools_common.h)
endif ()
@@ -32,14 +31,13 @@ endif ()
if (OPENDHT_C)
add_executable (dhtcnode dhtcnode.c)
add_dependencies(dhtcnode opendht-c)
target_link_libraries (dhtcnode PUBLIC opendht-c)
target_link_libraries (dhtcnode PUBLIC opendht-c ${readline_LIBRARIES})
target_include_directories (dhtcnode SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/c)
if (WIN32)
target_link_libraries (dhtcnode PUBLIC ws2_32)
endif()
if (MSVC)
target_sources(dhtcnode PRIVATE ${MSC_COMPAT_SOURCES})
target_link_libraries(dhtcnode PRIVATE unofficial::readline-win32::readline)
target_include_directories (dhtcnode SYSTEM PRIVATE ${MSC_COMPAT_DIR} ${MSVC_COMPAT_DIR})
endif()
endif ()
@@ -48,15 +46,9 @@ if (NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR bin)
endif ()
install (TARGETS dhtnode RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (OPENDHT_EXAMPLES)
install (TARGETS dhtscanner dhtchat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif ()
install (TARGETS dhtnode dhtscanner dhtchat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if(MSVC)
install(FILES $<TARGET_PDB_FILE:dhtnode> CONFIGURATIONS "Debug" "RelWithDebInfo" DESTINATION ${CMAKE_INSTALL_BINDIR})
if (OPENDHT_EXAMPLES)
install(FILES $<TARGET_PDB_FILE:dhtscanner> $<TARGET_PDB_FILE:dhtchat> CONFIGURATIONS "Debug" "RelWithDebInfo" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
install(FILES $<TARGET_PDB_FILE:dhtnode> $<TARGET_PDB_FILE:dhtscanner> $<TARGET_PDB_FILE:dhtchat> CONFIGURATIONS "Debug" "RelWithDebInfo" DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (OPENDHT_SYSTEMD)
+1 -8
View File
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <stdatomic.h>
#include <inttypes.h>
#include <time.h>
#ifdef _MSC_VER
#include "wingetopt.h"
@@ -34,7 +33,6 @@
#include <readline/readline.h>
#include <readline/history.h>
#ifdef _WIN32
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#else
@@ -298,12 +296,7 @@ int main(int argc, char **argv)
// Wait until shutdown callback is called
while (!atomic_load(&ctx.stop)) {
#ifdef _WIN32
Sleep(10); // 10ms
#else
struct timespec ts = {0, 10000000}; // 10ms
nanosleep(&ts, NULL);
#endif
usleep(10000);
}
dht_runner_delete(runner);
return EXIT_SUCCESS;
+12 -12
View File
@@ -34,21 +34,21 @@
#include <fmt/ranges.h>
#ifndef _WIN32
#if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32__) && !defined(__NT__)
#pragma message "Building on UNIX-like platform, linking system getopt"
#include <getopt.h>
#include <readline/readline.h>
#include <readline/history.h>
#endif
#ifdef _MSC_VER
#pragma message("Building on WIN32 platform using MSVC, linking wingetopt")
#include "wingetopt.h"
#endif
#if defined(__MINGW32__) || defined (__MINGW64__)
#pragma message "Building on MinGW, linking system-wide getopt"
#include <getopt.h>
#include <readline/readline.h>
#include <readline/history.h>
#else
#ifdef _MSC_VER
#pragma message("Building on WIN32 platform using MSVC, linking wingetopt")
#include "wingetopt.h"
#endif
#if defined(__MINGW32__) || defined (__MINGW64__)
#pragma message "Building on MinGW, linking system-wide getopt"
#include <getopt.h>
#include <readline/readline.h>
#include <readline/history.h>
#endif
#endif
#if defined(_MSC_VER) || defined(__MINGW32__) || defined (__MINGW64__)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"default-registry": {
"kind": "git",
"baseline": "dd3097e305afa53f7b4312371f62058d2e665320",
"baseline": "654410ee8e11f0610c11a4a49a8827a84be5e187",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "opendht",
"version-string": "3.5.1",
"version-string": "3.4.0",
"port-version": 1,
"description": "OpenDHT is a distributed hash table (DHT) implementation that provides a decentralized and fault-tolerant way to store and retrieve data across a network of nodes.",
"homepage": "https://opendht.net",