diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ef38b69b0186ffa8cc4faa77157c50d30c0e72f9..0000000000000000000000000000000000000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "argon2"] - path = argon2 - url = https://github.com/P-H-C/phc-winner-argon2 - ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a85df4f48593a0f698ab8c9574e6819bcee6a31..230786dd98c7dc497a33e12cde1d19337bf0fa4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ 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) @@ -28,7 +27,6 @@ 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) @@ -46,22 +44,12 @@ if (NOT MSVC) find_package (Threads) find_package (PkgConfig REQUIRED) find_package (GnuTLS 3.3 REQUIRED) - pkg_search_module (Nettle nettle) + pkg_search_module (Nettle REQUIRED 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(argon2 REQUIRED libargon2) pkg_search_module(Jsoncpp jsoncpp) if (Jsoncpp_FOUND) add_definitions(-DOPENDHT_JSONCPP) @@ -95,9 +83,6 @@ if (NOT MSVC) 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 () @@ -187,6 +172,7 @@ if (Jsoncpp_INCLUDE_DIRS) endif () link_directories (${Nettle_LIBRARY_DIRS}) link_directories (${Jsoncpp_LIBRARY_DIRS}) +link_directories (${argon2_LIBRARY_DIRS}) include_directories ( ./ include/ @@ -314,23 +300,6 @@ if (OPENDHT_HTTP) ) 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 () @@ -343,11 +312,7 @@ if (OPENDHT_STATIC) ${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_include_directories(opendht-static SYSTEM PRIVATE ${argon2_INCLUDE_DIRS}) target_link_libraries(opendht-static PRIVATE ${argon2_LIBRARIES} PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${GNUTLS_LIBRARIES} ${Nettle_STATIC_LIBRARIES} @@ -412,25 +377,20 @@ if (OPENDHT_SHARED) 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 () + target_include_directories(opendht SYSTEM PRIVATE ${argon2_INCLUDE_DIRS}) 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} + ${FMT_LIBRARY} ${HTTP_PARSER_LIBRARY} ${argon2_LIBRARIES} 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}) + ${FMT_LIBRARY} ${HTTP_PARSER_LIBRARY} ${argon2_LIBRARIES}) endif () install (TARGETS opendht DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT opendht) diff --git a/argon2 b/argon2 deleted file mode 160000 index 62358ba2123abd17fccf2a108a301d4b52c01a7c..0000000000000000000000000000000000000000 --- a/argon2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 62358ba2123abd17fccf2a108a301d4b52c01a7c diff --git a/autogen.sh b/autogen.sh index 1a4d9079fcdbe41cd070b8197565a6d2b353a11f..52bbe5600bf7cc22dc04cbfe27bf141a74f551bb 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,2 +1 @@ -git submodule update --init autoreconf --install --verbose -Wall diff --git a/configure.ac b/configure.ac index 501f617af4004d84bcf695b1ff54f3e1125b427b..7b14caf9780e5e8a40d8610bf6d607ec63301260 100644 --- a/configure.ac +++ b/configure.ac @@ -132,6 +132,8 @@ AM_CONDITIONAL(PROXY_CLIENT_OR_SERVER, test x$proxy_client == xyes || test x$pro PKG_CHECK_MODULES([Nettle], [nettle >= 2.4]) PKG_CHECK_MODULES([GnuTLS], [gnutls >= 3.3]) PKG_CHECK_MODULES([MsgPack], [msgpack >= 1.2]) +PKG_CHECK_MODULES([Argon2], [libargon2]) +AC_SUBST(argon2_lib, [", libargon2"]) AC_ARG_WITH([jsoncpp], AS_HELP_STRING([--without-jsoncpp], [Build without JsonCpp support])) AS_IF([test "x$with_jsoncpp" != "xno"], @@ -157,14 +159,6 @@ AS_IF([test "x$have_openssl" = "xyes"], [ 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" @@ -183,27 +177,6 @@ AM_COND_IF([PROXY_CLIENT_OR_SERVER], [ 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], [ diff --git a/include/opendht/http.h b/include/opendht/http.h index 76ba5f0e5134fa7d8e9a589085e92fef0aaf82e1..1da883ee1f2718e381c2d344d42890df80740ed2 100644 --- a/include/opendht/http.h +++ b/include/opendht/http.h @@ -375,15 +375,3 @@ private: } // namespace http } // namespace dht -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK -namespace restinio -{ -/* Custom HTTP-methods for RESTinio > 0.5.0. - * https://github.com/Stiffstream/restinio/issues/26 - */ -constexpr const restinio::http_method_id_t method_listen {HTTP_LISTEN, "LISTEN"}; -constexpr const restinio::http_method_id_t method_stats {HTTP_STATS, "STATS"}; -constexpr const restinio::http_method_id_t method_sign {HTTP_SIGN, "SIGN"}; -constexpr const restinio::http_method_id_t method_encrypt {HTTP_ENCRYPT, "ENCRYPT"}; -} // namespace restinio -#endif diff --git a/src/Makefile.am b/src/Makefile.am index b41ec421ba06d3465e83d9da70f3fa9f48031d94..2820655ba7f8376460d4619b71e7c471e2746a2b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,7 +2,7 @@ lib_LTLIBRARIES = libopendht.la libopendht_la_CPPFLAGS = @CPPFLAGS@ -I$(top_srcdir)/include/opendht @Argon2_CFLAGS@ @JsonCpp_CFLAGS@ @MsgPack_CFLAGS@ @OpenSSL_CFLAGS@ @Fmt_CFLAGS@ libopendht_la_LIBADD = @Argon2_LIBS@ @JsonCpp_LIBS@ @GnuTLS_LIBS@ @Nettle_LIBS@ @OpenSSL_LIBS@ @Fmt_LIBS@ -libopendht_la_LDFLAGS = @LDFLAGS@ @Argon2_LDFLAGS@ -version-number @OPENDHT_MAJOR_VERSION@:@OPENDHT_MINOR_VERSION@:@OPENDHT_PATCH_VERSION@ +libopendht_la_LDFLAGS = @LDFLAGS@ -version-number @OPENDHT_MAJOR_VERSION@:@OPENDHT_MINOR_VERSION@:@OPENDHT_PATCH_VERSION@ libopendht_la_SOURCES = \ dht.cpp \ storage.h \ @@ -87,30 +87,3 @@ endif clean-local: rm -rf libargon2.la - -###################### -# ARGON2 submodule # -###################### - -if WITH_INCLUDED_ARGON2 -noinst_LTLIBRARIES = libargon2.la -libopendht_la_DEPENDENCIES = libargon2.la - -libargon2_la_CFLAGS = -std=c89 -fPIC -pthread -O3 -Wall -I@top_builddir@/argon2/include -I@top_builddir@/argon2/src -libargon2_la_SOURCES = \ - @top_builddir@/argon2/src/argon2.c \ - @top_builddir@/argon2/src/core.c \ - @top_builddir@/argon2/src/blake2/blake2b.c \ - @top_builddir@/argon2/src/thread.c \ - @top_builddir@/argon2/src/ref.c \ - @top_builddir@/argon2/src/encoding.c - -noinst_HEADERS = \ - @top_builddir@/argon2/include/argon2.h \ - @top_builddir@/argon2/src/blake2/blake2.h \ - @top_builddir@/argon2/src/blake2/blake2-impl.h \ - @top_builddir@/argon2/src/blake2/blamka-round-ref.h \ - @top_builddir@/argon2/src/core.h \ - @top_builddir@/argon2/src/encoding.h \ - @top_builddir@/argon2/src/thread.h -endif diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp index eb434970013705543db676be92f9a23f086b684b..cceb64c8e8df6b8e9d93c0714f1a3d2f1109177d 100644 --- a/src/dht_proxy_client.cpp +++ b/src/dht_proxy_client.cpp @@ -829,13 +829,8 @@ DhtProxyClient::listen(const InfoHash& key, ValueCallback cb, Value::Filter filt restinio::http_request_header_t header; if (deviceKey_.empty()){ // listen method = ListenMethod::LISTEN; -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - header.method(restinio::method_listen); - header.request_target("/" + key.toString()); -#else header.method(restinio::http_method_get()); header.request_target("/key/" + key.toString() + "/listen"); -#endif } else { method = ListenMethod::SUBSCRIBE; @@ -1151,13 +1146,8 @@ DhtProxyClient::restartListeners(const asio::error_code &ec) auto cb = listener.cb; // define header restinio::http_request_header_t header; -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - header.method(restinio::method_listen); - header.request_target("/" + search.first.toString()); -#else header.method(restinio::http_method_get()); header.request_target("/key/" + search.first.toString() + "/listen"); -#endif sendListen(header, cb, opstate, listener, ListenMethod::LISTEN); } } diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index cafe86e0522938106d23deeac09a784c7df50f12..647901b6cc7c25a839c7d9e79ede8c36b174e67d 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -39,26 +39,6 @@ using namespace std::placeholders; using namespace std::chrono_literals; -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK -namespace restinio { -struct custom_http_methods_t -{ - static constexpr restinio::http_method_id_t from_nodejs(int m) noexcept { - if(m == method_listen.raw_id()) - return method_listen; - else if(m == method_stats.raw_id()) - return method_stats; - else if(m == method_sign.raw_id()) - return method_sign; - else if(m == method_encrypt.raw_id()) - return method_encrypt; - else - return restinio::default_http_methods_t::from_nodejs(m); - } -}; -} -#endif - namespace dht { constexpr char RESP_MSG_JSON_INCORRECT[] = "{\"err:\":\"Incorrect JSON\"}"; constexpr char RESP_MSG_SERVICE_UNAVAILABLE[] = "{\"err\":\"Incorrect DhtRunner\"}"; @@ -156,9 +136,6 @@ DhtProxyServer::onConnectionClosed(restinio::connection_id_t id) struct DhtProxyServer::RestRouterTraitsTls : public restinio::default_tls_traits_t { using timer_manager_t = restinio::asio_timer_manager_t; -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - using http_methods_mapper_t = restinio::custom_http_methods_t; -#endif using logger_t = opendht_logger_t; using request_handler_t = RestRouter; using connection_state_listener_t = ConnectionListener; @@ -166,9 +143,6 @@ struct DhtProxyServer::RestRouterTraitsTls : public restinio::default_tls_traits struct DhtProxyServer::RestRouterTraits : public restinio::default_traits_t { using timer_manager_t = restinio::asio_timer_manager_t; -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - using http_methods_mapper_t = restinio::custom_http_methods_t; -#endif using logger_t = opendht_logger_t; using request_handler_t = RestRouter; using connection_state_listener_t = ConnectionListener; @@ -613,11 +587,6 @@ DhtProxyServer::createRestRouter() // **************************** LEGACY ROUTES **************************** // node.info router->http_get("/", std::bind(&DhtProxyServer::getNodeInfo, this, _1, _2)); -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - // node.stats - router->add_handler(restinio::custom_http_methods_t::from_nodejs(restinio::method_stats.raw_id()), - "/", std::bind(&DhtProxyServer::getStats, this, _1, _2)); -#endif // key.options router->add_handler(restinio::http_method_options(), "/:hash", std::bind(&DhtProxyServer::options, this, _1, _2)); @@ -625,11 +594,6 @@ DhtProxyServer::createRestRouter() router->http_get("/:hash", std::bind(&DhtProxyServer::get, this, _1, _2)); // key.post router->http_post("/:hash", std::bind(&DhtProxyServer::put, this, _1, _2)); -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - // key.listen - router->add_handler(restinio::custom_http_methods_t::from_nodejs(restinio::method_listen.raw_id()), - "/:hash", std::bind(&DhtProxyServer::listen, this, _1, _2)); -#endif #ifdef OPENDHT_PUSH_NOTIFICATIONS // key.subscribe router->add_handler(restinio::http_method_subscribe(), @@ -639,14 +603,6 @@ DhtProxyServer::createRestRouter() "/:hash", std::bind(&DhtProxyServer::unsubscribe, this, _1, _2)); #endif //OPENDHT_PUSH_NOTIFICATIONS #ifdef OPENDHT_PROXY_SERVER_IDENTITY -#ifdef OPENDHT_PROXY_HTTP_PARSER_FORK - // key.sign - router->add_handler(restinio::custom_http_methods_t::from_nodejs(restinio::method_sign.raw_id()), - "/:hash", std::bind(&DhtProxyServer::putSigned, this, _1, _2)); - // key.encrypt - router->add_handler(restinio::custom_http_methods_t::from_nodejs(restinio::method_encrypt.raw_id()), - "/:hash", std::bind(&DhtProxyServer::putEncrypted, this, _1, _2)); -#endif #endif // OPENDHT_PROXY_SERVER_IDENTITY // **************************** NEW ROUTES **************************** diff --git a/tools/Makefile.am b/tools/Makefile.am index a9c4b1835c28bb2214db414ff3e7c29b00d72dbc..14284d02a96a5c15d73a0c4bd045e93ee262886c 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,10 +4,10 @@ noinst_HEADERS = tools_common.h AM_CPPFLAGS = -isystem @top_srcdir@/include @JsonCpp_CFLAGS@ @MsgPack_CFLAGS@ dhtnode_SOURCES = dhtnode.cpp -dhtnode_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @Argon2_LDFLAGS@ @GnuTLS_LIBS@ +dhtnode_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @GnuTLS_LIBS@ dhtchat_SOURCES = dhtchat.cpp -dhtchat_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @Argon2_LDFLAGS@ @GnuTLS_LIBS@ +dhtchat_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @GnuTLS_LIBS@ dhtscanner_SOURCES = dhtscanner.cpp -dhtscanner_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @Argon2_LDFLAGS@ @GnuTLS_LIBS@ +dhtscanner_LDFLAGS = -lopendht -lreadline -L@top_builddir@/src/.libs @GnuTLS_LIBS@