Skip to content

Commit

Permalink
Don't link with yahttp any more (header files still in use)
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Feb 11, 2025
1 parent 75dd174 commit e0a55dc
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 22 deletions.
4 changes: 4 additions & 0 deletions ext/yahttp/yahttp/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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('..'),
)
1 change: 0 additions & 1 deletion pdns/recursordist/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ endif
CLEANFILES += lua.hpp

pdns_recursor_LDADD = \
$(YAHTTP_LIBS) \
$(JSON11_LIBS) \
$(LIBCRYPTO_LIBS) \
$(BOOST_CONTEXT_LIBS) \
Expand Down
1 change: 0 additions & 1 deletion pdns/recursordist/ext/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
SUBDIRS = \
arc4random \
yahttp \
json11 \
probds

Expand Down
4 changes: 2 additions & 2 deletions pdns/recursordist/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ deps = [
dep_libssl,
dep_lua,
dep_protozero,
dep_yahttp,
dep_yahttp_header_only,
dep_htmlfiles,
dep_dnstap,
dep_libcurl,
Expand Down Expand Up @@ -422,7 +422,7 @@ tools = {
dep_nod,
dep_lua,
dep_protozero,
dep_yahttp,
dep_yahttp_header_only,
dep_json11,
dep_settings,
dep_rust_settings,
Expand Down
8 changes: 5 additions & 3 deletions pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2923,13 +2923,14 @@ static void recursorThread()
}

t_fdm = unique_ptr<FDMultiplexer>(getMultiplexer(log));

#if 0
std::unique_ptr<RecursorWebServer> 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 {
Expand All @@ -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())));
}
Expand Down
20 changes: 10 additions & 10 deletions pdns/recursordist/ws-recursor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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"
Expand Down Expand Up @@ -639,6 +637,8 @@ const std::map<std::string, MetricDefinition> MetricDefinitionStorage::d_metrics
#include "rec-prometheus-gen.h"
};

#ifndef RUST_WS

constexpr bool CHECK_PROMETHEUS_METRICS = false;

static void validatePrometheusMetrics()
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<AsyncServer*>(arg);
Expand Down Expand Up @@ -978,6 +981,7 @@ void AsyncWebServer::go()
}
server->asyncWaitForConnections(d_fdm, [this](const std::shared_ptr<Socket>& socket) { serveConnection(socket); });
}
#endif // !RUST_WS

void serveRustWeb()
{
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pdns/recursordist/ws-recursor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
class HttpRequest;
class HttpResponse;

#if 0
class AsyncServer : public Server
{
public:
Expand Down Expand Up @@ -75,3 +76,4 @@ public:
private:
std::unique_ptr<AsyncWebServer> d_ws{nullptr};
};
#endif
7 changes: 5 additions & 2 deletions pdns/webserver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -686,3 +688,4 @@ void WebServer::go()
}
_exit(1);
}
#endif // !RUST_WS
16 changes: 13 additions & 3 deletions pdns/webserver.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#pragma once
#include <map>
#include <string>
#include <list>

#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 <boost/utility.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
Expand All @@ -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 {
Expand Down Expand Up @@ -159,6 +165,8 @@ public:
}
};

#ifndef RUST_WS

class Server
{
public:
Expand Down Expand Up @@ -300,3 +308,5 @@ protected:
// Describes the amount of logging the webserver does
WebServer::LogLevel d_loglevel{WebServer::LogLevel::Detailed};
};

#endif // !RUST_WS

0 comments on commit e0a55dc

Please sign in to comment.