]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Do not build protobuf support when DISABLE_PROTOBUF is defined
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 8 Nov 2021 16:24:32 +0000 (17:24 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 22 Dec 2021 08:30:43 +0000 (09:30 +0100)
pdns/dnsdist-lua-actions.cc
pdns/dnsdist-protobuf.cc
pdns/dnsdist-protobuf.hh
pdns/dnsdist.cc
pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc
pdns/dnstap.cc
pdns/dnstap.hh
pdns/protozero.cc
pdns/protozero.hh

index 490a8b152a6ff64b55c1e1daf8b5605d994fc083..2221d57cbc986ce167285ed2361267361bd3e15f 100644 (file)
@@ -1391,6 +1391,7 @@ private:
   bool d_hasV6;
 };
 
+#ifndef DISABLE_PROTOBUF
 static DnstapMessage::ProtocolType ProtocolToDNSTap(dnsdist::Protocol protocol)
 {
   if (protocol == dnsdist::Protocol::DoUDP) {
@@ -1497,6 +1498,8 @@ private:
   std::string d_ipEncryptKey;
 };
 
+#endif /* DISABLE_PROTOBUF */
+
 class SNMPTrapAction : public DNSAction
 {
 public:
@@ -1542,6 +1545,7 @@ private:
   std::string d_value;
 };
 
+#ifndef DISABLE_PROTOBUF
 class DnstapLogResponseAction : public DNSResponseAction, public boost::noncopyable
 {
 public:
@@ -1628,6 +1632,8 @@ private:
   bool d_includeCNAME;
 };
 
+#endif /* DISABLE_PROTOBUF */
+
 class DropResponseAction : public DNSResponseAction
 {
 public:
@@ -2334,6 +2340,7 @@ void setupLuaActions(LuaContext& luaCtx)
       return std::shared_ptr<DNSResponseAction>(new LuaFFIPerThreadResponseAction(code));
     });
 
+#ifndef DISABLE_PROTOBUF
   luaCtx.writeFunction("RemoteLogAction", [](std::shared_ptr<RemoteLoggerInterface> logger, boost::optional<std::function<void(DNSQuestion*, DNSDistProtoBufMessage*)> > alterFunc, boost::optional<std::unordered_map<std::string, std::string>> vars) {
       if (logger) {
         // avoids potentially-evaluated-expression warning with clang.
@@ -2389,6 +2396,7 @@ void setupLuaActions(LuaContext& luaCtx)
   luaCtx.writeFunction("DnstapLogResponseAction", [](const std::string& identity, std::shared_ptr<RemoteLoggerInterface> logger, boost::optional<std::function<void(DNSResponse*, DnstapMessage*)> > alterFunc) {
       return std::shared_ptr<DNSResponseAction>(new DnstapLogResponseAction(identity, logger, alterFunc));
     });
+#endif /* DISABLE_PROTOBUF */
 
   luaCtx.writeFunction("TeeAction", [](const std::string& remote, boost::optional<bool> addECS) {
       return std::shared_ptr<DNSAction>(new TeeAction(ComboAddress(remote, 53), addECS ? *addECS : false));
index df8cb3f6b20d5b6b91aaed3432c27f6d47f3173b..571d8776f23f357066c9a6d82d6dc42b7f5dbc33 100644 (file)
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #include "config.h"
+
+#ifndef DISABLE_PROTOBUF
 #include "dnsdist.hh"
 #include "dnsdist-protobuf.hh"
 #include "protozero.hh"
@@ -184,3 +186,5 @@ void DNSDistProtoBufMessage::serialize(std::string& data) const
 
   m.commitResponse();
 }
+
+#endif /* DISABLE_PROTOBUF */
index 82f308e396546876eddef10bc1444872fee11d76..4a5cbd9914054ad33a4c2ad6eb3cba78464bb7f7 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "dnsdist.hh"
 #include "dnsname.hh"
+
+#ifndef DISABLE_PROTOBUF
 #include "protozero.hh"
 
 class DNSDistProtoBufMessage
@@ -91,3 +93,5 @@ private:
   pdns::ProtoZero::Message::MessageType d_type{pdns::ProtoZero::Message::MessageType::DNSQueryType};
   bool d_includeCNAME{false};
 };
+
+#endif /* DISABLE_PROTOBUF */
index 6f97643911da8ddddd8e7041ba21cb2f5136f066..78dce34649112ff7d115823b14126bb32b347d13 100644 (file)
@@ -2390,7 +2390,9 @@ int main(int argc, char** argv)
 #ifdef HAVE_NGHTTP2
         cout<<"outgoing-dns-over-https(nghttp2) ";
 #endif
+#ifndef DISABLE_PROTOBUF
         cout<<"protobuf ";
+#endif
 #ifdef HAVE_RE2
         cout<<"re2 ";
 #endif
index 734eb8178d4cd0a6ceaeaa3595fc5972d7432654..7bb7a628ddc518cd2546bc2bd14acd74a4ac97ba 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #include "config.h"
+
 #include "dnsdist.hh"
 #include "dnsdist-lua.hh"
 
+#ifndef DISABLE_PROTOBUF
 #include "dnsdist-protobuf.hh"
 #include "dnstap.hh"
 #include "fstrm_logger.hh"
@@ -163,3 +165,8 @@ void setupLuaBindingsProtoBuf(LuaContext& luaCtx, bool client, bool configCheck)
       return std::string();
   });
 }
