From: Fred Morcos Date: Tue, 31 May 2022 11:34:10 +0000 (+0200) Subject: Implement toString() for SyncRes::AuthDomain X-Git-Tag: auth-4.8.0-alpha0~63^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=08326ab943fe3d6eae2945fa814e4ba10faa9f0d;p=thirdparty%2Fpdns.git Implement toString() for SyncRes::AuthDomain --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 3e04d88d7d..dd8d494c92 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -868,6 +868,30 @@ bool SyncRes::AuthDomain::operator==(const AuthDomain& rhs) const && d_rdForward == rhs.d_rdForward; } +[[nodiscard]] std::string SyncRes::AuthDomain::print(const std::string& indent, + const std::string& indentLevel) const +{ + std::stringstream s; + s << indent << "DNSName = " << d_name << std::endl; + s << indent << "rdForward = " << d_rdForward << std::endl; + s << indent << "Records {" << std::endl; + auto recordContentIndentation = indent; + recordContentIndentation += indentLevel; + recordContentIndentation += indentLevel; + for (const auto& record : d_records) { + s << indent << indentLevel << "Record `" << record.d_name << "` {" << std::endl; + s << record.print(recordContentIndentation); + s << indent << indentLevel << "}" << std::endl; + } + s << indent << "}" << std::endl; + s << indent << "Servers {" << std::endl; + for (const auto& server : d_servers) { + s << indent << indentLevel << server.toString() << std::endl; + } + s << indent << "}" << std::endl; + return s.str(); +} + int SyncRes::AuthDomain::getRecords(const DNSName& qname, const QType qtype, std::vector& records) const { int result = RCode::NoError; diff --git a/pdns/syncres.hh b/pdns/syncres.hh index d8dbe22a82..2210560792 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -116,6 +116,10 @@ public: bool operator==(const AuthDomain& rhs) const; + [[nodiscard]] + std::string print(const std::string& indent = "", + const std::string& indentLevel = " ") const; + int getRecords(const DNSName& qname, QType qtype, std::vector& records) const; bool isAuth() const {