From: Otto Moerbeek Date: Wed, 25 Mar 2026 08:52:12 +0000 (+0100) Subject: rec docs: describe followCNAMERecords better X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56900fc7c9fecbbdbff5d320d55edfeb6b304b69;p=thirdparty%2Fpdns.git rec docs: describe followCNAMERecords better While working on this, I noted it is underspecified *which* CNAME record is followed, but that is for some other time. Fixes #17030 Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/docs/lua-scripting/hooks.rst b/pdns/recursordist/docs/lua-scripting/hooks.rst index 953e609c6e..0b078afa72 100644 --- a/pdns/recursordist/docs/lua-scripting/hooks.rst +++ b/pdns/recursordist/docs/lua-scripting/hooks.rst @@ -302,16 +302,16 @@ dq.followupPrefix to the same prefix as used with Follow up actions ----------------- -When modifying queries, it might be needed that the Recursor does some extra work after the function returns. +When modifying queries, it might be needed that the :program:`Recursor` does some extra work after the function returns. The :attr:`dq.followupFunction ` can be set in this case. .. _cnamechainresolution: CNAME chain resolution ^^^^^^^^^^^^^^^^^^^^^^ -It may be useful to return a CNAME record for Lua, and then have the PowerDNS Recursor continue resolving that CNAME. -This can be achieved by setting dq.followupFunction to ``followCNAMERecords`` and dq.followupDomain to "www.powerdns.com". -PowerDNS will do the rest. +It may be useful to return a ``CNAME`` record for Lua, and then have :program:`Recursor` continue resolving that ``CNAME``. +This can be achieved by adding or setting a ``CNAME`` record and setting :attr:`dq.followupFunction ` to ``"followCNAMERecords"``. +:program:`Recursor` will inspect the current records and resolve the ``CNAME`` found. .. _udpqueryresponse: diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index e9618b99f6..b1c2b39217 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -702,6 +702,9 @@ int followCNAMERecords(vector& ret, const QType qtype, int rcode) { vector resolved; DNSName target; + // Docs do not specify *which* CNAME is picked. We take the first + // and do not mind the section. Maybe the last in the answer section + // would be what users expect? for (const DNSRecord& record : ret) { if (record.d_type == QType::CNAME) { auto rec = getRR(record);