From: Otto Moerbeek Date: Mon, 17 Jul 2023 14:27:04 +0000 (+0200) Subject: rec: set TTL in getFakePTRRecords X-Git-Tag: rec-5.0.0-alpha1~95^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71996c157fab7066d58008d8d1df5ae1b1149d54;p=thirdparty%2Fpdns.git rec: set TTL in getFakePTRRecords Alternative solution to #13011 --- diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 927cf06dd8..e0f78da2e3 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -768,14 +768,19 @@ int getFakePTRRecords(const DNSName& qname, vector& ret) } newquery += "in-addr.arpa."; + auto log = g_slog->withName("dns64")->withValues("method", Logging::Loggable("getPTR")); + vector answers; + int rcode = directResolve(DNSName(newquery), QType::PTR, QClass::IN, answers, t_pdl, log); + DNSRecord record; record.d_name = qname; record.d_type = QType::CNAME; record.setContent(std::make_shared(newquery)); + // Copy the TTL of the synhtesized CNAME from the actual answer + record.d_ttl = (rcode == RCode::NoError && !answers.empty()) ? answers.at(0).d_ttl : SyncRes::s_minimumTTL; ret.push_back(record); - auto log = g_slog->withName("dns64")->withValues("method", Logging::Loggable("getPTR")); - int rcode = directResolve(DNSName(newquery), QType::PTR, QClass::IN, ret, t_pdl, log); + ret.insert(ret.end(), answers.begin(), answers.end()); t_Counters.at(rec::Counter::dns64prefixanswers)++; return rcode;