+#else /* DISABLE_PROTOBUF */
+void setupLuaBindingsProtoBuf(LuaContext&, bool, bool)
+{
+}
+#endif /* DISABLE_PROTOBUF */
index 86f933a6e1737c588077bceebe929cd6936d6609..d0fd632eb255c91a3047193821cae101de842cda 100644 (file)
@@ -3,6 +3,8 @@
 #include "gettime.hh"
 #include "dnstap.hh"
 
+#ifndef DISABLE_PROTOBUF
+
 #include <protozero/pbf_writer.hpp>
 
 namespace DnstapBaseFields {
@@ -90,3 +92,5 @@ void DnstapMessage::setExtra(const std::string& extra)
   protozero::pbf_writer pbf{d_buffer};
   pbf.add_bytes(DnstapBaseFields::extra, extra);
 }
+
+#endif /* DISABLE_PROTOBUF */
index 798e86762eb5c8d168ba2673347c636ae410d2b7..8a62b1a7695b5be0926921ae8dfc5c0fd750d154 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "dnsname.hh"
 #include "iputils.hh"
+
+#ifndef DISABLE_PROTOBUF
 #include "protozero.hh"
 
 class DnstapMessage
@@ -43,3 +45,5 @@ public:
 protected:
   std::string& d_buffer;
 };
+
+#endif /* DISABLE_PROTOBUF */
index 7d13a9cb8411d898aade694a75b3dbdbc646fdff..218852cbc99130181234a946145ef995fd67c108 100644 (file)
@@ -21,6 +21,8 @@
  */
 
 #include "protozero.hh"
+
+#ifndef DISABLE_PROTOBUF
 #include "dnsparser.hh"
 
 void pdns::ProtoZero::Message::encodeComboAddress(const protozero::pbf_tag_type type, const ComboAddress& ca)
@@ -157,3 +159,5 @@ void pdns::ProtoZero::Message::addRR(const DNSName& name, uint16_t uType, uint16
   pbf_rr.add_uint32(static_cast<protozero::pbf_tag_type>(pdns::ProtoZero::Message::RRField::ttl), uTTL);
   pbf_rr.add_string(static_cast<protozero::pbf_tag_type>(pdns::ProtoZero::Message::RRField::rdata), blob);
 }
+
+#endif /* DISABLE_PROTOBUF */
index 61d009ac951bea5ee5d4671739a1bbd3b1389369..4b3438d85bb0fdbf0ffb7dac0903b613cbe73993 100644 (file)
  */
 #pragma once
 
-#include <protozero/pbf_writer.hpp>
-
 #include "config.h"
+
 #include "iputils.hh"
 #include "gettime.hh"
 #include "uuid-utils.hh"
 
+#ifndef DISABLE_PROTOBUF
+
+#include <protozero/pbf_writer.hpp>
+
 namespace pdns {
   namespace ProtoZero {
     class Message {
@@ -270,3 +273,5 @@ namespace pdns {
     };
   };
 };
+
+#endif /* DISABLE_PROTOBUF */