From a84a0bd8dcb35f6d7ab9f4b34598f986796cf7f1 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sun, 19 Mar 2023 19:13:29 +0100 Subject: [PATCH] Added miniupnp submodule --- .gitmodules | 3 +++ CMakeLists.txt | 12 +++++++++++- external/src/miniupnp | 1 + tests/src/pool_block_tests.cpp | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 160000 external/src/miniupnp diff --git a/.gitmodules b/.gitmodules index 05c61e0..312be70 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,3 +22,6 @@ [submodule "external/src/curl"] path = external/src/curl url = https://github.com/SChernykh/curl +[submodule "external/src/miniupnp"] + path = external/src/miniupnp + url = https://github.com/SChernykh/miniupnp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d082c6..da98d25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ option(STATIC_BINARY "Build static binary" OFF) option(STATIC_LIBS "Link libuv and libzmq statically" OFF) option(WITH_RANDOMX "Include the RandomX library in the build. If this is turned off, p2pool will rely on monerod for verifying RandomX hashes" ON) option(WITH_LTO "Use link-time compiler optimization (if linking fails for you, run cmake with -DWITH_LTO=OFF)" ON) +option(WITH_UPNP "Include UPnP support. If this is turned off, p2pool will not be able to configure port forwarding on UPnP-enabled routers." ON) option(DEV_TEST_SYNC "[Developer only] Sync test, stop p2pool after sync is complete" OFF) @@ -17,7 +18,13 @@ endif() if (WITH_RANDOMX) add_definitions(-DWITH_RANDOMX) add_subdirectory(external/src/RandomX) - set(LIBS randomx) + set(LIBS ${LIBS} randomx) +endif() + +if (WITH_UPNP) + add_definitions(-DWITH_UPNP) + add_subdirectory(external/src/miniupnp/miniupnpc) + set(LIBS ${LIBS} libminiupnpc-static) endif() if (DEV_TEST_SYNC) @@ -117,6 +124,9 @@ if (WITH_RANDOMX) endif() include_directories(external/src/rapidjson/include) include_directories(external/src/robin-hood-hashing/src/include) +if (WITH_UPNP) + include_directories(external/src/miniupnp/miniupnpc/include) +endif() if (WIN32) set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi) diff --git a/external/src/miniupnp b/external/src/miniupnp new file mode 160000 index 0000000..b61674a --- /dev/null +++ b/external/src/miniupnp @@ -0,0 +1 @@ +Subproject commit b61674aa510a86ece3b5b41ec9d932f5b2bac5ad diff --git a/tests/src/pool_block_tests.cpp b/tests/src/pool_block_tests.cpp index a9cc506..3e78dd8 100644 --- a/tests/src/pool_block_tests.cpp +++ b/tests/src/pool_block_tests.cpp @@ -84,6 +84,7 @@ TEST(pool_block, deserialize) ASSERT_EQ(b.m_broadcasted, false); ASSERT_EQ(b.m_wantBroadcast, false); +#if !(defined(__FreeBSD__) || defined(__OpenBSD__)) RandomX_Hasher hasher(nullptr); hash seed; @@ -103,6 +104,7 @@ TEST(pool_block, deserialize) ASSERT_EQ(s.str(), "aa7a3c4a2d67cb6a728e244288219bf038024f3b511b0da197a19ec601000000"); ASSERT_EQ(b.m_difficulty.check_pow(pow_hash), true); +#endif destroy_crypto_cache(); }