From c5545a127dfb869169143cee052d5fa475b82c7f Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 25 Apr 2024 15:24:15 +0200 Subject: [PATCH] rec: add a HTTPS, SVCB and NAPTR record types to be exportable via protobuf --- contrib/ProtobufLogger.py | 4 ++-- .../recursordist/docs/lua-config/protobuf.rst | 12 ++++++++-- pdns/recursordist/rec-protozero.cc | 24 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/contrib/ProtobufLogger.py b/contrib/ProtobufLogger.py index dbba1822c8..b4dc9f3d8d 100644 --- a/contrib/ProtobufLogger.py +++ b/contrib/ProtobufLogger.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 import binascii import datetime @@ -175,7 +175,7 @@ class PDNSPBConnHandler(object): if (rrclass == 1 or rrclass == 255) and rr.HasField('rdata'): if rrtype == 1: rdatastr = socket.inet_ntop(socket.AF_INET, rr.rdata) - elif rrtype == 5: + elif rrtype in (5, 35, 64, 65): rdatastr = rr.rdata elif rrtype == 28: rdatastr = socket.inet_ntop(socket.AF_INET6, rr.rdata) diff --git a/pdns/recursordist/docs/lua-config/protobuf.rst b/pdns/recursordist/docs/lua-config/protobuf.rst index 82804f0ae2..752e4ab7a7 100644 --- a/pdns/recursordist/docs/lua-config/protobuf.rst +++ b/pdns/recursordist/docs/lua-config/protobuf.rst @@ -31,7 +31,7 @@ Protobuf export to a server is enabled using the ``protobufServer()`` directive: * ``asyncConnect``: bool - When set to false (default) the first connection to the server during startup will block up to ``timeout`` seconds, otherwise the connection is done in a separate thread, after the first message has been queued * ``logQueries=true``: bool - Whether to export queries * ``logResponses=true``: bool - Whether to export responses - * ``exportTypes={'A', 'AAAA', 'CNAME'}``: list of strings - The list of record types found in the answer section to export. Only A, AAAA, CNAME, MX, NS, PTR, SPF, SRV and TXT are currently supported + * ``exportTypes={'A', 'AAAA', 'CNAME'}``: list of strings - The list of record types found in the answer section to export. Record types A, AAAA, CNAME, MX, NS, PTR, SPF, SRV and TXT are supported. .. versionchanged:: 4.7.0 @@ -41,6 +41,10 @@ Protobuf export to a server is enabled using the ``protobufServer()`` directive: * ``logMappedFrom=false``: bool - whether to log the remote address before substitution by :ref:`proxymapping` (the default) or after + .. versionchanged:: 5.1.0 + + Added support for the HTTPS, SVCB and APTR record types. + .. function:: protobufServer(server [[[[[[[, timeout=2], maxQueuedEntries=100], reconnectWaitTime=1], maskV4=32], maskV6=128], asyncConnect=false], taggedOnly=false]) .. deprecated:: 4.2.0 @@ -85,12 +89,16 @@ While :func:`protobufServer` only exports the queries sent to the recursor from * ``asyncConnect``: bool - When set to false (default) the first connection to the server during startup will block up to ``timeout`` seconds, otherwise the connection is done in a separate thread, after the first message has been queued * ``logQueries=true``: bool - Whether to export queries * ``logResponses=true``: bool - Whether to export responses - * ``exportTypes={'A', 'AAAA', 'CNAME'}``: list of strings or qtypes - The list of record types found in the answer section to export. Only A, AAAA, CNAME, MX, NS, PTR, SPF, SRV and TXT are currently supported + * ``exportTypes={'A', 'AAAA', 'CNAME'}``: list of strings or qtypes - The list of record types found in the answer section to export. Record types A, AAAA, CNAME, MX, NS, PTR, SPF, SRV and TXT are supported .. versionchanged:: 4.7.0 The values in ``exportTypes`` can be numeric as well as strings. Symbolic names from ``pdns`` can be used, e.g. ``exportTypes = { pdns.A, pdns.AAAA, pdns.CNAME }`` + .. versionchanged:: 5.1.0 + + Added support for the HTTPS, SVCB and APTR records types. + .. function:: outgoingProtobufServer(server [[[[, timeout=2], maxQueuedEntries=100], reconnectWaitTime=1], asyncConnect=false]) .. deprecated:: 4.2.0 diff --git a/pdns/recursordist/rec-protozero.cc b/pdns/recursordist/rec-protozero.cc index 957b145779..bcabe26994 100644 --- a/pdns/recursordist/rec-protozero.cc +++ b/pdns/recursordist/rec-protozero.cc @@ -122,6 +122,30 @@ void pdns::ProtoZero::RecMessage::addRR(const DNSRecord& record, const std::set< add(content->d_target.toString()); break; } + case QType::SVCB: { + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getZoneRepresentation()); + break; + } + case QType::HTTPS: { + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getZoneRepresentation()); + break; + } + case QType::NAPTR: { + const auto& content = getRR(record); + if (!content) { + return; + } + add(content->getZoneRepresentation()); + break; + } default: break; } -- 2.47.2