From e0a55dc373168222ed15bad0d236a7ce556a2a42 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 3 Dec 2024 13:31:53 +0100 Subject: [PATCH] Don't link with yahttp any more (header files still in use) --- ext/yahttp/yahttp/meson.build | 4 ++++ pdns/recursordist/Makefile.am | 1 - pdns/recursordist/ext/Makefile.am | 1 - pdns/recursordist/meson.build | 4 ++-- pdns/recursordist/rec-main.cc | 8 +++++--- pdns/recursordist/ws-recursor.cc | 20 ++++++++++---------- pdns/recursordist/ws-recursor.hh | 2 ++ pdns/webserver.cc | 7 +++++-- pdns/webserver.hh | 16 +++++++++++++--- 9 files changed, 41 insertions(+), 22 deletions(-) diff --git a/ext/yahttp/yahttp/meson.build b/ext/yahttp/yahttp/meson.build index 2704d4798cc7..b9eb5d570f8a 100644 --- a/ext/yahttp/yahttp/meson.build +++ b/ext/yahttp/yahttp/meson.build @@ -20,3 +20,7 @@ dep_yahttp = declare_dependency( link_with: lib_yahttp, include_directories: include_directories('..'), ) + +dep_yahttp_header_only = declare_dependency( + include_directories: include_directories('..'), +) diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 0c57de01a597..488fc8e926c7 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -252,7 +252,6 @@ endif CLEANFILES += lua.hpp pdns_recursor_LDADD = \ - $(YAHTTP_LIBS) \ $(JSON11_LIBS) \ $(LIBCRYPTO_LIBS) \ $(BOOST_CONTEXT_LIBS) \ diff --git a/pdns/recursordist/ext/Makefile.am b/pdns/recursordist/ext/Makefile.am index 65131d0b277e..2fb9da054d6f 100644 --- a/pdns/recursordist/ext/Makefile.am +++ b/pdns/recursordist/ext/Makefile.am @@ -1,6 +1,5 @@ SUBDIRS = \ arc4random \ - yahttp \ json11 \ probds diff --git a/pdns/recursordist/meson.build b/pdns/recursordist/meson.build index 81d740568fe5..5f276d25fc8e 100644 --- a/pdns/recursordist/meson.build +++ b/pdns/recursordist/meson.build @@ -312,7 +312,7 @@ deps = [ dep_libssl, dep_lua, dep_protozero, - dep_yahttp, + dep_yahttp_header_only, dep_htmlfiles, dep_dnstap, dep_libcurl, @@ -422,7 +422,7 @@ tools = { dep_nod, dep_lua, dep_protozero, - dep_yahttp, + dep_yahttp_header_only, dep_json11, dep_settings, dep_rust_settings, diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 7dfcec091fd5..98dbff074d64 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -2923,13 +2923,14 @@ static void recursorThread() } t_fdm = unique_ptr(getMultiplexer(log)); - +#if 0 std::unique_ptr rws; - +#endif t_fdm->addReadFD(threadInfo.getPipes().readToThread, handlePipeRequest); if (threadInfo.isHandler()) { - if (false && ::arg().mustDo("webserver")) { +#if 0 + if (::arg().mustDo("webserver")) { SLOG(g_log << Logger::Warning << "Enabling web server" << endl, log->info(Logr::Info, "Enabling web server")); try { @@ -2941,6 +2942,7 @@ static void recursorThread() _exit(99); } } +#endif SLOG(g_log << Logger::Info << "Enabled '" << t_fdm->getName() << "' multiplexer" << endl, log->info(Logr::Info, "Enabled multiplexer", "name", Logging::Loggable(t_fdm->getName()))); } diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index 7de35f61a94e..3181564100d4 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -19,9 +19,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifdef HAVE_CONFIG_H + #include "config.h" -#endif + #include "ws-recursor.hh" #include "json.hh" @@ -42,8 +42,6 @@ #include "logging.hh" #include "rec-lua-conf.hh" #include "rpzloader.hh" -#include "uuid-utils.hh" -#include "tcpiohandler.hh" #include "rec-main.hh" #include "settings/cxxsettings.hh" // IWYU pragma: keep, needed by included generated file #include "settings/rust/src/bridge.hh" @@ -639,6 +637,8 @@ const std::map MetricDefinitionStorage::d_metrics #include "rec-prometheus-gen.h" }; +#ifndef RUST_WS + constexpr bool CHECK_PROMETHEUS_METRICS = false; static void validatePrometheusMetrics() @@ -719,8 +719,9 @@ RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm) d_ws->registerWebHandler("/metrics", prometheusMetrics, "GET"); d_ws->go(); } +#endif // !RUST_WS -void RecursorWebServer::jsonstat(HttpRequest* req, HttpResponse* resp) +static void jsonstat(HttpRequest* req, HttpResponse* resp) { string command; @@ -833,6 +834,8 @@ void RecursorWebServer::jsonstat(HttpRequest* req, HttpResponse* resp) resp->setErrorResult("Command '" + command + "' not found", 404); } +#ifndef RUST_WS + void AsyncServerNewConnectionMT(void* arg) { auto* server = static_cast(arg); @@ -978,6 +981,7 @@ void AsyncWebServer::go() } server->asyncWaitForConnections(d_fdm, [this](const std::shared_ptr& socket) { serveConnection(socket); }); } +#endif // !RUST_WS void serveRustWeb() { @@ -1054,11 +1058,7 @@ namespace pdns::rust::web::rec #define WRAPPER(A) \ void A(const Request& rustRequest, Response& rustResponse) { rustWrapper(::A, rustRequest, rustResponse); } -void jsonstat(const Request& rustRequest, Response& rustResponse) -{ - rustWrapper(RecursorWebServer::jsonstat, rustRequest, rustResponse); -} - +WRAPPER(jsonstat) WRAPPER(apiDiscovery) WRAPPER(apiDiscoveryV1) WRAPPER(apiServer) diff --git a/pdns/recursordist/ws-recursor.hh b/pdns/recursordist/ws-recursor.hh index 18ab40b5b7fc..882d29ba4fb3 100644 --- a/pdns/recursordist/ws-recursor.hh +++ b/pdns/recursordist/ws-recursor.hh @@ -28,6 +28,7 @@ class HttpRequest; class HttpResponse; +#if 0 class AsyncServer : public Server { public: @@ -75,3 +76,4 @@ public: private: std::unique_ptr d_ws{nullptr}; }; +#endif diff --git a/pdns/webserver.cc b/pdns/webserver.cc index fea0724d5382..e6595d6fac7f 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -19,9 +19,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifdef HAVE_CONFIG_H + #include "config.h" -#endif + #include "utility.hh" #include "webserver.hh" #include "misc.hh" @@ -136,6 +136,8 @@ void HttpResponse::setSuccessResult(const std::string& message, const int status this->status = status_; } +#ifndef RUST_WS + static void bareHandlerWrapper(const WebServer::HandlerFunction& handler, YaHTTP::Request* req, YaHTTP::Response* resp) { // wrapper to convert from YaHTTP::* to our subclasses @@ -686,3 +688,4 @@ void WebServer::go() } _exit(1); } +#endif // !RUST_WS diff --git a/pdns/webserver.hh b/pdns/webserver.hh index e1f3795f6912..e542bc54f9b1 100644 --- a/pdns/webserver.hh +++ b/pdns/webserver.hh @@ -20,9 +20,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #pragma once -#include -#include -#include + +#ifdef RECURSOR +// Network facing/routing part of webserver is implemented in rust. We stil use a few classes from +// yahttp, but do not link to it. +#define RUST_WS +#endif + #include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Woverloaded-virtual" @@ -34,7 +38,9 @@ #include "credentials.hh" #include "namespaces.hh" +#ifndef REST_WS #include "sstuff.hh" +#endif #include "logging.hh" class HttpRequest : public YaHTTP::Request { @@ -159,6 +165,8 @@ public: } }; +#ifndef RUST_WS + class Server { public: @@ -300,3 +308,5 @@ protected: // Describes the amount of logging the webserver does WebServer::LogLevel d_loglevel{WebServer::LogLevel::Detailed}; }; + +#endif // !RUST_WS