From: Alexandre Viau Date: Fri, 1 Jan 2021 19:02:19 +0000 (-0500) Subject: Import opendht_2.1.10.orig.tar.gz X-Git-Tag: archive/raspbian/3.0.1-1.1+rpi1~1^2^2^2^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6799a071136080773333f9173008071f4216da6e;p=opendht.git Import opendht_2.1.10.orig.tar.gz [dgit import orig opendht_2.1.10.orig.tar.gz] --- 6799a071136080773333f9173008071f4216da6e diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..26374af --- /dev/null +++ b/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*,clang-diagnostic-*,performance-*,bugprone-*,llvm-*,clang-analyzer-*,misc-*,-llvm-namespace-comment,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-llvm-header-guard,-llvm-include-order,-bugprone-suspicious-string-compare' diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 0000000..8e0321e --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -0,0 +1,34 @@ +name: C/C++ CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: deps + run: | + sudo apt install libncurses5-dev libreadline-dev nettle-dev \ + libgnutls28-dev libuv1-dev cython3 python3-dev python3-setuptools libcppunit-dev libjsoncpp-dev \ + autotools-dev autoconf libfmt-dev libhttp-parser-dev libmsgpack-dev + - name: autogen + run: ./autogen.sh + - name: argon2 + run: | + cd argon2 && make && sudo make install && cd .. + - name: asio + run: | + wget https://github.com/aberaud/asio/archive/b2b7a1c166390459e1c169c8ae9ef3234b361e3f.tar.gz \ + && tar -xvf b2b7a1c166390459e1c169c8ae9ef3234b361e3f.tar.gz && cd asio-b2b7a1c166390459e1c169c8ae9ef3234b361e3f/asio \ + && ./autogen.sh && ./configure --prefix=/usr --without-boost --disable-examples --disable-tests \ + && sudo make install \ + && cd ../../ && rm -rf asio* + - name: configure + run: ./configure + - name: make + run: make + - name: make check + run: make check diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0165417 --- /dev/null +++ b/.gitignore @@ -0,0 +1,75 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Autotools +/ac +Makefile +Makefile.in +/aclocal.m4 +/autom4te.cache/ +/config.* +/configure +/depcomp +/install-sh +/libtool +/ltmain.sh +/m4/ +/missing +/stamp-h? +.deps/ +.dirstamp +.libs/ +*.l[ao] +*~ +*.pc + +# KDevelop +.kdev4/ +*.kdev4 + +# VSCode +.vscode/* + +# Eclipse CDT +.cproject +.project +.autotools +language.settings.xml + +# Python +*.pyc +*.stamp +python/opendht.cpp +python/setup.py + +# Doxygen +doc/Doxyfile + +# git backup files +*.orig + +# vim swap files +*.swp +*.swo + +# build dir +build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ef38b69 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "argon2"] + path = argon2 + url = https://github.com/P-H-C/phc-winner-argon2 + ignore = dirty diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2c45aa2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,67 @@ +dist: xenial +sudo: required + +services: + - docker + +language: cpp + +env: + matrix: + - OPENDHT_TEST_JOB="opendht.classic" + - OPENDHT_TEST_JOB="opendht.llvm" + - OPENDHT_TEST_JOB="opendht.proxyserver" + - OPENDHT_TEST_JOB="opendht.proxyclient" + - OPENDHT_TEST_JOB="opendht.push" + +before_install: + - | + if [[ "$OPENDHT_TEST_JOB" == *"opendht.classic"* ]]; then + docker pull aberaud/opendht-deps-bionic; + fi + if [[ "$OPENDHT_TEST_JOB" == *"opendht.proxyclient"* ]] || [[ "$OPENDHT_TEST_JOB" == *"opendht.proxyserver"* ]] || [[ "$OPENDHT_TEST_JOB" == *"opendht.push"* ]]; then + docker pull aberaud/opendht-deps; + fi + if [[ "$OPENDHT_TEST_JOB" == *"opendht.llvm"* ]]; then + docker pull aberaud/opendht-deps-llvm + fi + +script: + - | + # classic build + if [[ "$OPENDHT_TEST_JOB" == *"opendht.classic"* ]]; then + docker build -t opendht -f docker/DockerfileTravis .; + fi + + - | + # proxy builds + if [[ "$OPENDHT_TEST_JOB" != *"opendht.llvm"* ]] && [[ "$OPENDHT_TEST_JOB" != *"opendht.classic"* ]]; then + docker build -t opendht-proxy -f docker/DockerfileTravisProxy .; + options='-DOPENDHT_SANITIZE=On '; + if [[ "$OPENDHT_TEST_JOB" == *"opendht.proxyserver"* ]] || [[ "$OPENDHT_TEST_JOB" == *"opendht.push"* ]]; then + options+='-DOPENDHT_PROXY_SERVER=ON '; + else + options+='-DOPENDHT_PROXY_SERVER=OFF '; + fi + if [[ "$OPENDHT_TEST_JOB" == *"opendht.proxyclient"* ]] || [[ "$OPENDHT_TEST_JOB" == *"opendht.push"* ]]; then + options+='-DOPENDHT_PROXY_CLIENT=ON '; + else + options+='-DOPENDHT_PROXY_CLIENT=OFF '; + fi + if [[ "$OPENDHT_TEST_JOB" == *"opendht.push"* ]]; then + options+='-DOPENDHT_PUSH_NOTIFICATIONS=ON '; + else + options+='-DOPENDHT_PUSH_NOTIFICATIONS=OFF '; + fi + docker run opendht-proxy /bin/sh -c "cd /root/opendht && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr -DOPENDHT_PYTHON=ON -DOPENDHT_LTO=ON -DOPENDHT_TESTS=ON $options .. && make -j8 && ./opendht_unit_tests && make install"; + fi + + - | + # llvm build + if [[ "$OPENDHT_TEST_JOB" == *"opendht.llvm"* ]]; then + docker build -f docker/DockerfileTravisLlvm . + fi + +notifications: + email: + - adrien.beraud@savoirfairelinux.com diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9fff55d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,539 @@ +cmake_minimum_required (VERSION 3.1) +project (opendht) + +include(CMakePackageConfigHelpers) +include(CMakeDependentOption) +include(FindPkgConfig) +include(cmake/CheckAtomic.cmake) + +set (opendht_VERSION_MAJOR 2) +set (opendht_VERSION_MINOR 1.9) +set (opendht_VERSION ${opendht_VERSION_MAJOR}.${opendht_VERSION_MINOR}) +set (PACKAGE_VERSION ${opendht_VERSION}) +set (VERSION "${opendht_VERSION}") + +# Options +option (OPENDHT_STATIC "Build static library" ON) +option (OPENDHT_SHARED "Build shared library" ON) +option (OPENDHT_LOG "Build with logs" ON) +option (OPENDHT_PYTHON "Build Python bindings" OFF) +option (OPENDHT_TOOLS "Build DHT tools" ON) +option (OPENDHT_SYSTEMD "Install systemd module" OFF) +option (OPENDHT_SYSTEMD_UNIT_FILE_LOCATION "Where to install systemd unit file") +option (OPENDHT_ARGON2 "Use included argon2 sources" OFF) +option (OPENDHT_LTO "Build with LTO" OFF) +option (OPENDHT_SANITIZE "Build with address sanitizer and stack protector" OFF) +option (OPENDHT_PROXY_SERVER "Enable DHT proxy server, use Restinio and jsoncpp" OFF) +option (OPENDHT_PUSH_NOTIFICATIONS "Enable push notifications support" OFF) +option (OPENDHT_PROXY_SERVER_IDENTITY "Allow clients to use the node identity" OFF) +option (OPENDHT_PROXY_CLIENT "Enable DHT proxy client, use Restinio and jsoncpp" OFF) +option (OPENDHT_PROXY_OPENSSL "Build DHT proxy with OpenSSL" ON) +option (OPENDHT_PROXY_HTTP_PARSER_FORK "Build DHT proxy with custom http_parser to support old API" OFF) +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_INDEX "Build DHT indexation feature" OFF) +option (OPENDHT_TESTS "Add unit tests executable" OFF) +option (OPENDHT_TESTS_NETWORK "Enable unit tests that require network access" ON) +option (OPENDHT_C "Build C bindings" OFF) + +find_package(Doxygen) +option (OPENDHT_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" ${DOXYGEN_FOUND}) + +# Dependencies +list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +if (NOT MSVC) + set (THREADS_PREFER_PTHREAD_FLAG TRUE) + find_package (Threads) + find_package (PkgConfig REQUIRED) + find_package (GnuTLS 3.3 REQUIRED) + pkg_search_module (Nettle nettle) + find_package (Msgpack 1.2 REQUIRED) + if (OPENDHT_TOOLS) + find_package (Readline 6 REQUIRED) + endif () + if (NOT OPENDHT_ARGON2) + pkg_search_module(argon2 libargon2) + if (argon2_FOUND) + message("-- Found Argon2: " ${argon2_LIBRARY_DIRS} " (found version \"" ${argon2_VERSION} "\")") + link_directories (${argon2_LIBRARY_DIRS}) + else () + message("Argon2 not found, using included version.") + set(OPENDHT_ARGON2 ON) + endif() + endif () + + pkg_search_module(Jsoncpp jsoncpp) + if (Jsoncpp_FOUND) + add_definitions(-DOPENDHT_JSONCPP) + list (APPEND opendht_SOURCES + src/base64.h + src/base64.cpp + ) + endif() + + if (OPENDHT_HTTP) + find_path(ASIO_INCLUDE_DIR asio.hpp REQUIRED) + find_package(Restinio REQUIRED) + find_library(FMT_LIBRARY fmt) + add_library(fmt SHARED IMPORTED) + find_library(HTTP_PARSER_LIBRARY http_parser) + add_library(http_parser SHARED IMPORTED) + 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 openssl) + if (OPENSSL_FOUND) + message(STATUS "Found OpenSSL ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIRS}") + include_directories(SYSTEM ${OPENSSL_INCLUDE_DIRS}) + link_directories (${OPENSSL_LIBRARY_DIRS}) + else () + message(SEND_ERROR "OpenSSL is required for DHT proxy as specified") + endif() + endif() + if (OPENDHT_PROXY_HTTP_PARSER_FORK) + add_definitions(-DOPENDHT_PROXY_HTTP_PARSER_FORK) + endif() + else () + set(OPENDHT_PROXY_OPENSSL OFF) + endif () +else () + 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}/http_parser + ) + endif () +endif () + +if (OPENDHT_HTTP OR OPENDHT_PEER_DISCOVERY) + add_definitions(-DASIO_STANDALONE) +endif() + +# Build flags +set (CMAKE_CXX_STANDARD 14) +set (CMAKE_CXX_STANDARD_REQUIRED on) + +if (NOT MSVC) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -pedantic-errors -fvisibility=hidden") + if (OPENDHT_SANITIZE) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fstack-protector-strong") + endif () +else () + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS + -D_CRT_SECURE_NO_WARNINGS + -DWIN32_LEAN_AND_MEAN + -DSTATIC_GETOPT + -DGNUTLS_INTERNAL_BUILD) + set(DISABLE_MSC_WARNINGS "/wd4101 /wd4244 /wd4267 /wd4273 /wd4804 /wd4834 /wd4996") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DISABLE_MSC_WARNINGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") +endif () +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT") + +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif () +add_definitions(-DPACKAGE_VERSION="${opendht_VERSION}") +if (OPENDHT_LOG) + add_definitions(-DOPENDHT_LOG=true) +else () + add_definitions(-DOPENDHT_LOG=false) +endif() +if (OPENDHT_LTO AND NOT MSVC) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") + if (CMAKE_COMPILER_IS_GNUCC) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-linker-plugin") + set (CMAKE_AR "gcc-ar") + set (CMAKE_NM "gcc-nm") + set (CMAKE_RANLIB "gcc-ranlib") + endif () +endif () + +if (MSGPACK_INCLUDE_DIRS) + include_directories (SYSTEM "${MSGPACK_INCLUDE_DIRS}") +endif () +if (GNUTLS_INCLUDE_DIRS) + include_directories (SYSTEM "${GNUTLS_INCLUDE_DIRS}") +endif () +if (Nettle_INCLUDE_DIRS) + include_directories (SYSTEM "${Nettle_INCLUDE_DIRS}") +endif () +if (ASIO_INCLUDE_DIR) + include_directories (SYSTEM "${ASIO_INCLUDE_DIR}") +endif () +if (Restinio_INCLUDE_DIR) + include_directories (SYSTEM "${Restinio_INCLUDE_DIR}") +endif () +if (Jsoncpp_INCLUDE_DIRS) + include_directories (SYSTEM "${Jsoncpp_INCLUDE_DIRS}") +endif () +link_directories (${Nettle_LIBRARY_DIRS}) +link_directories (${Jsoncpp_LIBRARY_DIRS}) +include_directories ( + ./ + include/ + include/opendht/ + ${CMAKE_CURRENT_BINARY_DIR}/include/ +) + +# Install dirs +include (GNUInstallDirs) +set (prefix ${CMAKE_INSTALL_PREFIX}) +set (exec_prefix "\${prefix}") +set (libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") +set (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +set (bindir "${CMAKE_INSTALL_FULL_BINDIR}") +set (sysconfdir "${CMAKE_INSTALL_FULL_SYSCONFDIR}") +set (top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}") + +# Sources +list (APPEND opendht_SOURCES + src/utils.cpp + src/infohash.cpp + src/crypto.cpp + src/default_types.cpp + src/node.cpp + src/value.cpp + src/dht.cpp + src/op_cache.cpp + src/storage.h + src/listener.h + src/search.h + src/value_cache.h + src/op_cache.h + src/net.h + src/parsed_message.h + src/request.h + src/callbacks.cpp + src/routing_table.cpp + src/node_cache.cpp + src/network_engine.cpp + src/securedht.cpp + src/dhtrunner.cpp + src/log.cpp + src/network_utils.cpp + src/thread_pool.cpp +) + +list (APPEND opendht_HEADERS + include/opendht/def.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 + include/opendht/dht.h + include/opendht/dht_interface.h + include/opendht/callbacks.h + include/opendht/routing_table.h + include/opendht/node_cache.h + include/opendht/network_engine.h + include/opendht/scheduler.h + include/opendht/rate_limiter.h + include/opendht/securedht.h + include/opendht/log.h + include/opendht/log_enable.h + include/opendht/thread_pool.h + include/opendht/network_utils.h + include/opendht.h +) + +if (OPENDHT_PEER_DISCOVERY) + list (APPEND opendht_SOURCES src/peer_discovery.cpp) + list (APPEND opendht_HEADERS include/opendht/peer_discovery.h) + add_definitions(-DOPENDHT_PEER_DISCOVERY) +endif() + +if (OPENDHT_PYTHON) + message("Indexation enabled since it is required for Python support") + set(OPENDHT_INDEX ON) +endif() +if (OPENDHT_INDEX) + list (APPEND opendht_SOURCES src/indexation/pht.cpp) + list (APPEND opendht_HEADERS include/opendht/indexation/pht.h) + add_definitions(-DOPENDHT_INDEXATION) +endif() + +if (OPENDHT_PROXY_SERVER) + add_definitions(-DOPENDHT_PROXY_SERVER) + if (OPENDHT_PROXY_SERVER_IDENTITY) + add_definitions(-DOPENDHT_PROXY_SERVER_IDENTITY) + endif() + list (APPEND opendht_HEADERS + include/opendht/dht_proxy_server.h + ) + list (APPEND opendht_SOURCES + src/dht_proxy_server.cpp + ) +endif () + +if (OPENDHT_PROXY_CLIENT) + add_definitions(-DOPENDHT_PROXY_CLIENT) + list (APPEND opendht_HEADERS + include/opendht/dht_proxy_client.h + ) + list (APPEND opendht_SOURCES + src/dht_proxy_client.cpp + ) +endif () + +if (OPENDHT_HTTP) + if (OPENDHT_PUSH_NOTIFICATIONS) + message("Using push notification") + add_definitions(-DOPENDHT_PUSH_NOTIFICATIONS) + endif () + list (APPEND opendht_HEADERS + include/opendht/proxy.h + include/opendht/http.h + src/compat/os_cert.h + ) + list (APPEND opendht_SOURCES + src/http.cpp + src/compat/os_cert.cpp + ) +endif () + +if(OPENDHT_ARGON2) + # make sure argon2 submodule is up to date and initialized + message("Initializing Argon2 submodule") + execute_process(COMMAND git submodule update --init) + + # add local argon2 files to build + list (APPEND opendht_SOURCES + argon2/src/argon2.c + argon2/src/core.c + argon2/src/blake2/blake2b.c + argon2/src/thread.c + argon2/src/ref.c + argon2/src/encoding.c + ) + include_directories(argon2/include/) +endif() + +if (MSVC) + list (APPEND opendht_HEADERS src/compat/msvc/unistd.h) +endif () + +# Targets +if (OPENDHT_STATIC) + if (NOT MSVC) + add_library (opendht-static STATIC + ${opendht_SOURCES} + ${opendht_HEADERS} + ) + set_target_properties (opendht-static PROPERTIES OUTPUT_NAME "opendht") + if (OPENDHT_ARGON2) + target_include_directories(opendht-static SYSTEM PRIVATE argon2) + else () + target_include_directories(opendht-static SYSTEM PRIVATE ${argon2_INCLUDE_DIRS}) + endif () + target_link_libraries(opendht-static + PRIVATE ${argon2_LIBRARIES} + PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${GNUTLS_LIBRARIES} ${Nettle_STATIC_LIBRARIES} + ${Jsoncpp_STATIC_LIBRARIES} ${FMT_LIBRARY} ${HTTP_PARSER_LIBRARY} + ${OPENSSL_STATIC_LIBRARIES}) + else () + 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 + $ + $ + $ + ) + if (OPENDHT_HTTP) + add_obj_lib (win32_fmt ${WIN32_DEP_DIR}/fmt/msvc/Release/fmt.lib) + add_obj_lib (win32_http_parser ${WIN32_DEP_DIR}/http_parser/x64/Release/http-parser.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 + $ + $ + $ + $ + ) + 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}/../http_parser/x64/Release/http-parser.lib + ${PROJECT_SOURCE_DIR}/../openssl/libssl.lib + ${PROJECT_SOURCE_DIR}/../openssl/libcrypto.lib + ) + endif () + add_library (opendht-static STATIC + ${opendht_SOURCES} + ${opendht_HEADERS} + ${obj_libs} + ) + target_link_libraries(opendht-static PUBLIC ${Win32_STATIC_LIBRARIES} ${Win32_IMPORT_LIBRARIES}) + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4006") + set_target_properties (opendht-static PROPERTIES OUTPUT_NAME "libopendht") + endif() + install (TARGETS opendht-static DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht) +endif () + +if (OPENDHT_SHARED) + add_library (opendht SHARED + ${opendht_SOURCES} + ${opendht_HEADERS} + ) + 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) + if (OPENDHT_ARGON2) + target_include_directories(opendht SYSTEM PRIVATE argon2) + else () + target_link_libraries(opendht PRIVATE ${argon2_LIBRARIES}) + target_include_directories(opendht SYSTEM PRIVATE ${argon2_INCLUDE_DIRS}) + endif () + if (APPLE) + target_link_libraries(opendht + PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} + PRIVATE ${GNUTLS_LIBRARIES} ${Nettle_LIBRARIES} + ${Jsoncpp_LIBRARIES} + ${FMT_LIBRARY} ${HTTP_PARSER_LIBRARY} + SYSTEM "-framework CoreFoundation" "-framework Security") + else () + target_link_libraries(opendht + PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} + PRIVATE ${GNUTLS_LIBRARIES} ${Nettle_LIBRARIES} + ${Jsoncpp_LIBRARIES} + ${FMT_LIBRARY} ${HTTP_PARSER_LIBRARY}) + endif () + + install (TARGETS opendht DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht) +endif () + +if (OPENDHT_C) + add_library (opendht-c SHARED + c/opendht.cpp + c/opendht_c.h + ) + target_compile_definitions(opendht-c PRIVATE OPENDHT_C_BUILD) + if (OPENDHT_SHARED) + target_link_libraries(opendht-c opendht) + else () + target_link_libraries(opendht-c opendht-static) + endif () + + # PkgConfig module + configure_file ( + opendht-c.pc.in + opendht-c.pc + @ONLY + ) + install (TARGETS opendht-c DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht-c) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/opendht-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif () + +if (OPENDHT_TOOLS) + add_subdirectory(tools) +endif () +add_subdirectory(doc) + +if (OPENDHT_PYTHON) + add_subdirectory(python) +endif () + +# CMake module +write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/opendhtConfigVersion.cmake" + VERSION ${opendht_VERSION} + COMPATIBILITY AnyNewerVersion +) +# PkgConfig module +configure_file ( + opendht.pc.in + opendht.pc + @ONLY +) + +# Install targets +install (DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) +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) + +# Unit tests +if (OPENDHT_TESTS) + pkg_search_module(Cppunit REQUIRED cppunit) + # unit testing + list (APPEND test_FILES + tests/infohashtester.h + tests/infohashtester.cpp + tests/valuetester.h + tests/valuetester.cpp + tests/cryptotester.h + tests/cryptotester.cpp + tests/dhtrunnertester.h + tests/dhtrunnertester.cpp + tests/threadpooltester.h + tests/threadpooltester.cpp + ) + if (OPENDHT_TESTS_NETWORK) + if (OPENDHT_PROXY_SERVER AND OPENDHT_PROXY_CLIENT) + list (APPEND test_FILES + tests/httptester.h + tests/httptester.cpp + tests/dhtproxytester.h + tests/dhtproxytester.cpp + ) + endif() + if (OPENDHT_PEER_DISCOVERY) + list (APPEND test_FILES + tests/peerdiscoverytester.h + tests/peerdiscoverytester.cpp + ) + endif() + endif() + add_executable(opendht_unit_tests + tests/tests_runner.cpp + ${test_FILES} + ) + target_include_directories(opendht_unit_tests SYSTEM PRIVATE ${Cppunit_INCLUDE_DIR}) + target_link_directories(opendht_unit_tests PRIVATE ${Cppunit_LIBRARY_DIRS}) + if (OPENDHT_SHARED) + target_link_libraries(opendht_unit_tests opendht) + else () + target_link_libraries(opendht_unit_tests opendht-static) + endif () + target_link_libraries(opendht_unit_tests + ${CMAKE_THREAD_LIBS_INIT} + ${Cppunit_LIBRARIES} + ${GNUTLS_LIBRARIES} + ${Jsoncpp_LIBRARIES} + ) + if (OPENDHT_PROXY_OPENSSL) + target_link_libraries(opendht_unit_tests ${OPENSSL_LIBRARIES}) + endif() + enable_testing() + add_test(TEST opendht_unit_tests) +endif() diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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. + + 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. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7ba6efb --- /dev/null +++ b/Makefile.am @@ -0,0 +1,31 @@ +AM_CXXFLAGS = -pthread + +SUBDIRS = + +SUBDIRS += src + +if ENABLE_TOOLS +SUBDIRS += tools +endif + +if USE_CYTHON +SUBDIRS += python +endif + +if ENABLE_TESTS +SUBDIRS += tests +endif + +SUBDIRS += doc + +ACLOCAL_AMFLAGS = -I m4 + +DOC_FILES = \ + README.md \ + COPYING + +EXTRA_DIST = \ + $(DOC_FILES) + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = opendht.pc diff --git a/README.md b/README.md new file mode 100644 index 0000000..34fb21b --- /dev/null +++ b/README.md @@ -0,0 +1,122 @@ + +
+

