From: Otto Moerbeek Date: Fri, 8 Mar 2019 10:23:23 +0000 (+0100) Subject: Use a dummy class if the framestream lib is not available. X-Git-Tag: dnsdist-1.4.0-beta1~13^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10ba6d01566ddcf4703e30787e16bfa11069da32;p=thirdparty%2Fpdns.git Use a dummy class if the framestream lib is not available. --- diff --git a/pdns/fstrm_logger.hh b/pdns/fstrm_logger.hh index ceb1e80090..57ee93aed8 100644 --- a/pdns/fstrm_logger.hh +++ b/pdns/fstrm_logger.hh @@ -68,4 +68,6 @@ private: bool d_logResponses{true}; }; +#else +class FrameStreamLogger : public RemoteLoggerInterface, boost::noncopyable {}; #endif /* HAVE_FSTRM */ diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 05e5709f15..dbbaba26ef 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -57,22 +57,20 @@ #include "fstrm_logger.hh" bool g_syslog; -static bool isEnabledForQueries(const std::shared_ptr>>& fstreamLoggers) +static bool isEnabledForQueries(const std::shared_ptr>>& fstreamLoggers) { if (fstreamLoggers == nullptr) { return false; } for (auto& logger : *fstreamLoggers) { - // We know this is safe since fstreamLoggers is filled with FrameStreamLogger objects only - auto fsl = static_cast(logger.get()); - if (fsl->logQueries()) { + if (logger->logQueries()) { return true; } } return false; } -static void logFstreamQuery(const std::shared_ptr>>& fstreamLoggers, const struct timeval &queryTime, const ComboAddress& ip, bool doTCP, const vector& packet) +static void logFstreamQuery(const std::shared_ptr>>& fstreamLoggers, const struct timeval &queryTime, const ComboAddress& ip, bool doTCP, const vector& packet) { if (fstreamLoggers == nullptr) return; @@ -88,22 +86,20 @@ static void logFstreamQuery(const std::shared_ptr>>& fstreamLoggers) +static bool isEnabledForResponses(const std::shared_ptr>>& fstreamLoggers) { if (fstreamLoggers == nullptr) { return false; } for (auto& logger : *fstreamLoggers) { - // We know this is safe since fstreamLoggers is filled with FrameStreamLogger objects only - auto fsl = static_cast(logger.get()); - if (fsl->logResponses()) { + if (logger->logResponses()) { return true; } } return false; } -static void logFstreamResponse(const std::shared_ptr>>& fstreamLoggers, const ComboAddress& ip, bool doTCP, const std::string& packet, const struct timeval& queryTime, const struct timeval& replyTime) +static void logFstreamResponse(const std::shared_ptr>>& fstreamLoggers, const ComboAddress& ip, bool doTCP, const std::string& packet, const struct timeval& queryTime, const struct timeval& replyTime) { if (fstreamLoggers == nullptr) return; @@ -175,7 +171,7 @@ static void logIncomingResponse(const std::shared_ptr& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained) +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained) { size_t len; size_t bufsize=g_outgoingEDNSBufsize; diff --git a/pdns/lwres.hh b/pdns/lwres.hh index 12a08e72e2..510ae9e23d 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -41,6 +41,7 @@ #include "dns.hh" #include "namespaces.hh" #include "remote_logger.hh" +#include "fstrm_logger.hh" #include "resolve-context.hh" @@ -69,5 +70,5 @@ public: bool d_haveEDNS{false}; }; -int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult* res, bool* chained); +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult* res, bool* chained); #endif // PDNS_LWRES_HH diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 25ff42300c..eefdc3017e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -122,7 +122,7 @@ static thread_local uint64_t t_outgoingProtobufServersGeneration; #endif /* HAVE_PROTOBUF */ #ifdef HAVE_FSTRM -static thread_local std::shared_ptr>> t_frameStreamServers{nullptr}; +static thread_local std::shared_ptr>> t_frameStreamServers{nullptr}; static thread_local uint64_t t_frameStreamServersGeneration; #endif /* HAVE_FSTRM */ @@ -963,9 +963,9 @@ static bool checkOutgoingProtobufExport(LocalStateHolder& luacon #ifdef HAVE_FSTRM -static std::shared_ptr>> startFrameStreamServers(const FrameStreamExportConfig& config) +static std::shared_ptr>> startFrameStreamServers(const FrameStreamExportConfig& config) { - auto result = std::make_shared>>(); + auto result = std::make_shared>>(); for (const auto& server : config.servers) { try { diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 6c37f2604b..afc82e62c8 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -114,6 +114,7 @@ pdns_recursor_SOURCES = \ ednsoptions.cc ednsoptions.hh \ ednssubnet.cc ednssubnet.hh \ filterpo.cc filterpo.hh \ + fstrm_logger.cc fstrm_logger.hh \ gettime.cc gettime.hh \ gss_context.cc gss_context.hh \ iputils.hh iputils.cc \ @@ -390,7 +391,7 @@ endif if FSTRM pdns_recursor_SOURCES += \ - dnstap.cc dnstap.hh fstrm_logger.cc fstrm_logger.hh rec-dnstap.hh + dnstap.cc dnstap.hh rec-dnstap.hh pdns_recursor_LDADD += \ $(FSTRM_LIBS) diff --git a/pdns/recursordist/test-syncres_cc.cc b/pdns/recursordist/test-syncres_cc.cc index 23e9099594..20e7d1fa28 100644 --- a/pdns/recursordist/test-syncres_cc.cc +++ b/pdns/recursordist/test-syncres_cc.cc @@ -39,7 +39,7 @@ bool RecursorLua4::preoutquery(const ComboAddress& ns, const ComboAddress& reque return false; } -int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers,const std::set& exportTypes, LWResult* res, bool* chained) +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers,const std::set& exportTypes, LWResult* res, bool* chained) { return 0; } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 885a55828e..d0ead57a17 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -665,7 +665,7 @@ public: #endif #ifdef HAVE_FSTRM - void setFrameStreamServers(std::shared_ptr>>& servers) + void setFrameStreamServers(std::shared_ptr>>& servers) { d_frameStreamServers = servers; } @@ -815,7 +815,7 @@ private: shared_ptr d_pdl; boost::optional d_outgoingECSNetwork; std::shared_ptr>> d_outgoingProtobufServers{nullptr}; - std::shared_ptr>> d_frameStreamServers{nullptr}; + std::shared_ptr>> d_frameStreamServers{nullptr}; #ifdef HAVE_PROTOBUF boost::optional d_initialRequestId; #endif