libssl1.1 \
libsystemd0 \
libsodium23 \
- libfstrm0 \
- libprotobuf17
+ libfstrm0
install-auth-deps:
description: Install all libraries needed to run the auth
libfstrm0 \
libh2o-evloop0.13 \
liblmdb0 \
- libprotobuf17 \
libre2-5 \
libssl-dev \
libsystemd0 \
libsodium23 \
patch \
- protobuf-compiler \
python3-venv
install-ixfrdist-deps:
name: configure
command: |
./configure \
- --disable-unit-tests \
- --disable-protobuf
+ --disable-unit-tests
working_directory: ~/project/pdns/recursordist
- run:
name: build docs
name: configure
command: |
./configure \
- --disable-unit-tests \
- --disable-protobuf
+ --disable-unit-tests
working_directory: ~/project/pdns/dnsdistdist
- run:
name: build docs
libcap-dev \
libluajit-5.1-dev \
libfstrm-dev \
- libprotobuf-dev \
libsodium-dev \
libssl-dev \
libsystemd-dev \
libtool \
make \
pkg-config \
- protobuf-compiler \
ragel \
systemd \
python3-venv
--with-libsodium \
--with-lua=luajit \
--with-libcap \
- --with-protobuf=yes \
--without-net-snmp
working_directory: ~/project/pdns/recursordist
- run:
password: $DOCKERHUB_PASSWORD
steps:
- add-auth-repo
- - run: apt-get --no-install-recommends install -qq -y pdns-server pdns-backend-bind pdns-tools daemontools authbind jq libfaketime lua-posix lua-socket moreutils bc python3-venv protobuf-compiler
+ - run: apt-get --no-install-recommends install -qq -y pdns-server pdns-backend-bind pdns-tools daemontools authbind jq libfaketime lua-posix lua-socket moreutils bc python3-venv
- install-recursor-deps
- run:
name: Set up authbind
libfstrm-dev \
liblmdb-dev \
libluajit-5.1-dev \
- libprotobuf-dev \
libre2-dev \
libsnmp-dev \
libsodium-dev \
libtool \
make \
pkg-config \
- protobuf-compiler \
ragel \
python3-venv
- install-coverity-tools
--with-libsodium \
--with-lua=luajit \
--with-libcap \
- --with-protobuf=yes \
--with-re2
working_directory: /opt/project/pdns/dnsdistdist
- run:
libcap-dev \
libluajit-5.1-dev \
libfstrm-dev \
- libprotobuf-dev \
libsodium-dev \
libssl-dev \
libsystemd-dev \
libtool \
make \
pkg-config \
- protobuf-compiler \
ragel \
python3-venv
- install-coverity-tools
--with-libsodium \
--with-lua=luajit \
--with-libcap \
- --with-protobuf=yes \
--without-net-snmp
working_directory: /opt/project/pdns/recursordist
- run:
libh2o-evloop-dev \
liblmdb-dev \
libluajit-5.1-dev \
- libprotobuf-dev \
libre2-dev \
libsnmp-dev \
libsodium-dev \
libtool \
make \
pkg-config \
- protobuf-compiler \
ragel \
systemd \
python3-venv
--with-libsodium \
--with-lua=luajit \
--with-libcap \
- --with-protobuf=yes \
--with-re2 \
--enable-asan \
--enable-ubsan
libmaxminddb-dev \
libp11-kit-dev \
libpq-dev \
- libprotobuf-dev \
libre2-dev \
libsnmp-dev \
libsodium-dev \
libsystemd-dev \
libwslay-dev \
libyaml-cpp-dev \
- protobuf-compiler \
ragel \
unixodbc-dev
- name: Build auth
run: |
autoreconf -vfi
- ./configure --with-modules='bind geoip gmysql godbc gpgsql gsqlite3 ldap lmdb lua2 pipe random remote tinydns' --enable-tools --enable-ixfrdist --enable-dns-over-tls --enable-experimental-pkcs11 --with-libsodium --with-protobuf --enable-lua-records CFLAGS='-O0' CXXFLAGS='-O0'
+ ./configure --with-modules='bind geoip gmysql godbc gpgsql gsqlite3 ldap lmdb lua2 pipe random remote tinydns' --enable-tools --enable-ixfrdist --enable-dns-over-tls --enable-experimental-pkcs11 --with-libsodium --enable-lua-records CFLAGS='-O0' CXXFLAGS='-O0'
make -j8 -C ext
make -j8 -C modules
make -j8 -C pdns
./configure --enable-unit-tests --enable-dnstap --enable-dnscrypt --enable-dns-over-tls --enable-dns-over-https LIBS=-lwslay CFLAGS='-O0' CXXFLAGS='-O0'
make -j8 -C ext/ipcrypt
make -j8 -C ext/yahttp
- make dnsmessage.pb.cc dnstap.pb.cc
make -j4 dnsdist
- name: Build recursor
autoreconf -vfi
./configure --enable-unit-tests --enable-nod --enable-dnstap CFLAGS='-O0' CXXFLAGS='-O0'
make -j8 -C ext
- make dnsmessage.pb.cc dnstap.pb.cc htmlfiles.h
+ make htmlfiles.h
make -j8 pdns_recursor rec_control
- name: Perform CodeQL Analysis
# TODO: control file is not in tarballs at all right now
RUN mk-build-deps -i -t 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' /source/builder-support/debian/recursor/debian-buster/control && \
apt-get clean
-# RUN apt-get -y install protobuf-compiler && apt-get clean
COPY pdns /source/pdns
COPY build-aux /source/build-aux
run "sudo apt-get -qq --no-install-recommends install \
libboost-all-dev \
libluajit-5.1-dev \
- libedit-dev \
- libprotobuf-dev \
- protobuf-compiler"
+ libedit-dev"
run "cd .."
run "wget http://ppa.launchpad.net/kalon33/gamesgiroll/ubuntu/pool/main/libs/libsodium/libsodium-dev_1.0.3-1~ppa14.04+1_amd64.deb"
libmaxminddb-dev,
libp11-kit-dev,
libpq-dev,
- libprotobuf-dev,
libsodium-dev,
libsqlite3-dev,
libssl-dev,
libyaml-cpp-dev (>= 0.5),
pkg-config,
po-debconf,
- protobuf-compiler,
ragel,
systemd [linux-any],
unixodbc-dev (>= 2.3.1)
--enable-tools \
--with-libsodium \
--with-lua=luajit \
- --with-protobuf \
--enable-unit-tests \
--enable-experimental-pkcs11 \
--enable-lua-records \
libmysqlclient-dev,
libp11-kit-dev,
libpq-dev,
- libprotobuf-dev,
libsodium-dev,
libsqlite3-dev,
libssl-dev,
libyaml-cpp-dev (>= 0.5),
pkg-config,
po-debconf,
- protobuf-compiler,
ragel,
systemd [linux-any],
unixodbc-dev (>= 2.3.1)
--enable-tools \
--with-libsodium \
--with-lua=luajit \
- --with-protobuf \
--enable-unit-tests \
--enable-experimental-pkcs11 \
--enable-lua-records \
libmaxminddb-dev,
libp11-kit-dev,
libpq-dev,
- libprotobuf-dev,
libsodium-dev,
libsqlite3-dev,
libssl-dev,
libyaml-cpp-dev (>= 0.5),
pkg-config,
po-debconf,
- protobuf-compiler,
ragel,
systemd [linux-any],
unixodbc-dev (>= 2.3.1)
--with-modules="" \
--enable-tools \
--with-libsodium \
- --with-protobuf \
--enable-unit-tests \
--enable-experimental-pkcs11 \
--enable-lua-records \
liblmdb-dev,
libluajit-5.1-dev [!arm64],
liblua5.3-dev [arm64],
- libprotobuf-dev,
libre2-dev,
libsnmp-dev,
libsodium-dev,
libsystemd-dev [linux-any],
libwslay-dev,
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Standards-Version: 4.1.5
--with-libsodium \
--with-re2 \
--with-ebpf \
- --with-protobuf \
--with-service-user='_dnsdist' \
--with-service-group='_dnsdist' \
$(CONFIGURE_ARGS)
libcdb-dev,
libedit-dev,
libluajit-5.1-dev,
- libprotobuf-dev,
libre2-dev,
libsodium-dev,
libssl-dev,
libsystemd-dev [linux-any],
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Standards-Version: 4.1.0
--with-re2 \
--with-ebpf \
--with-lua=luajit \
- --with-protobuf \
--with-service-user='_dnsdist' \
--with-service-group='_dnsdist' \
$(CONFIGURE_ARGS)
liblmdb-dev,
libluajit-5.1-dev [!arm64],
liblua5.3-dev [arm64],
- libprotobuf-dev,
libre2-dev,
libsodium-dev,
libssl-dev,
libsystemd-dev [linux-any],
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Standards-Version: 4.1.0
--with-libsodium \
--with-re2 \
--with-ebpf \
- --with-protobuf \
--with-service-user='_dnsdist' \
--with-service-group='_dnsdist' \
$(CONFIGURE_ARGS)
libcap-dev,
libluajit-5.1-dev [!arm64],
liblua5.3-dev [arm64],
- libprotobuf-dev,
libfstrm-dev,
libsodium-dev,
libssl-dev,
libsystemd-dev [linux-any],
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Vcs-Git: https://anonscm.debian.org/git/pkg-dns/pdns-recursor.git
--enable-unit-tests \
--with-libcap \
--with-libsodium \
- --with-protobuf=yes \
--enable-dnstap \
--without-net-snmp \
--disable-silent-rules \
libboost-all-dev,
libcap-dev,
libluajit-5.1-dev,
- libprotobuf-dev,
libsnmp-dev,
libsodium-dev,
libssl-dev,
libsystemd-dev [linux-any],
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Homepage: https://www.powerdns.com/
--with-lua=luajit \
--with-libcap \
--with-libsodium \
- --with-protobuf=yes \
--with-net-snmp \
--disable-silent-rules \
--with-service-user=pdns \
libcap-dev,
libluajit-5.1-dev [!arm64],
liblua5.3-dev [arm64],
- libprotobuf-dev,
libfstrm-dev,
libsodium-dev,
libssl-dev,
libsystemd-dev [linux-any],
pkg-config,
- protobuf-compiler,
ragel,
systemd [linux-any]
Vcs-Git: https://anonscm.debian.org/git/pkg-dns/pdns-recursor.git
--enable-unit-tests \
--with-libcap \
--with-libsodium \
- --with-protobuf=yes \
--enable-dnstap \
--without-net-snmp \
--disable-silent-rules \
%if 0%{?el6}
BuildRequires: boost148-devel
BuildRequires: lua-devel
-BuildRequires: protobuf-compiler
-BuildRequires: protobuf-devel
BuildRequires: re2-devel
%endif
%if 0%{?suse_version}
%define lua_implementation luajit
%endif
BuildRequires: net-snmp-devel
-BuildRequires: protobuf-compiler
-BuildRequires: protobuf-devel
BuildRequires: re2-devel
BuildRequires: systemd
BuildRequires: systemd-devel
--without-libsodium \
--with-re2 \
--with-net-snmp \
- --with-protobuf \
--with-boost=/usr/include/boost148 LIBRARY_PATH=/usr/lib64/boost148
%endif
%if 0%{?suse_version}
--without-libsodium \
--without-re2 \
--enable-systemd --with-systemd=/lib/systemd/system \
- --without-protobuf \
--without-net-snmp
%endif
%if 0%{?rhel} >= 7
--with-gnutls \
- --with-protobuf \
--enable-dnstap \
--with-lua=%{lua_implementation} \
--with-libcap \
%endif
%if 0%{?rhel} >= 7
-BuildRequires: protobuf-compiler
-BuildRequires: protobuf-devel
BuildRequires: fstrm-devel
%endif
--disable-static \
--enable-unit-tests \
%if 0%{?rhel} == 6
- --without-protobuf \
--with-boost=/usr/include/boost148 LIBRARY_PATH=/usr/lib64/boost148 \
CPPFLAGS=-D__STDC_FORMAT_MACROS
make %{?_smp_mflags} LIBRARY_PATH=/usr/lib64/boost148
%else
- --with-protobuf \
--enable-dnstap \
--with-libcap \
--with-lua=%{lua_implementation} \
BuildRequires: systemd-units
BuildRequires: systemd-devel
-BuildRequires: protobuf-devel
-BuildRequires: protobuf-compiler
BuildRequires: p11-kit-devel
BuildRequires: libcurl-devel
BuildRequires: boost-devel
--enable-ixfrdist
%else
--disable-lua-records \
- --without-protobuf \
--with-boost=/usr/include/boost148/ LDFLAGS=-L/usr/lib64/boost148 \
CXXFLAGS=-std=gnu++11 \
CPPFLAGS="${CPPFLAGS} -D__STDC_FORMAT_MACROS"
%{_mandir}/man1/sdig.1.gz
%{_bindir}/dnsbulktest
%{_bindir}/dnspcap2calidns
+%{_bindir}/dnspcap2protobuf
%{_bindir}/dnstcpbench
%{_mandir}/man1/dnsbulktest.1.gz
%{_mandir}/man1/dnspcap2calidns.1.gz
-%{_mandir}/man1/dnstcpbench.1.gz
-%if 0%{?rhel} >= 7
-%{_bindir}/dnspcap2protobuf
%{_mandir}/man1/dnspcap2protobuf.1.gz
-%endif
+%{_mandir}/man1/dnstcpbench.1.gz
%files backend-mysql
%doc modules/gmysqlbackend/schema.mysql.sql
PDNS_ENABLE_TOOLS
PDNS_ENABLE_IXFRDIST
-PDNS_WITH_PROTOBUF
-
PDNS_WITH_LUA_RECORDS
AM_CONDITIONAL([LDAP], [test "x$needldap" = "xyes"])
MANPAGES_TARGET_TOOLS = calidns.1 \
dnspcap2calidns.1 \
+ dnspcap2protobuf.1 \
dnsgram.1 \
dnsreplay.1 \
dnsscan.1 \
MANPAGES_DIST += $(MANPAGES_TARGET_TOOLS) \
$(MANPAGES_TARGET_IXFRDIST) \
dnsbulktest.1 \
- dnstcpbench.1 \
- dnspcap2protobuf.1
+ dnstcpbench.1
if HAVE_BOOST_GE_148
MANPAGES_INSTALL += dnsbulktest.1 \
dnstcpbench.1
endif
-if HAVE_PROTOBUF
-if HAVE_PROTOC
-MANPAGES_INSTALL += dnspcap2protobuf.1
-endif
-endif
-
if TOOLS
MANPAGES_INSTALL += $(MANPAGES_TARGET_TOOLS)
endif
+++ /dev/null
-AC_DEFUN([PDNS_WITH_PROTOBUF], [
- AC_MSG_CHECKING([if we need to link in protobuf])
- AC_ARG_WITH([protobuf],
- AS_HELP_STRING([--with-protobuf],[enable protobuf support @<:@default=auto@:>@]),
- [with_protobuf=$withval],
- [with_protobuf=auto],
- )
- AC_MSG_RESULT([$with_protobuf])
-
- AS_IF([test "x$with_protobuf" != "xno"], [
- AS_IF([test "x$with_protobuf" = "xyes" -o "x$with_protobuf" = "xauto"], [
- PKG_CHECK_MODULES([PROTOBUF], [protobuf], [ : ], [ : ])
- AC_CHECK_PROG([PROTOC], [protoc], [protoc])
- ])
- ])
- AS_IF([test "x$with_protobuf" = "xyes"], [
- AS_IF([test x"$PROTOBUF_LIBS" = "x"], [
- AC_MSG_ERROR([Protobuf requested but libraries were not found])
- ])
- AS_IF([test x"$PROTOC" = "x"], [
- AC_MSG_ERROR([Protobuf requested but the protobuf compiler was not found])
- ])
- ])
- AM_CONDITIONAL([HAVE_PROTOBUF], [test x"$PROTOBUF_LIBS" != "x"])
- AM_CONDITIONAL([HAVE_PROTOC], [test x"$PROTOC" != "x"])
- AS_IF([test x"$PROTOBUF_LIBS" != "x"], [AC_DEFINE([HAVE_PROTOBUF], [1], [Define if using protobuf.])])
-])
backends/gsql/gsqlbackend.gcda \
backends/gsql/gsqlbackend.gcno \
backends/gsql/gsqlbackend.gcov \
- dnsmessage.pb.cc dnsmessage.pb.h \
pdns.conf-dist \
apidocfiles.h \
api-swagger.yaml \
* `Lua <http://www.lua.org/>`_ 5.1+ or `LuaJit <http://luajit.org/>`_
* `Editline (libedit) <http://thrysoee.dk/editline/>`_
* `libsodium <https://download.libsodium.org/doc/>`_ (optional)
-* `protobuf <https://developers.google.com/protocol-buffers/>`_ (optional)
+* `protobuf <https://developers.google.com/protocol-buffers/>`_ (optional, not needed as of 1.6.0)
* `re2 <https://github.com/google/re2>`_ (optional)
Should :program:`dnsdist` be run on a system with systemd, it is highly recommended to have
+++ /dev/null
-
-#include "gettime.hh"
-#include "dnsparser.hh"
-#include "protobuf.hh"
-#include "dnsparser.hh"
-#include "gettime.hh"
-
-void DNSProtoBufMessage::setType(DNSProtoBufMessageType type)
-{
-#ifdef HAVE_PROTOBUF
- switch(type) {
- case DNSProtoBufMessage::DNSProtoBufMessageType::Query:
- d_message.set_type(PBDNSMessage_Type_DNSQueryType);
- break;
- case DNSProtoBufMessage::DNSProtoBufMessageType::Response:
- d_message.set_type(PBDNSMessage_Type_DNSResponseType);
- break;
- case DNSProtoBufMessage::DNSProtoBufMessageType::OutgoingQuery:
- d_message.set_type(PBDNSMessage_Type_DNSOutgoingQueryType);
- break;
- case DNSProtoBufMessage::DNSProtoBufMessageType::IncomingResponse:
- d_message.set_type(PBDNSMessage_Type_DNSIncomingResponseType);
- break;
- default:
- throw std::runtime_error("Unsupported protobuf type: "+std::to_string(type));
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-DNSProtoBufMessage::DNSProtoBufMessage(DNSProtoBufMessageType type)
-{
- setType(type);
-}
-
-void DNSProtoBufMessage::setQuestion(const DNSName& qname, uint16_t qtype, uint16_t qclass)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSQuestion* question = d_message.mutable_question();
- if (question) {
- if(!qname.empty())
- question->set_qname(qname.toString());
- question->set_qtype(qtype);
- question->set_qclass(qclass);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setBytes(size_t bytes)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_inbytes(bytes);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setResponseCode(uint8_t rcode)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- response->set_rcode(rcode);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setNetworkErrorResponseCode()
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- /* special code meaning 'network error', like a timeout */
- response->set_rcode(65536);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setTime(time_t sec, uint32_t usec)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_timesec(sec);
- d_message.set_timeusec(usec);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setQueryTime(time_t sec, uint32_t usec)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- response->set_querytimesec(sec);
- response->set_querytimeusec(usec);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setEDNSSubnet(const Netmask& subnet, uint8_t mask)
-{
-#ifdef HAVE_PROTOBUF
- if (!subnet.empty()) {
- ComboAddress ca(subnet.getNetwork());
- ca.truncate(mask);
- if (ca.sin4.sin_family == AF_INET) {
- d_message.set_originalrequestorsubnet(&ca.sin4.sin_addr.s_addr, sizeof(ca.sin4.sin_addr.s_addr));
- }
- else if (ca.sin4.sin_family == AF_INET6) {
- d_message.set_originalrequestorsubnet(&ca.sin6.sin6_addr.s6_addr, sizeof(ca.sin6.sin6_addr.s6_addr));
- }
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::addTag(const std::string& strValue)
-{
-#ifdef HAVE_PROTOBUF
-
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (!response)
- return;
-
- response->add_tags(strValue);
-
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::addRR(const DNSName& qname, uint16_t uType, uint16_t uClass, uint32_t uTTL, const std::string& strBlob)
-{
-#ifdef HAVE_PROTOBUF
-
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (!response)
- return;
- PBDNSMessage_DNSResponse_DNSRR* rr = response->add_rrs();
- if (rr) {
- rr->set_name(qname.toString());
- rr->set_type(uType);
- rr->set_class_(uClass);
- rr->set_ttl(uTTL);
- rr->set_rdata(strBlob.c_str(), strBlob.size());
- }
-
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::addRRsFromPacket(const char* packet, const size_t len, bool includeCNAME)
-{
-#ifdef HAVE_PROTOBUF
- if (len < sizeof(struct dnsheader))
- return;
-
- const struct dnsheader* dh = (const struct dnsheader*) packet;
-
- if (ntohs(dh->ancount) == 0)
- return;
-
- if (ntohs(dh->qdcount) == 0)
- return;
-
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (!response)
- return;
-
- std::string packetStr(packet, len);
- PacketReader pr(packetStr);
-
- size_t idx = 0;
- DNSName rrname;
- uint16_t qdcount = ntohs(dh->qdcount);
- uint16_t ancount = ntohs(dh->ancount);
- uint16_t rrtype;
- uint16_t rrclass;
- string blob;
- struct dnsrecordheader ah;
-
- rrname = pr.getName();
- rrtype = pr.get16BitInt();
- rrclass = pr.get16BitInt();
-
- /* consume remaining qd if any */
- if (qdcount > 1) {
- for(idx = 1; idx < qdcount; idx++) {
- rrname = pr.getName();
- rrtype = pr.get16BitInt();
- rrclass = pr.get16BitInt();
- (void) rrtype;
- (void) rrclass;
- }
- }
-
- /* parse AN */
- for (idx = 0; idx < ancount; idx++) {
- rrname = pr.getName();
- pr.getDnsrecordheader(ah);
-
- if (ah.d_type == QType::A || ah.d_type == QType::AAAA) {
- pr.xfrBlob(blob);
-
- PBDNSMessage_DNSResponse_DNSRR* rr = response->add_rrs();
- if (rr) {
- rr->set_name(rrname.toString());
- rr->set_type(ah.d_type);
- rr->set_class_(ah.d_class);
- rr->set_ttl(ah.d_ttl);
- rr->set_rdata(blob.c_str(), blob.length());
- }
- } else if (ah.d_type == QType::CNAME && includeCNAME) {
- PBDNSMessage_DNSResponse_DNSRR* rr = response->add_rrs();
- if (rr) {
- rr->set_name(rrname.toString());
- rr->set_type(ah.d_type);
- rr->set_class_(ah.d_class);
- rr->set_ttl(ah.d_ttl);
- DNSName target;
- pr.xfrName(target, true);
- rr->set_rdata(target.toString());
- }
- }
- else {
- pr.xfrBlob(blob);
- }
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setRequestor(const std::string& requestor)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_from(requestor);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setRequestor(const ComboAddress& requestor)
-{
-#ifdef HAVE_PROTOBUF
- if (requestor.sin4.sin_family == AF_INET) {
- d_message.set_from(&requestor.sin4.sin_addr.s_addr, sizeof(requestor.sin4.sin_addr.s_addr));
- }
- else if (requestor.sin4.sin_family == AF_INET6) {
- d_message.set_from(&requestor.sin6.sin6_addr.s6_addr, sizeof(requestor.sin6.sin6_addr.s6_addr));
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setRequestorPort(uint16_t port)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_fromport(port);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setRequestorId(const std::string& requestorId)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_requestorid(requestorId);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setDeviceId(const std::string& deviceId)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_deviceid(deviceId);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setDeviceName(const std::string& deviceName)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_devicename(deviceName);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setServerIdentity(const std::string& serverId)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_serveridentity(serverId);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setResponder(const std::string& responder)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_to(responder);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setResponder(const ComboAddress& responder)
-{
-#ifdef HAVE_PROTOBUF
- if (responder.sin4.sin_family == AF_INET) {
- d_message.set_to(&responder.sin4.sin_addr.s_addr, sizeof(responder.sin4.sin_addr.s_addr));
- }
- else if (responder.sin4.sin_family == AF_INET6) {
- d_message.set_to(&responder.sin6.sin6_addr.s6_addr, sizeof(responder.sin6.sin6_addr.s6_addr));
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::setResponderPort(uint16_t port)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_toport(port);
-#endif /* HAVE_PROTOBUF */
-}
-
-void DNSProtoBufMessage::serialize(std::string& data) const
-{
-#ifdef HAVE_PROTOBUF
- d_message.SerializeToString(&data);
-#endif /* HAVE_PROTOBUF */
-}
-
-std::string DNSProtoBufMessage::toDebugString() const
-{
-#ifdef HAVE_PROTOBUF
- return d_message.DebugString();
-#else
- return std::string();
-#endif /* HAVE_PROTOBUF */
-}
-
-#ifdef HAVE_PROTOBUF
-
-void DNSProtoBufMessage::setUUID(const boost::uuids::uuid& uuid)
-{
- std::string* messageId = d_message.mutable_messageid();
- messageId->resize(uuid.size());
- std::copy(uuid.begin(), uuid.end(), messageId->begin());
-}
-
-void DNSProtoBufMessage::setInitialRequestID(const boost::uuids::uuid& uuid)
-{
- std::string* messageId = d_message.mutable_initialrequestid();
- messageId->resize(uuid.size());
- std::copy(uuid.begin(), uuid.end(), messageId->begin());
-}
-
-void DNSProtoBufMessage::updateTime()
-{
- struct timespec ts;
- gettime(&ts, true);
- setTime(ts.tv_sec, ts.tv_nsec / 1000);
-}
-
-void DNSProtoBufMessage::update(const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, uint16_t id)
-{
- updateTime();
- setUUID(uuid);
- d_message.set_id(ntohs(id));
-
- if (requestor) {
- d_message.set_socketfamily(requestor->sin4.sin_family == AF_INET ? PBDNSMessage_SocketFamily_INET : PBDNSMessage_SocketFamily_INET6);
- }
- else if (responder) {
- d_message.set_socketfamily(responder->sin4.sin_family == AF_INET ? PBDNSMessage_SocketFamily_INET : PBDNSMessage_SocketFamily_INET6);
- }
-
- d_message.set_socketprotocol(isTCP ? PBDNSMessage_SocketProtocol_TCP : PBDNSMessage_SocketProtocol_UDP);
-
- if (responder) {
- setResponder(*responder);
- setResponderPort(responder->getPort());
- }
- if (requestor) {
- setRequestor(*requestor);
- setRequestorPort(requestor->getPort());
- }
-}
-
-
-DNSProtoBufMessage::DNSProtoBufMessage(DNSProtoBufMessageType type, const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, const DNSName& domain, int qtype, uint16_t qclass, uint16_t qid, bool isTCP, size_t bytes)
-{
- update(uuid, requestor, responder, isTCP, qid);
-
- setType(type);
-
- setBytes(bytes);
- setQuestion(domain, qtype, qclass);
-}
-
-void DNSProtoBufMessage::copyFrom(const DNSProtoBufMessage& msg)
-{
- d_message.CopyFrom(msg.d_message);
-}
-
-#endif /* HAVE_PROTOBUF */
+++ /dev/null
-/*
- * This file is part of PowerDNS or dnsdist.
- * Copyright -- PowerDNS.COM B.V. and its contributors
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * In addition, for the avoidance of any doubt, permission is granted to
- * link this program with OpenSSL and to (re)distribute the binaries
- * produced as the result of such linking.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#pragma once
-
-#include <cstddef>
-#include <string>
-
-#include "config.h"
-
-#include "dnsname.hh"
-#include "iputils.hh"
-
-#ifdef HAVE_PROTOBUF
-#include <boost/uuid/uuid.hpp>
-#include "dnsmessage.pb.h"
-#endif /* HAVE_PROTOBUF */
-
-class DNSProtoBufMessage
-{
-public:
- enum DNSProtoBufMessageType {
- Query,
- Response,
- OutgoingQuery,
- IncomingResponse
- };
-
- DNSProtoBufMessage()
- {
- }
-
- DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type);
-
- ~DNSProtoBufMessage()
- {
- }
-
- void setType(DNSProtoBufMessage::DNSProtoBufMessageType type);
- void setQuestion(const DNSName& qname, uint16_t qtype, uint16_t qclass);
- void setEDNSSubnet(const Netmask& subnet, uint8_t mask=128);
- void setBytes(size_t bytes);
- void setTime(time_t sec, uint32_t usec);
- void updateTime();
- void setQueryTime(time_t sec, uint32_t usec);
- void setResponseCode(uint8_t rcode);
- void setNetworkErrorResponseCode();
- void addRRsFromPacket(const char* packet, const size_t len, bool includeCNAME=false);
- void serialize(std::string& data) const;
- void setRequestor(const std::string& requestor);
- void setRequestor(const ComboAddress& requestor);
- void setRequestorPort(uint16_t port);
- void setResponder(const std::string& responder);
- void setResponder(const ComboAddress& responder);
- void setResponderPort(uint16_t port);
- void setRequestorId(const std::string& requestorId);
- void setDeviceId(const std::string& deviceId);
- void setDeviceName(const std::string& deviceName);
- void setServerIdentity(const std::string& serverId);
- std::string toDebugString() const;
- void addTag(const std::string& strValue);
- void addRR(const DNSName& qame, uint16_t utype, uint16_t uClass, uint32_t uTTl, const std::string& strBlob);
-
-#ifdef HAVE_PROTOBUF
- DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type, const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, const DNSName& domain, int qtype, uint16_t qclass, uint16_t qid, bool isTCP, size_t bytes);
- void update(const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, uint16_t id);
- void setUUID(const boost::uuids::uuid& uuid);
- void setInitialRequestID(const boost::uuids::uuid& uuid);
- void copyFrom(const DNSProtoBufMessage& msg);
-
-protected:
- PBDNSMessage d_message;
-#endif /* HAVE_PROTOBUF */
-};
+++ /dev/null
-
-#include "config.h"
-#include "rec-protobuf.hh"
-
-#ifdef NOD_ENABLED
-void RecProtoBufMessage::setNOD(bool nod)
-{
-#ifdef HAVE_PROTOBUF
- d_message.set_newlyobserveddomain(nod);
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::clearUDR()
-{
-#ifdef HAVE_PROTOBUF
- auto response = d_message.mutable_response();
- if (!response) {
- return;
- }
- const int count = response->rrs_size();
- for (int idx = 0; idx < count; idx++) {
- auto rr = response->mutable_rrs(idx);
- rr->set_udr(false);
- }
-#endif /* HAVE_PROTOBUF */
-}
-#endif /* NOD_ENABLED */
-
-#ifdef NOD_ENABLED
-void RecProtoBufMessage::addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes, bool udr)
-#else
-void RecProtoBufMessage::addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes)
-#endif /* NOD_ENABLED */
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (!response) {
- return;
- }
-
- if (record.d_place != DNSResourceRecord::ANSWER || record.d_class != QClass::IN) {
- return;
- }
-
- if (exportTypes.count(record.d_type) == 0) {
- return;
- }
-
- PBDNSMessage_DNSResponse_DNSRR* pbRR = response->add_rrs();
- if (!pbRR) {
- return;
- }
-
- pbRR->set_name(record.d_name.toString());
- pbRR->set_type(record.d_type);
- pbRR->set_class_(record.d_class);
- pbRR->set_ttl(record.d_ttl);
-#ifdef NOD_ENABLED
- pbRR->set_udr(udr);
-#endif
-
- switch(record.d_type) {
- case QType::A:
- {
- const auto& content = dynamic_cast<const ARecordContent&>(*(record.d_content));
- ComboAddress data = content.getCA();
- pbRR->set_rdata(&data.sin4.sin_addr.s_addr, sizeof(data.sin4.sin_addr.s_addr));
- break;
- }
- case QType::AAAA:
- {
- const auto& content = dynamic_cast<const AAAARecordContent&>(*(record.d_content));
- ComboAddress data = content.getCA();
- pbRR->set_rdata(&data.sin6.sin6_addr.s6_addr, sizeof(data.sin6.sin6_addr.s6_addr));
- break;
- }
- case QType::CNAME:
- {
- const auto& content = dynamic_cast<const CNAMERecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.getTarget().toString());
- break;
- }
- case QType::TXT:
- {
- const auto& content = dynamic_cast<const TXTRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.d_text);
- break;
- }
- case QType::NS:
- {
- const auto& content = dynamic_cast<const NSRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.getNS().toString());
- break;
- }
- case QType::PTR:
- {
- const auto& content = dynamic_cast<const PTRRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.getContent().toString());
- break;
- }
- case QType::MX:
- {
- const auto& content = dynamic_cast<const MXRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.d_mxname.toString());
- break;
- }
- case QType::SPF:
- {
- const auto& content = dynamic_cast<const SPFRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.getText());
- break;
- }
- case QType::SRV:
- {
- const auto& content = dynamic_cast<const SRVRecordContent&>(*(record.d_content));
- pbRR->set_rdata(content.d_target.toString());
- break;
- }
- default:
- break;
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::addRRs(const std::vector<DNSRecord>& records, const std::set<uint16_t>& exportTypes)
-{
- for (const auto& record : records) {
- addRR(record, exportTypes);
- }
-}
-
-void RecProtoBufMessage::setAppliedPolicy(const std::string& policy)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response && !policy.empty()) {
- response->set_appliedpolicy(policy);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::setAppliedPolicyType(const DNSFilterEngine::PolicyType& type)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- switch(type) {
- case DNSFilterEngine::PolicyType::None:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_UNKNOWN);
- break;
- case DNSFilterEngine::PolicyType::QName:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_QNAME);
- break;
- case DNSFilterEngine::PolicyType::ClientIP:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_CLIENTIP);
- break;
- case DNSFilterEngine::PolicyType::ResponseIP:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_RESPONSEIP);
- break;
- case DNSFilterEngine::PolicyType::NSDName:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_NSDNAME);
- break;
- case DNSFilterEngine::PolicyType::NSIP:
- response->set_appliedpolicytype(PBDNSMessage_PolicyType_NSIP);
- break;
- default:
- throw std::runtime_error("Unsupported protobuf policy type");
- }
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::setAppliedPolicyTrigger(const DNSName& trigger)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response && !trigger.empty()) {
- response->set_appliedpolicytrigger(trigger.toString());
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::setAppliedPolicyHit(const string& hit)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response && !hit.empty()) {
- response->set_appliedpolicyhit(hit);
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::setPolicyTags(const std::unordered_set<std::string>& policyTags)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- for (const auto& tag : policyTags) {
- response->add_tags(tag);
- }
- }
-#endif /* HAVE_PROTOBUF */
-}
-
-void RecProtoBufMessage::addPolicyTag(const std::string& policyTag)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- response->add_tags(policyTag);
- }
-#endif
-}
-
-void RecProtoBufMessage::removePolicyTag(const std::string& policyTag)
-{
-#ifdef HAVE_PROTOBUF
- PBDNSMessage_DNSResponse* response = d_message.mutable_response();
- if (response) {
- const int count = response->tags_size();
- int keep = 0;
- for (int idx = 0; idx < count; ++idx) {
- auto tagp = response->mutable_tags(idx);
- if (tagp->compare(policyTag) == 0) {
- }
- else {
- if (keep < idx) {
- response->mutable_tags()->SwapElements(idx, keep);
- }
- ++keep;
- }
- }
- response->mutable_tags()->DeleteSubrange(keep, count - keep);
- }
-#endif
-}
-
-std::string RecProtoBufMessage::getAppliedPolicy() const
-{
- std::string result;
-#ifdef HAVE_PROTOBUF
- const PBDNSMessage_DNSResponse& response = d_message.response();
- result = response.appliedpolicy();
-#endif /* HAVE_PROTOBUF */
- return result;
-}
-
-std::vector<std::string> RecProtoBufMessage::getPolicyTags() const
-{
- std::vector<std::string> result;
-#ifdef HAVE_PROTOBUF
- const PBDNSMessage_DNSResponse& response = d_message.response();
- const int count = response.tags_size();
- for (int idx = 0; idx < count; idx++) {
- result.push_back(response.tags(idx));
- }
-#endif /* HAVE_PROTOBUF */
- return result;
-}
+++ /dev/null
-/*
- * This file is part of PowerDNS or dnsdist.
- * Copyright -- PowerDNS.COM B.V. and its contributors
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * In addition, for the avoidance of any doubt, permission is granted to
- * link this program with OpenSSL and to (re)distribute the binaries
- * produced as the result of such linking.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-#pragma once
-
-#include "protobuf.hh"
-#include "filterpo.hh"
-#include "dnsrecords.hh"
-
-class RecProtoBufMessage: public DNSProtoBufMessage
-{
-public:
- RecProtoBufMessage(): DNSProtoBufMessage()
- {
- }
-
- RecProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type): DNSProtoBufMessage(type)
- {
- }
-
-#ifdef HAVE_PROTOBUF
- RecProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type, const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, const DNSName& domain, int qtype, uint16_t qclass, uint16_t qid, bool isTCP, size_t bytes): DNSProtoBufMessage(type, uuid, requestor, responder, domain, qtype, qclass, qid, isTCP, bytes)
- {
- }
-#endif /* HAVE_PROTOBUF */
-
- void addRRs(const std::vector<DNSRecord>& records, const std::set<uint16_t>& exportTypes);
-#ifdef NOD_ENABLED
- void setNOD(bool nod);
- void addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes, bool udr=false);
- void clearUDR();
-#else
- void addRR(const DNSRecord& record, const std::set<uint16_t>& exportTypes);
-#endif /* NOD_ENABLED */
- void setAppliedPolicy(const std::string& policy);
- void setAppliedPolicyType(const DNSFilterEngine::PolicyType& policyType);
- void setAppliedPolicyTrigger(const DNSName& trigger);
- void setAppliedPolicyHit(const string& hit);
- void setPolicyTags(const std::unordered_set<std::string>& policyTags);
- void addPolicyTag(const std::string& policyTag);
- void removePolicyTag(const std::string& policyTag);
- std::string getAppliedPolicy() const;
- std::vector<std::string> getPolicyTags() const;
-};
dnslabeltext.cc
CLEANFILES = htmlfiles.h \
- dnsmessage.pb.cc \
- dnsmessage.pb.h \
recursor.conf-dist
htmlfiles.h: html/*
^^^^^^^^^^^^^^^^^^^^^^^^^
The PowerDNS Recursor can log DNS query information over :doc:`Protocol Buffers <../lua-config/protobuf>`.
-To enable this functionality, install the `protobuf <https://developers.google.com/protocol-buffers/>`_ library and compiler.
-The configure script will automatically detect this and bump the Boost version dependency to 1.42.
-To disable building this functionality, use ``--without-protobuf``.
+This functionality from 4.5.0 and upwards, without needing any external library. Before 4.5.0, installing the `protobuf <https://developers.google.com/protocol-buffers/>`_ library and compiler is required to enable this functionality. The configure script will automatically detect this and bump the Boost version dependency to 1.42. To disable building this functionality before 4.5.0, use ``--without-protobuf``.
systemd notify support
^^^^^^^^^^^^^^^^^^^^^^
+++ /dev/null
-../protobuf.cc
\ No newline at end of file
+++ /dev/null
-../protobuf.hh
\ No newline at end of file
+++ /dev/null
-../rec-protobuf.cc
\ No newline at end of file
+++ /dev/null
-../rec-protobuf.hh
\ No newline at end of file