+ OpenDHT +

+ +A lightweight C++14 Distributed Hash Table implementation. + +OpenDHT provides an easy to use distributed in-memory data store. +Every node in the network can read and write values to the store. +Values are distributed over the network, with redundancy. + + * Lightweight and scalable, designed for large networks and small devices + * High resilience to network disruption + * Public key cryptography layer providing optional data signature and encryption (using GnuTLS) + * IPv4 and IPv6 support + * Clean and powerful **C++14** map API + * Bindings for **C, Rust & Python 3** + * REST API with optional HTTP client+server with push notification support + +## Documentation +See the wiki: + +#### How-to build and install + +Build instructions: + +#### How-to build a simple client app +```bash +g++ main.cpp -std=c++14 -lopendht +``` + +## Examples +### C++ example +The `tools` directory includes simple example programs : +* `dhtnode`, a command line tool, allowing to run a DHT node and perform operations supported by the library (get, put etc.) with text values. +* `dhtchat`, a very simple IM client working over the dht. + +Example program launching a DHT node, connecting to the network and performing some basic operations: +```c++ +#include +#include + +int main() +{ + dht::DhtRunner node; + + // Launch a dht node on a new thread, using a + // generated RSA key pair, and listen on port 4222. + node.run(4222, dht::crypto::generateIdentity(), true); + + // Join the network through any running node, + // here using a known bootstrap node. + node.bootstrap("bootstrap.jami.net", "4222"); + + // put some data on the dht + std::vector some_data(5, 10); + node.put("unique_key", some_data); + + // put some data on the dht, signed with our generated private key + node.putSigned("unique_key_42", some_data); + + // get data from the dht + node.get("other_unique_key", [](const std::vector>& values) { + // Callback called when values are found + for (const auto& value : values) + std::cout << "Found value: " << *value << std::endl; + return true; // return false to stop the search + }); + + // wait for dht threads to end + node.join(); + return 0; +} +``` +### Python 3 example +```python +import opendht as dht + +node = dht.DhtRunner() +node.run() + +# Join the network through any running node, +# here using a known bootstrap node. +node.bootstrap("bootstrap.jami.net", "4222") + +# blocking call (provide callback arguments to make the call non-blocking) +node.put(dht.InfoHash.get("unique_key"), dht.Value(b'some binary data')) + +results = node.get(dht.InfoHash.get("unique_key")) +for r in results: + print(r) +``` + +## Dependencies +- msgpack-c 1.2+, used for data serialization. +- GnuTLS 3.3+, used for cryptographic operations. +- Nettle 2.4+, a GnuTLS dependency for crypto. +- (optional) restinio used for the REST API. +- (optional) jsoncpp 1.7.4-3+, used for the REST API. +- Build tested with GCC 5.2+ (GNU/Linux, Windows with MinGW), Clang/LLVM (GNU/Linux, Android, macOS, iOS). +- Build tested with Microsoft Visual Studio 2015, 2017, 2019 + +## Contact + +IRC: join us on Freenode at [`#opendht`](https://webchat.freenode.net/?channels=%23opendht). + +## License +Copyright (C) 2014-2020 Savoir-faire Linux Inc. + +OpenDHT 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, 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. + +See COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html for the full GPLv3 license. + +## Acknowledgements +This project was originally based on https://github.com/jech/dht by Juliusz Chroboczek. +It is independent from another project called OpenDHT (Sean Rhea. Ph.D. Thesis, 2005), now extinct. + +## Donations +We gratefully accept Bitcoin donations to support OpenDHT development at: `bitcoin:3EykSd1An888efq4Bq3KaV3hJ3JQ4FPnwm`. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..1a4d907 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,2 @@ +git submodule update --init +autoreconf --install --verbose -Wall diff --git a/c/opendht.cpp b/c/opendht.cpp new file mode 100644 index 0000000..282bc5d --- /dev/null +++ b/c/opendht.cpp @@ -0,0 +1,430 @@ +#include "opendht_c.h" +#include "opendht.h" + +using ValueSp = std::shared_ptr; +using PrivkeySp = std::shared_ptr; +using PubkeySp = std::shared_ptr; +using CertSp = std::shared_ptr; + +#ifdef __cplusplus +extern "C" { +#endif + +// dht::InfoHash + +inline dht_infohash dht_infohash_to_c(const dht::InfoHash& h) { + dht_infohash ret; + *reinterpret_cast(&ret) = h; + return ret; +} + +inline dht_pkid dht_pkid_to_c(const dht::PkId& h) { + dht_pkid ret; + *reinterpret_cast(&ret) = h; + return ret; +} + +const char* dht_infohash_print(const dht_infohash* h) { + return reinterpret_cast(h)->to_c_str(); +} + +void dht_infohash_zero(dht_infohash* h) { + *reinterpret_cast(h) = dht::InfoHash{}; +} + +void dht_infohash_random(dht_infohash* h) { + *reinterpret_cast(h) = dht::InfoHash::getRandom(); +} + +void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size) { + *reinterpret_cast(h) = dht::InfoHash::get(dat, dat_size); +} + +void dht_infohash_get_from_string(dht_infohash* h, const char* dat) { + *reinterpret_cast(h) = dht::InfoHash::get((const uint8_t*)dat, (size_t)strlen(dat)); +} + +bool dht_infohash_is_zero(const dht_infohash* h) { + return !static_cast(*reinterpret_cast(h)); +} + +void dht_infohash_from_hex(dht_infohash* h, const char* dat) { + *h = dht_infohash_to_c(dht::InfoHash(std::string(dat, HASH_LEN*2))); +} + +const char* dht_pkid_print(const dht_pkid* h) { + return reinterpret_cast(h)->to_c_str(); +} + +// dht::Blob +void dht_blob_delete(dht_blob* data) { + delete reinterpret_cast(data); +} + +dht_data_view dht_blob_get_data(const dht_blob* data) { + dht_data_view view; + view.data = reinterpret_cast(data)->data(); + view.size = reinterpret_cast(data)->size(); + return view; +} + +// dht::Value +dht_data_view dht_value_get_data(const dht_value* data) { + const ValueSp& vsp(*reinterpret_cast(data)); + dht_data_view view; + view.data = vsp->data.data(); + view.size = vsp->data.size(); + return view; +} + +dht_value_id dht_value_get_id(const dht_value* data) { + const ValueSp& vsp(*reinterpret_cast(data)); + return vsp->id; +} + +dht_publickey* dht_value_get_owner(const dht_value* data) { + const ValueSp& vsp(*reinterpret_cast(data)); + return vsp->owner ? reinterpret_cast(new PubkeySp(vsp->owner)) : nullptr; +} + +dht_infohash dht_value_get_recipient(const dht_value* data) { + const ValueSp& vsp(*reinterpret_cast(data)); + return dht_infohash_to_c(vsp->recipient); +} + +const char* dht_value_get_user_type(const dht_value* data) { + const ValueSp& vsp(*reinterpret_cast(data)); + return vsp->user_type.c_str(); +} + +dht_value* dht_value_new(const uint8_t* data, size_t size) { + return reinterpret_cast(new ValueSp(std::make_shared(data, size))); +} + +dht_value* dht_value_ref(const dht_value* v) { + return reinterpret_cast(new ValueSp(*reinterpret_cast(v))); +} + +void dht_value_unref(dht_value* v) { + delete reinterpret_cast(v); +} + +// dht::crypto::PublicKey +dht_publickey* dht_publickey_import(const uint8_t* dat, size_t dat_size) { + try { + return reinterpret_cast(new PubkeySp(std::make_shared(dat, dat_size))); + } catch (const dht::crypto::CryptoException& e) { + return nullptr; + } +} + +void dht_publickey_delete(dht_publickey* pk) { + delete reinterpret_cast(pk); +} + +int dht_publickey_export(const dht_publickey* pk, char* out, size_t* outlen) { + const auto& pkey = *reinterpret_cast(pk); + return pkey->pack((uint8_t*)out, outlen); +} + +dht_infohash dht_publickey_get_id(const dht_publickey* pk) { + const auto& pkey = *reinterpret_cast(pk); + return dht_infohash_to_c(pkey->getId()); +} + +dht_pkid dht_publickey_get_long_id(const dht_publickey* pk) { + const auto& pkey = *reinterpret_cast(pk); + return dht_pkid_to_c(pkey->getLongId()); +} + +bool dht_publickey_check_signature(const dht_publickey* pk, const char* data, size_t data_size, const char* signature, size_t signature_size) { + const auto& pkey = *reinterpret_cast(pk); + return pkey->checkSignature((const uint8_t*)data, data_size, (const uint8_t*)signature, signature_size); +} + +dht_blob* dht_publickey_encrypt(const dht_publickey* pk, const char* data, size_t data_size) { + const auto& pkey = *reinterpret_cast(pk); + auto rdata = new dht::Blob; + *rdata = pkey->encrypt((const uint8_t*)data, data_size); + return (dht_blob*)rdata; +} + +// dht::crypto::PrivateKey +dht_privatekey* dht_privatekey_generate(unsigned key_length_bits) { + if (key_length_bits == 0) + key_length_bits = 4096; + return reinterpret_cast(new PrivkeySp(std::make_shared(dht::crypto::PrivateKey::generate(key_length_bits)))); +} + +dht_privatekey* dht_privatekey_import(const uint8_t* dat, size_t dat_size, const char* password) { + try { + return reinterpret_cast(new PrivkeySp(std::make_shared(dat, dat_size, password))); + } catch (const dht::crypto::CryptoException& e) { + return nullptr; + } +} + +int dht_privatekey_export(const dht_privatekey* k, char* out, size_t* out_size, const char* password) { + if (!out or !out_size or !*out_size) + return -1; + const auto& key = *reinterpret_cast(k); + return key->serialize((uint8_t*)out, out_size, password); +} + +dht_publickey* dht_privatekey_get_publickey(const dht_privatekey* k) { + const auto& key = *reinterpret_cast(k); + return reinterpret_cast(new PubkeySp(std::make_shared(key->getPublicKey()))); +} + +void dht_privatekey_delete(dht_privatekey* pk) { + delete reinterpret_cast(pk); +} + +// dht::crypto::Certificate +dht_certificate* dht_certificate_import(const uint8_t* dat, size_t dat_size) { + try { + return reinterpret_cast(new CertSp(std::make_shared(dat, dat_size))); + } catch (const dht::crypto::CryptoException& e) { + return nullptr; + } +} + +void dht_certificate_delete(dht_certificate* c) { + delete reinterpret_cast(c); +} + +dht_infohash dht_certificate_get_id(const dht_certificate* c) { + const auto& cert = *reinterpret_cast(c); + return dht_infohash_to_c(cert->getId()); +} + +dht_pkid dht_certificate_get_long_id(const dht_certificate* c) { + const auto& cert = *reinterpret_cast(c); + return dht_pkid_to_c(cert->getLongId()); +} + +dht_publickey* dht_certificate_get_publickey(const dht_certificate* c) { + const auto& cert = *reinterpret_cast(c); + return reinterpret_cast(new PubkeySp(std::make_shared(cert->getPublicKey()))); +} + +// dht::crypto::Identity +inline dht::crypto::Identity dht_identity_from_c(const dht_identity* cid) { + dht::crypto::Identity id {}; + if (cid and cid->privatekey) + id.first = *reinterpret_cast(cid->privatekey); + if (cid and cid->certificate) + id.second = *reinterpret_cast(cid->certificate); + return id; +} + +inline dht_identity dht_identity_to_c(const dht::crypto::Identity& id) { + dht_identity cid {}; + cid.privatekey = id.first ? reinterpret_cast(new PrivkeySp(id.first)) : NULL; + cid.certificate = id.second ? reinterpret_cast(new CertSp(id.second)) : NULL; + return cid; +} + +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))); +} + +OPENDHT_C_PUBLIC void dht_identity_delete(dht_identity* id) { + if (id->certificate) { + dht_certificate_delete(id->certificate); + id->certificate = NULL; + } + if (id->privatekey) { + dht_privatekey_delete(id->privatekey); + id->privatekey = NULL; + } +} + +// config +void dht_runner_config_default(dht_runner_config* config) { + bzero(config, sizeof(dht_runner_config)); + config->threaded = true; +} + +// dht::DhtRunner +dht_runner* dht_runner_new() { + return reinterpret_cast(new dht::DhtRunner); +} + +void dht_runner_delete(dht_runner* runner) { + delete reinterpret_cast(runner); +} + +void dht_runner_run(dht_runner* r, in_port_t port) { + auto runner = reinterpret_cast(r); + runner->run(port, {}, true); +} + +void dht_runner_run_config(dht_runner* r, in_port_t port, const dht_runner_config* conf) { + auto runner = reinterpret_cast(r); + dht::DhtRunner::Config config; + config.dht_config.node_config.is_bootstrap = conf->dht_config.node_config.is_bootstrap; + config.dht_config.node_config.maintain_storage = conf->dht_config.node_config.maintain_storage; + config.dht_config.node_config.node_id = *reinterpret_cast(&conf->dht_config.node_config.node_id); + config.dht_config.node_config.network = conf->dht_config.node_config.network; + config.dht_config.node_config.persist_path = conf->dht_config.node_config.persist_path + ? std::string(conf->dht_config.node_config.persist_path) : std::string{}; + + if (conf->dht_config.id.privatekey) + config.dht_config.id.first = *reinterpret_cast(conf->dht_config.id.privatekey); + + if (conf->dht_config.id.certificate) + config.dht_config.id.second = *reinterpret_cast(conf->dht_config.id.certificate); + + config.threaded = conf->threaded; + config.proxy_server = conf->proxy_server ? std::string(conf->proxy_server) : std::string{}; + config.push_node_id = conf->push_node_id ? std::string(conf->push_node_id) : std::string{}; + config.push_token = conf->push_token ? std::string(conf->push_token) : std::string{}; + config.peer_discovery = conf->peer_discovery; + config.peer_publish = conf->peer_publish; + runner->run(port, config); +} + +void dht_runner_ping(dht_runner* r, struct sockaddr* addr, socklen_t addr_len) { + auto runner = reinterpret_cast(r); + runner->bootstrap(dht::SockAddr(addr, addr_len)); +} + +void dht_runner_bootstrap(dht_runner* r, const char* host, const char* service) { + auto runner = reinterpret_cast(r); + if (service) + runner->bootstrap(host, service); + else + runner->bootstrap(host); +} + +void dht_runner_get(dht_runner* r, const dht_infohash* h, dht_get_cb cb, dht_done_cb done_cb, void* cb_user_data) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + runner->get(*hash, [cb,cb_user_data](std::shared_ptr value){ + return cb(reinterpret_cast(&value), cb_user_data); + }, [done_cb, cb_user_data](bool ok){ + if (done_cb) + done_cb(ok, cb_user_data); + }); +} + +struct ScopeGuardCb { + ScopeGuardCb(dht_shutdown_cb cb, void* data) + : onDestroy(cb), userData(data) {} + + ~ScopeGuardCb() { + if (onDestroy) + onDestroy((void*)userData); + } +private: + const dht_shutdown_cb onDestroy; + void const* userData; +}; + +dht_op_token* dht_runner_listen(dht_runner* r, const dht_infohash* h, dht_value_cb cb, dht_shutdown_cb done_cb, void* cb_user_data) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + auto fret = new std::future; + auto guard = done_cb ? std::make_shared(done_cb, cb_user_data) : std::shared_ptr{}; + *fret = runner->listen(*hash, [cb,cb_user_data, guard](const std::vector>& values, bool expired) { + for (const auto& value : values) { + if (not cb(reinterpret_cast(&value), expired, cb_user_data)) + return false; + } + return true; + }); + return (dht_op_token*)fret; +} + +void dht_runner_cancel_listen(dht_runner* r, const dht_infohash* h, dht_op_token* t) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + auto token = reinterpret_cast*>(t); + runner->cancelListen(*hash, std::move(*token)); +} + +void dht_op_token_delete(dht_op_token* token) { + delete reinterpret_cast*>(token); +} + +void dht_runner_put(dht_runner* r, const dht_infohash* h, const dht_value* v, dht_done_cb done_cb, void* cb_user_data, bool permanent) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + auto value = reinterpret_cast(v); + runner->put(*hash, *value, [done_cb, cb_user_data](bool ok){ + if (done_cb) + done_cb(ok, cb_user_data); + }, dht::time_point::max(), permanent); +} + +void dht_runner_put_signed(dht_runner* r, const dht_infohash* h, const dht_value* v, dht_done_cb done_cb, void* cb_user_data, bool permanent) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + auto value = reinterpret_cast(v); + runner->putSigned(*hash, *value, [done_cb, cb_user_data](bool ok){ + if (done_cb) + done_cb(ok, cb_user_data); + }, permanent); +} + +void dht_runner_put_encrypted(dht_runner* r, const dht_infohash* h, const dht_infohash* to, const dht_value* v, dht_done_cb done_cb, void* cb_user_data, bool permanent) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + auto toHash = reinterpret_cast(to); + auto value = reinterpret_cast(v); + runner->putEncrypted(*hash, *toHash, *value, [done_cb, cb_user_data](bool ok){ + if (done_cb) + done_cb(ok, cb_user_data); + }, permanent); +} + +void dht_runner_cancel_put(dht_runner* r, const dht_infohash* h, dht_value_id value_id) { + auto runner = reinterpret_cast(r); + auto hash = reinterpret_cast(h); + runner->cancelPut(*hash, value_id); +} + +void dht_runner_shutdown(dht_runner* r, dht_shutdown_cb done_cb, void* cb_user_data) { + auto runner = reinterpret_cast(r); + runner->shutdown([done_cb, cb_user_data](){ + if (done_cb) + done_cb(cb_user_data); + }); +} + +dht_infohash dht_runner_get_node_id(const dht_runner* r) { + auto runner = reinterpret_cast(r); + dht_infohash ret; + *reinterpret_cast(&ret) = runner->getNodeId(); + return ret; +} + +dht_infohash dht_runner_get_id(const dht_runner* r) { + auto runner = reinterpret_cast(r); + dht_infohash ret; + *reinterpret_cast(&ret) = runner->getId(); + return ret; +} + +struct sockaddr** dht_runner_get_public_address(const dht_runner* r) { + auto runner = reinterpret_cast(r); + auto addrs = const_cast(runner)->getPublicAddress(); + if (addrs.empty()) + return nullptr; + auto ret = (struct sockaddr**)malloc(sizeof(struct sockaddr*) * (addrs.size() + 1)); + for (size_t i=0; i +#include +#include +#include +#include + +// Non-owning data view +struct OPENDHT_C_PUBLIC dht_data_view { + const uint8_t* data; + size_t size; +}; +typedef struct dht_data_view dht_data_view; + +// dht::Blob +struct OPENDHT_C_PUBLIC dht_blob; +typedef struct dht_blob dht_blob; +OPENDHT_C_PUBLIC dht_data_view dht_blob_get_data(const dht_blob* data); +OPENDHT_C_PUBLIC void dht_blob_delete(dht_blob* data); + +// dht::InfoHash +struct OPENDHT_C_PUBLIC dht_infohash { uint8_t d[HASH_LEN]; }; +typedef struct dht_infohash dht_infohash; +OPENDHT_C_PUBLIC void dht_infohash_zero(dht_infohash* h); +OPENDHT_C_PUBLIC void dht_infohash_random(dht_infohash* h); +OPENDHT_C_PUBLIC void dht_infohash_from_hex(dht_infohash* h, const char* dat); +OPENDHT_C_PUBLIC void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size); +OPENDHT_C_PUBLIC void dht_infohash_get_from_string(dht_infohash* h, const char* str); +OPENDHT_C_PUBLIC const char* dht_infohash_print(const dht_infohash* h); +OPENDHT_C_PUBLIC bool dht_infohash_is_zero(const dht_infohash* h); + +// dht::PkId +struct OPENDHT_C_PUBLIC dht_pkid { uint8_t d[32]; }; +typedef struct dht_pkid dht_pkid; +OPENDHT_C_PUBLIC const char* dht_pkid_print(const dht_pkid* h); + +// dht::crypto::PublicKey +struct OPENDHT_C_PUBLIC dht_publickey; +typedef struct dht_publickey dht_publickey; +OPENDHT_C_PUBLIC dht_publickey* dht_publickey_import(const uint8_t* dat, size_t dat_size); +OPENDHT_C_PUBLIC void dht_publickey_delete(dht_publickey* pk); +OPENDHT_C_PUBLIC int dht_publickey_export(const dht_publickey* pk, char* out, size_t* out_size); +OPENDHT_C_PUBLIC dht_infohash dht_publickey_get_id(const dht_publickey* pk); +OPENDHT_C_PUBLIC dht_pkid dht_publickey_get_long_id(const dht_publickey* pk); +OPENDHT_C_PUBLIC bool dht_publickey_check_signature(const dht_publickey* pk, const char* data, size_t data_size, const char* signature, size_t signature_size); +OPENDHT_C_PUBLIC dht_blob* dht_publickey_encrypt(const dht_publickey* pk, const char* data, size_t data_size); + +// dht::crypto::PrivateKey +struct OPENDHT_C_PUBLIC dht_privatekey; +typedef struct dht_privatekey dht_privatekey; +OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_generate(unsigned key_length_bits); +OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_import(const uint8_t* dat, size_t dat_size, const char* password); +OPENDHT_C_PUBLIC int dht_privatekey_export(const dht_privatekey*, char* out, size_t* out_size, const char* password); +OPENDHT_C_PUBLIC dht_publickey* dht_privatekey_get_publickey(const dht_privatekey*); +OPENDHT_C_PUBLIC void dht_privatekey_delete(dht_privatekey*); + +// dht::crypto::Certificate +struct OPENDHT_C_PUBLIC dht_certificate; +typedef struct dht_certificate dht_certificate; +OPENDHT_C_PUBLIC dht_certificate* dht_certificate_import(const uint8_t* dat, size_t dat_size); +OPENDHT_C_PUBLIC dht_infohash dht_certificate_get_id(const dht_certificate*); +OPENDHT_C_PUBLIC dht_pkid dht_certificate_get_long_id(const dht_certificate*); +OPENDHT_C_PUBLIC dht_publickey* dht_certificate_get_publickey(const dht_certificate*); +OPENDHT_C_PUBLIC void dht_certificate_delete(dht_certificate*); + +struct OPENDHT_PUBLIC dht_identity { + dht_privatekey* privatekey; + dht_certificate* certificate; +}; +typedef struct dht_identity dht_identity; +OPENDHT_C_PUBLIC dht_identity dht_identity_generate(const char* common_name, const dht_identity* ca); +OPENDHT_C_PUBLIC void dht_identity_delete(dht_identity*); + +// dht::Value +struct OPENDHT_C_PUBLIC dht_value; +typedef struct dht_value dht_value; +typedef uint64_t dht_value_id; +OPENDHT_C_PUBLIC dht_value* dht_value_new(const uint8_t* data, size_t size); +OPENDHT_C_PUBLIC dht_value* dht_value_ref(const dht_value*); +OPENDHT_C_PUBLIC void dht_value_unref(dht_value*); +OPENDHT_C_PUBLIC dht_data_view dht_value_get_data(const dht_value* data); +OPENDHT_C_PUBLIC dht_value_id dht_value_get_id(const dht_value* data); +OPENDHT_C_PUBLIC dht_publickey* dht_value_get_owner(const dht_value* data); +OPENDHT_C_PUBLIC dht_infohash dht_value_get_recipient(const dht_value* data); +OPENDHT_C_PUBLIC const char* dht_value_get_user_type(const dht_value* data); + +// callbacks +typedef bool (*dht_get_cb)(const dht_value* value, void* user_data); +typedef bool (*dht_value_cb)(const dht_value* value, bool expired, void* user_data); +typedef void (*dht_done_cb)(bool ok, void* user_data); +typedef void (*dht_shutdown_cb)(void* user_data); + +struct OPENDHT_C_PUBLIC dht_op_token; +typedef struct dht_op_token dht_op_token; +OPENDHT_C_PUBLIC void dht_op_token_delete(dht_op_token* token); + +// config +struct OPENDHT_PUBLIC dht_node_config { + dht_infohash node_id; + uint32_t network; + bool is_bootstrap; + bool maintain_storage; + const char* persist_path; +}; +typedef struct dht_node_config dht_node_config; + +struct OPENDHT_PUBLIC dht_secure_config { + dht_node_config node_config; + dht_identity id; +}; +typedef struct dht_secure_config dht_secure_config; + +struct OPENDHT_PUBLIC dht_runner_config { + dht_secure_config dht_config; + bool threaded; + const char* proxy_server; + const char* push_node_id; + const char* push_token; + bool peer_discovery; + bool peer_publish; + dht_certificate* server_ca; + dht_identity client_identity; +}; +typedef struct dht_runner_config dht_runner_config; +OPENDHT_C_PUBLIC void dht_runner_config_default(dht_runner_config* config); + +// dht::DhtRunner +struct OPENDHT_C_PUBLIC dht_runner; +typedef struct dht_runner dht_runner; +OPENDHT_C_PUBLIC dht_runner* dht_runner_new(); +OPENDHT_C_PUBLIC void dht_runner_delete(dht_runner* runner); +OPENDHT_C_PUBLIC void dht_runner_run(dht_runner* runner, in_port_t port); +OPENDHT_C_PUBLIC void dht_runner_run_config(dht_runner* runner, in_port_t port, const dht_runner_config* config); +OPENDHT_C_PUBLIC void dht_runner_ping(dht_runner* runner, struct sockaddr* addr, socklen_t addr_len); +OPENDHT_C_PUBLIC void dht_runner_bootstrap(dht_runner* runner, const char* host, const char* service); +OPENDHT_C_PUBLIC void dht_runner_get(dht_runner* runner, const dht_infohash* hash, dht_get_cb cb, dht_done_cb done_cb, void* cb_user_data); +OPENDHT_C_PUBLIC dht_op_token* dht_runner_listen(dht_runner* runner, const dht_infohash* hash, dht_value_cb cb, dht_shutdown_cb done_cb, void* cb_user_data); +OPENDHT_C_PUBLIC void dht_runner_cancel_listen(dht_runner* runner, const dht_infohash* hash, dht_op_token* token); +OPENDHT_C_PUBLIC void dht_runner_put(dht_runner* runner, const dht_infohash* hash, const dht_value* value, dht_done_cb done_cb, void* cb_user_data, bool permanent); +OPENDHT_C_PUBLIC void dht_runner_put_signed(dht_runner* runner, const dht_infohash* hash, const dht_value* value, dht_done_cb done_cb, void* cb_user_data, bool permanent); +OPENDHT_C_PUBLIC void dht_runner_put_encrypted(dht_runner* runner, const dht_infohash* hash, const dht_infohash* to, const dht_value* value, dht_done_cb done_cb, void* cb_user_data, bool permanent); +OPENDHT_C_PUBLIC void dht_runner_cancel_put(dht_runner* runner, const dht_infohash* hash, dht_value_id value_id); +OPENDHT_C_PUBLIC void dht_runner_shutdown(dht_runner* runner, dht_shutdown_cb done_cb, void* cb_user_data); +OPENDHT_C_PUBLIC dht_infohash dht_runner_get_node_id(const dht_runner* runner); +OPENDHT_C_PUBLIC dht_infohash dht_runner_get_id(const dht_runner* runner); +OPENDHT_C_PUBLIC struct sockaddr** dht_runner_get_public_address(const dht_runner* runner); + +#ifdef __cplusplus +} +#endif diff --git a/cmake/CheckAtomic.cmake b/cmake/CheckAtomic.cmake new file mode 100644 index 0000000..d4a6711 --- /dev/null +++ b/cmake/CheckAtomic.cmake @@ -0,0 +1,95 @@ +# University of Illinois/NCSA +# Open Source License +# +# Copyright (c) 2003-2017 University of Illinois at Urbana-Champaign. +# All rights reserved. +# +# Developed by: +# +# LLVM Team +# +# University of Illinois at Urbana-Champaign +# +# http://llvm.org +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal with +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +# of the Software, and to permit persons to whom the Software is furnished to do +# so, subject to the following conditions: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimers. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimers in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the names of the LLVM Team, University of Illinois at +# Urbana-Champaign, nor the names of its contributors may be used to +# endorse or promote products derived from this Software without specific +# prior written permission. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE +# SOFTWARE. + +include(CheckCXXSourceCompiles) +include(CheckLibraryExists) + +# Sometimes linking against libatomic is required for atomic ops, if +# the platform doesn't support lock-free atomics. + +function(check_working_cxx_atomics varname) + set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + get_directory_property(compile_options COMPILE_OPTIONS) + set(CMAKE_REQUIRED_FLAGS ${compile_options}) + CHECK_CXX_SOURCE_COMPILES(" +#include +#include +std::atomic v1; +std::atomic v2; +int main(int, char**) { + return v1 + v2; +}" ${varname}) + set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) +endfunction(check_working_cxx_atomics) + + +if(NOT DEFINED PROXYGEN_COMPILER_IS_GCC_COMPATIBLE) + if(CMAKE_COMPILER_IS_GNUCXX) + set(PROXYGEN_COMPILER_IS_GCC_COMPATIBLE ON) + elseif(MSVC) + set(PROXYGEN_COMPILER_IS_GCC_COMPATIBLE OFF) + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(PROXYGEN_COMPILER_IS_GCC_COMPATIBLE ON) + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") + set(PROXYGEN_COMPILER_IS_GCC_COMPATIBLE ON) + endif() +endif() + +# This isn't necessary on MSVC, so avoid command-line switch annoyance +# by only running on GCC-like hosts. +if(PROXYGEN_COMPILER_IS_GCC_COMPATIBLE) + # First check if atomics work without the library. + check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB) + # If not, check if the library exists, and atomics work with it. + if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB) + check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC) + if(HAVE_LIBATOMIC) + list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") + check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB) + if (NOT HAVE_CXX_ATOMICS_WITH_LIB) + message(FATAL_ERROR "Host compiler must support std::atomic!") + endif() + list(APPEND CMAKE_CXX_STANDARD_LIBRARIES -latomic) + else() + message(FATAL_ERROR "Host compiler appears to require libatomic, but cannot find it.") + endif() + endif() +endif() diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake new file mode 100644 index 0000000..7d9dd81 --- /dev/null +++ b/cmake/FindMsgpack.cmake @@ -0,0 +1,64 @@ +# - Try to find msgpack +# Once done this will define +# MSGPACK_FOUND - System has msgpack +# MSGPACK_INCLUDE_DIRS - The msgpack include directories +# MSGPACK_LIBRARIES - The libraries needed to use msgpack + +if(NOT MSGPACK_USE_BUNDLED) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_search_module(PC_MSGPACK QUIET + msgpackc>=${Msgpack_FIND_VERSION} + msgpack>=${Msgpack_FIND_VERSION}) + endif() +else() + set(PC_MSGPACK_INCLUDEDIR) + set(PC_MSGPACK_INCLUDE_DIRS) + set(PC_MSGPACK_LIBDIR) + set(PC_MSGPACK_LIBRARY_DIRS) + set(LIMIT_SEARCH NO_DEFAULT_PATH) +endif() + +set(MSGPACK_DEFINITIONS ${PC_MSGPACK_CFLAGS_OTHER}) + +find_path(MSGPACK_INCLUDE_DIR msgpack/version_master.h + HINTS ${PC_MSGPACK_INCLUDEDIR} ${PC_MSGPACK_INCLUDE_DIRS} + ${LIMIT_SEARCH}) + +if(MSGPACK_INCLUDE_DIR) + file(READ ${MSGPACK_INCLUDE_DIR}/msgpack/version_master.h msgpack_version_h) + string(REGEX REPLACE ".*MSGPACK_VERSION_MAJOR +([0-9]+).*" "\\1" MSGPACK_VERSION_MAJOR "${msgpack_version_h}") + string(REGEX REPLACE ".*MSGPACK_VERSION_MINOR +([0-9]+).*" "\\1" MSGPACK_VERSION_MINOR "${msgpack_version_h}") + string(REGEX REPLACE ".*MSGPACK_VERSION_REVISION +([0-9]+).*" "\\1" MSGPACK_VERSION_REVISION "${msgpack_version_h}") + set(MSGPACK_VERSION_STRING "${MSGPACK_VERSION_MAJOR}.${MSGPACK_VERSION_MINOR}.${MSGPACK_VERSION_REVISION}") +else() + set(MSGPACK_VERSION_STRING) +endif() + +# If we're asked to use static linkage, add libmsgpack{,c}.a as a preferred library name. +if(MSGPACK_USE_STATIC) + list(APPEND MSGPACK_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}msgpackc${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}msgpack${CMAKE_STATIC_LIBRARY_SUFFIX}") +endif() + +list(APPEND MSGPACK_NAMES msgpackc msgpack) + +find_library(MSGPACK_LIBRARY NAMES ${MSGPACK_NAMES} + # Check each directory for all names to avoid using headers/libraries from + # different places. + NAMES_PER_DIR + HINTS ${PC_MSGPACK_LIBDIR} ${PC_MSGPACK_LIBRARY_DIRS} + ${LIMIT_SEARCH}) + +mark_as_advanced(MSGPACK_INCLUDE_DIR MSGPACK_LIBRARY) + +set(MSGPACK_LIBRARIES ${MSGPACK_LIBRARY}) +set(MSGPACK_INCLUDE_DIRS ${MSGPACK_INCLUDE_DIR}) + +include(FindPackageHandleStandardArgs) +# handle the QUIETLY and REQUIRED arguments and set MSGPACK_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(Msgpack + REQUIRED_VARS MSGPACK_LIBRARY MSGPACK_INCLUDE_DIR + VERSION_VAR MSGPACK_VERSION_STRING) diff --git a/cmake/FindReadline.cmake b/cmake/FindReadline.cmake new file mode 100644 index 0000000..6807812 --- /dev/null +++ b/cmake/FindReadline.cmake @@ -0,0 +1,48 @@ +# - Try to find readline, a library for easy editing of command lines. +# Variables used by this module: +# READLINE_ROOT_DIR - Readline root directory +# Variables defined by this module: +# READLINE_FOUND - system has Readline +# READLINE_INCLUDE_DIR - the Readline include directory (cached) +# READLINE_INCLUDE_DIRS - the Readline include directories +# (identical to READLINE_INCLUDE_DIR) +# READLINE_LIBRARY - the Readline library (cached) +# READLINE_LIBRARIES - the Readline library plus the libraries it +# depends on + +# Copyright (C) 2009 +# ASTRON (Netherlands Institute for Radio Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program is free software; you can redistribute it and/or modify +# 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, +# 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 this program. If not, see . +# +# $Id: FindReadline.cmake 15228 2010-03-16 09:27:26Z loose $ + +if(NOT READLINE_FOUND) + + find_path(READLINE_INCLUDE_DIR readline/readline.h + HINTS ${READLINE_ROOT_DIR} PATH_SUFFIXES include) + find_library(READLINE_LIBRARY readline + HINTS ${READLINE_ROOT_DIR} PATH_SUFFIXES lib) + find_library(NCURSES_LIBRARY ncurses) # readline depends on libncurses + mark_as_advanced(READLINE_INCLUDE_DIR READLINE_LIBRARY NCURSES_LIBRARY) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Readline DEFAULT_MSG + READLINE_LIBRARY NCURSES_LIBRARY READLINE_INCLUDE_DIR) + + set(READLINE_INCLUDE_DIRS ${READLINE_INCLUDE_DIR}) + set(READLINE_LIBRARIES ${READLINE_LIBRARY} ${NCURSES_LIBRARY}) + +endif(NOT READLINE_FOUND) diff --git a/cmake/FindRestinio.cmake b/cmake/FindRestinio.cmake new file mode 100644 index 0000000..a0887b3 --- /dev/null +++ b/cmake/FindRestinio.cmake @@ -0,0 +1,14 @@ +# header-only does not produce a library +if(NOT Restinio_FOUND) + find_path (Restinio_INCLUDE_DIR restinio + HINTS + "/usr/include" + "/usr/local/include" + "/opt/local/include") + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Restinio DEFAULT_MSG Restinio_INCLUDE_DIR) + if (Restinio_INCLUDE_DIR) + set(Restinio_FOUND TRUE) + set(Restinio_INCLUDE_DIRS ${Restinio_INCLUDE_DIR}) + endif() +endif() diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..23a317b --- /dev/null +++ b/configure.ac @@ -0,0 +1,235 @@ +dnl define macros +m4_define([opendht_major_version], 2) +m4_define([opendht_minor_version], 1) +m4_define([opendht_patch_version], 9) +m4_define([opendht_version], + [opendht_major_version.opendht_minor_version.opendht_patch_version]) + +AC_INIT(opendht, [opendht_version]) +AC_CONFIG_AUX_DIR(ac) +AM_INIT_AUTOMAKE([foreign subdir-objects]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CANONICAL_HOST + +AC_SUBST(OPENDHT_MAJOR_VERSION, opendht_major_version) +AC_SUBST(OPENDHT_MINOR_VERSION, opendht_minor_version) +AC_SUBST(OPENDHT_PATCH_VERSION, opendht_patch_version) + +AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [Build in debug mode, adds stricter warnings, disables optimization])) +AS_IF([test "x$enable_debug" = "xyes"], + [CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -O0 -pedantic-errors"], + [CXXFLAGS="${CXXFLAGS} -O3 -pedantic-errors"]) + +AC_PROG_CXX +AM_PROG_AR + +dnl Check for logs +AC_ARG_ENABLE([logs], [AS_HELP_STRING([--disable-logs], [Disable DHT logs])]) +AS_IF([test "x$enable_logs" != "xno"], [ + AC_DEFINE([OPENDHT_LOG], [true], [Define if DHT logs are enabled]) +], [ + AC_DEFINE([OPENDHT_LOG], [false], [Define if DHT logs are enabled]) +]) + +dnl Check for indexation +AC_ARG_ENABLE([indexation], [AS_HELP_STRING([--disable-indexation], [Disable DHT indexation])]) +AM_CONDITIONAL(ENABLE_INDEXATION, test x$enable_indexation != "xno") +AM_COND_IF(ENABLE_INDEXATION, [ + AC_DEFINE([OPENDHT_INDEXATION], [], [Define if DHT indexation is enabled]) +]) + +AC_ARG_ENABLE([peer-discovery], [AS_HELP_STRING([--disable-peer-discovery], [Disable peer-discovery])]) +AM_CONDITIONAL(ENABLE_PEER_DISCOVERY, test x$enable_peer_discovery != "xno") +AM_COND_IF(ENABLE_PEER_DISCOVERY, [AC_DEFINE([OPENDHT_PEER_DISCOVERY], [], [Define if peer discovery is enabled])]) + +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_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], [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"]) + +case "${host_os}" in + "") + SYS=unknown + ;; + *android*) + SYS=android + ;; + linux*) + SYS=linux + ;; + darwin*) + SYS=darwin + ;; + mingw32*) + SYS=mingw32 + WIN32=1 + AC_DEFINE([_POSIX_SOURCE], [1], [IEEE Std 1003.1.]) + AC_DEFINE([_POSIX_C_SOURCE], [200809L], [IEEE Std 1003.1.]) + AC_DEFINE([_XOPEN_SOURCE], [700], [POSIX and XPG 7th edition]) + AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [XPG things and X/Open Unix extensions.]) + AC_DEFINE([_BSD_SOURCE], [1], [ISO C, POSIX, and 4.3BSD things.]) + LDFLAGS="${LDFLAGS} -lws2_32" + AC_SUBST(WINDOWS_ARCH) + AC_SUBST(PROGRAMFILES) + ;; + *) + SYS="${host_os}" + ;; +esac + +AM_CONDITIONAL(WIN32, [test "x$SYS" = "xmingw32"]) +AS_IF([test "x$SYS" = "xandroid"], + [], [LDFLAGS="${LDFLAGS} -lpthread"]) + +LT_INIT() +LT_LANG(C++) + +AX_CXX_COMPILE_STDCXX(14,[noext],[mandatory]) + +PKG_PROG_PKG_CONFIG() + +AC_ARG_ENABLE([proxy_server], AS_HELP_STRING([--enable-proxy-server], [Enable proxy server ability]), proxy_server=yes, proxy_server=no) +AM_CONDITIONAL(ENABLE_PROXY_SERVER, test x$proxy_server == xyes) + +AC_ARG_ENABLE([push_notifications], AS_HELP_STRING([--enable-push-notifications], [Enable push notifications support]), push_notifications=yes, push_notifications=no) +AM_CONDITIONAL(ENABLE_PUSH_NOTIFICATIONS, test x$push_notifications == xyes) + +AC_ARG_ENABLE([proxy_server_identity], AS_HELP_STRING([--enable-proxy-server-identity], + [Enable proxy server ability]), proxy_server_identity=yes, proxy_server_identity=no) +AM_CONDITIONAL(ENABLE_PROXY_SERVER_IDENTITY, test x$proxy_server_identity == xyes -a x$proxy_server == xyes) +AC_ARG_ENABLE([proxy_server_identity], AS_HELP_STRING([--enable-proxy-server-identity], + [Enable proxy server ability]), proxy_server_identity=yes, proxy_server_identity=no) + +AC_ARG_ENABLE([proxy_client], AS_HELP_STRING([--enable-proxy-client], [Enable proxy client ability]), proxy_client=yes, proxy_client=no) +AM_CONDITIONAL(ENABLE_PROXY_CLIENT, test x$proxy_client == xyes) + +AC_ARG_ENABLE([tests], AS_HELP_STRING([--enable-tests], [Enable tests]), build_tests=yes, build_tests=no) +AM_CONDITIONAL(ENABLE_TESTS, test x$build_tests == xyes) +AM_COND_IF([ENABLE_TESTS], [ + PKG_CHECK_MODULES([CppUnit], [cppunit >= 1.12]) +]) + +AM_CONDITIONAL(PROXY_CLIENT_OR_SERVER, test x$proxy_client == xyes || test x$proxy_server == xyes) + +PKG_CHECK_MODULES([Nettle], [nettle >= 2.4]) +PKG_CHECK_MODULES([GnuTLS], [gnutls >= 3.3]) +PKG_CHECK_MODULES([MsgPack], [msgpack >= 1.2]) + +AC_ARG_WITH([jsoncpp], AS_HELP_STRING([--without-jsoncpp], [Build without JsonCpp support])) +AS_IF([test "x$with_jsoncpp" != "xno"], + [PKG_CHECK_MODULES([JsonCpp], [jsoncpp >= 1.7.2], [have_jsoncpp=yes], [have_jsoncpp=no])], + [have_jsoncpp=no]) +AS_IF([test "x$have_jsoncpp" = "xyes"], [ + AC_MSG_NOTICE([Using JsonCpp]) + CPPFLAGS+=" -DOPENDHT_JSONCPP" + AC_SUBST(jsoncpp_lib, [", jsoncpp"]) +], [ + AC_MSG_NOTICE([Not using JsonCpp]) + 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 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]) +AS_IF([test "x$have_openssl" = "xyes"], [ + AC_MSG_NOTICE([Using OpenSSL]) + AC_SUBST(openssl_lib, [", openssl"]) +], [ + AC_MSG_NOTICE([Not using OpenSSL]) +]) + +AC_ARG_WITH([http_parser_fork], AS_HELP_STRING([--with-http-parser-fork], [Build with http_parser fork to support old API])) +AS_IF([test "x$with_http_parser_fork" = "xyes"],[ + AC_MSG_NOTICE([Using http_parser fork]) + AC_DEFINE([OPENDHT_PROXY_HTTP_PARSER_FORK], [], [Define if using http parser fork]) +], [ + AC_MSG_NOTICE([Not using http_parser fork]) +]) + +AM_COND_IF([PROXY_CLIENT_OR_SERVER], [ + AC_CHECK_HEADERS([asio.hpp], exit,, AC_MSG_ERROR([Missing Asio headers files])) + CXXFLAGS="${CXXFLAGS} -DASIO_STANDALONE" + PKG_CHECK_MODULES([Fmt], [fmt >= 5.3.0], [have_fmt=yes], [have_fmt=no]) + AS_IF([test "x$have_fmt" = "xyes"], [ + AC_MSG_NOTICE([Using libfmt]) + ], [ + AC_MSG_NOTICE([Missing libfmt files]) + ]) + # http_parser has no pkgconfig, instead we check with: + AC_CHECK_LIB(http_parser, exit,, AC_MSG_ERROR([Missing HttpParser library files])) + AC_CHECK_HEADERS([http_parser.h], [http_parser_headers=yes; break;]) + AC_SUBST(http_parser_lib, ["-lhttp_parser"]) + AS_IF([test "x$http_parser_headers" != "xyes"], AC_MSG_ERROR([Missing HttpParser headers files])) +]) + +CXXFLAGS="${CXXFLAGS} -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT" + +dnl Check for Argon2 +AC_ARG_WITH([argon2], AS_HELP_STRING([--without-argon2], [Use included Argon2])) +AS_IF([test "x$with_argon2" != "xno"], + [PKG_CHECK_MODULES([Argon2], [libargon2], [have_argon2=yes], [have_argon2=no])], + [have_argon2=no]) +AS_IF([test "x$have_argon2" = "xyes"], [ + AC_MSG_NOTICE([Using system Argon2]) + AC_SUBST(argon2_lib, [", libargon2"]) +], [ + AS_IF([test "x$with_argon2" = "xyes"], [ + AC_MSG_ERROR([Argon2 requested but not found]) + ],[ + AC_MSG_NOTICE([Using included Argon2]) + AC_SUBST(Argon2_CFLAGS, "-I\${top_srcdir}/argon2/src -I\${top_srcdir}/argon2/include") + AC_SUBST(Argon2_LIBS, "libargon2.la") + AC_SUBST(Argon2_LDFLAGS, "-L\${abs_top_srcdir}/argon2/src/.libs") + ]) +]) + +AM_CONDITIONAL([WITH_INCLUDED_ARGON2], [test "x$have_argon2" = "xno"]) + +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]) + ]) +]) + +AM_COND_IF(ENABLE_PROXY_SERVER, AC_DEFINE([OPENDHT_PROXY_SERVER], [], [Building with proxy server])) +AM_COND_IF(ENABLE_PROXY_CLIENT, AC_DEFINE([OPENDHT_PROXY_CLIENT], [], [Building with proxy client])) +AM_COND_IF(ENABLE_PUSH_NOTIFICATIONS, [CPPFLAGS+=" -DOPENDHT_PUSH_NOTIFICATIONS"], []) +AM_COND_IF(ENABLE_PROXY_SERVER_IDENTITY, [CPPFLAGS+=" -DOPENDHT_PROXY_SERVER_IDENTITY"], []) + +dnl Configure setup.py if we build the python module +AC_SUBST(CURRENT_SOURCE_DIR, ".") +AC_SUBST(CURRENT_BINARY_DIR, ".") +AC_SUBST(PROJECT_SOURCE_DIR, "..") +AC_SUBST(PROJECT_BINARY_DIR, "../src/.libs") + +AC_CONFIG_FILES([Makefile + src/Makefile + tools/Makefile + python/Makefile + python/setup.py + tests/Makefile + doc/Makefile + doc/Doxyfile + opendht.pc]) +AC_OUTPUT diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..681cb28 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,16 @@ +if (OPENDHT_TOOLS) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/dhtnode.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1) +endif () + +if (OPENDHT_DOCUMENTATION) + if (NOT DOXYGEN_FOUND) + message(FATAL_ERROR "Doxygen is needed to build the documentation.") + endif() + configure_file (Doxyfile.in Doxyfile @ONLY) + add_custom_target(doc ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc/opendht) +endif() diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in new file mode 100644 index 0000000..19dfa98 --- /dev/null +++ b/doc/Doxyfile.in @@ -0,0 +1,983 @@ +# Doxyfile 1.8.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for this project. + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +DOXYFILE_ENCODING = UTF-8 + +PROJECT_NAME = @PACKAGE_NAME@ +PROJECT_NUMBER = @PACKAGE_VERSION@ +PROJECT_BRIEF = "C++ Distributed Hash Table" +PROJECT_LOGO = + +OUTPUT_DIRECTORY = +CREATE_SUBDIRS = NO +ALLOW_UNICODE_NAMES = NO +OUTPUT_LANGUAGE = English +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 4 +ALIASES = +TCL_SUBST = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +MARKDOWN_SUPPORT = YES +AUTOLINK_SUPPORT = YES +BUILTIN_STL_SUPPORT = YES +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +INLINE_GROUPED_CLASSES = NO +INLINE_SIMPLE_STRUCTS = NO +TYPEDEF_HIDES_STRUCT = NO +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +EXTRACT_ALL = NO +EXTRACT_PRIVATE = NO +EXTRACT_PACKAGE = NO +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +HIDE_COMPOUND_REFERENCE= NO +SHOW_INCLUDE_FILES = YES +SHOW_GROUPED_MEMB_INC = NO +FORCE_LOCAL_INCLUDES = NO +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO +STRICT_PROTO_MATCHING = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = NO +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +INPUT = @top_srcdir@/include +INPUT_ENCODING = UTF-8 +FILE_PATTERNS = *.cpp *.h +RECURSIVE = YES + +EXCLUDE = @top_srcdir@/include/opendht/serialize.h +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = +EXCLUDE_SYMBOLS = + +EXAMPLE_PATH = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO + +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +FILTER_SOURCE_PATTERNS = +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = NO +REFERENCES_RELATION = NO +REFERENCES_LINK_SOURCE = YES +SOURCE_TOOLTIPS = YES +USE_HTAGS = NO +VERBATIM_HEADERS = YES +CLANG_ASSISTED_PARSING = NO +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +ALPHABETICAL_INDEX = NO +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = com.savoirfairelinux + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Savoir-faire Linux + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /