]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Implement toString() for SyncRes::AuthDomain
authorFred Morcos <fred.morcos@open-xchange.com>
Tue, 31 May 2022 11:34:10 +0000 (13:34 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Mon, 13 Jun 2022 12:24:23 +0000 (14:24 +0200)
pdns/syncres.cc
pdns/syncres.hh

index 3e04d88d7dde30b0be2e0b01862002155deb5976..dd8d494c92b067f16baabbe7128acb047d7d1586 100644 (file)
@@ -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<DNSRecord>& records) const
 {
   int result = RCode::NoError;
index d8dbe22a82e08883392fa1d0c64fa174e95816d9..2210560792c2641e2a17ed11ceb351d3906d451e 100644 (file)
@@ -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<DNSRecord>& records) const;
     bool isAuth() const
     {