From: Remi Gacogne Date: Mon, 8 Nov 2021 16:24:32 +0000 (+0100) Subject: dnsdist: Do not build protobuf support when DISABLE_PROTOBUF is defined X-Git-Tag: auth-4.7.0-alpha1~103^2~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=454e997438c70bb2465e0dbcbe4930f343bd833c;p=thirdparty%2Fpdns.git dnsdist: Do not build protobuf support when DISABLE_PROTOBUF is defined --- diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index 490a8b152a..2221d57cbc 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -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(new LuaFFIPerThreadResponseAction(code)); }); +#ifndef DISABLE_PROTOBUF luaCtx.writeFunction("RemoteLogAction", [](std::shared_ptr logger, boost::optional > alterFunc, boost::optional> 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 logger, boost::optional > alterFunc) { return std::shared_ptr(new DnstapLogResponseAction(identity, logger, alterFunc)); }); +#endif /* DISABLE_PROTOBUF */ luaCtx.writeFunction("TeeAction", [](const std::string& remote, boost::optional addECS) { return std::shared_ptr(new TeeAction(ComboAddress(remote, 53), addECS ? *addECS : false)); diff --git a/pdns/dnsdist-protobuf.cc b/pdns/dnsdist-protobuf.cc index df8cb3f6b2..571d8776f2 100644 --- a/pdns/dnsdist-protobuf.cc +++ b/pdns/dnsdist-protobuf.cc @@ -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 */ diff --git a/pdns/dnsdist-protobuf.hh b/pdns/dnsdist-protobuf.hh index 82f308e396..4a5cbd9914 100644 --- a/pdns/dnsdist-protobuf.hh +++ b/pdns/dnsdist-protobuf.hh @@ -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 */ diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 6f97643911..78dce34649 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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 diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc index 734eb8178d..7bb7a628dd 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-protobuf.cc @@ -20,9 +20,11 @@ * 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 */ diff --git a/pdns/dnstap.cc b/pdns/dnstap.cc index 86f933a6e1..d0fd632eb2 100644 --- a/pdns/dnstap.cc +++ b/pdns/dnstap.cc @@ -3,6 +3,8 @@ #include "gettime.hh" #include "dnstap.hh" +#ifndef DISABLE_PROTOBUF + #include 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 */ diff --git a/pdns/dnstap.hh b/pdns/dnstap.hh index 798e86762e..8a62b1a769 100644 --- a/pdns/dnstap.hh +++ b/pdns/dnstap.hh @@ -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 */ diff --git a/pdns/protozero.cc b/pdns/protozero.cc index 7d13a9cb84..218852cbc9 100644 --- a/pdns/protozero.cc +++ b/pdns/protozero.cc @@ -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(pdns::ProtoZero::Message::RRField::ttl), uTTL); pbf_rr.add_string(static_cast(pdns::ProtoZero::Message::RRField::rdata), blob); } + +#endif /* DISABLE_PROTOBUF */ diff --git a/pdns/protozero.hh b/pdns/protozero.hh index 61d009ac95..4b3438d85b 100644 --- a/pdns/protozero.hh +++ b/pdns/protozero.hh @@ -21,13 +21,16 @@ */ #pragma once -#include - #include "config.h" + #include "iputils.hh" #include "gettime.hh" #include "uuid-utils.hh" +#ifndef DISABLE_PROTOBUF + +#include + namespace pdns { namespace ProtoZero { class Message { @@ -270,3 +273,5 @@ namespace pdns { }; }; }; + +#endif /* DISABLE_PROTOBUF */