Parcourir la source

chedk RRtype/class in findRRset()
additional clenaup and improvements:
- supported NS for the static names
- use 0 TTL to be compatible with the current behavior


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@714 e5f2f494-b856-4b98-b285-d166d9295462

JINMEI Tatuya il y a 15 ans
Parent
commit
0e91898859
2 fichiers modifiés avec 29 ajouts et 6 suppressions
  1. 27 6
      src/lib/auth/cpp/data_source_static.cc
  2. 2 0
      src/lib/auth/cpp/data_source_static.h

+ 27 - 6
src/lib/auth/cpp/data_source_static.cc

@@ -15,14 +15,13 @@
 namespace isc {
 namespace dns {
 
-using namespace isc::dns;
 using namespace isc::dns::rdata;
 
 StaticDataSrc::StaticDataSrc() : authors_name("authors.bind"),
                                  version_name("version.bind")
 {
     authors = RRsetPtr(new RRset(authors_name, RRClass::CH(),
-                                          RRType::TXT(), RRTTL(3600)));
+                                          RRType::TXT(), RRTTL(0)));
     authors->addRdata(generic::TXT("Evan Hunt"));
     authors->addRdata(generic::TXT("Han Feng"));
     authors->addRdata(generic::TXT("Jelte Jansen"));
@@ -32,12 +31,20 @@ StaticDataSrc::StaticDataSrc() : authors_name("authors.bind"),
     authors->addRdata(generic::TXT("Kazunori Fujiwara"));
     authors->addRdata(generic::TXT("Michael Graff"));
     authors->addRdata(generic::TXT("Naoki Kambe"));
-    authors->addRdata(generic::TXT("Shane Kerr")); 
+    authors->addRdata(generic::TXT("Shane Kerr"));
     authors->addRdata(generic::TXT("Zhang Likun"));
 
+    authors_ns = RRsetPtr(new RRset(authors_name, RRClass::CH(),
+                                    RRType::NS(), RRTTL(0)));
+    authors_ns->addRdata(generic::NS(authors_name));
+
     version = RRsetPtr(new RRset(version_name, RRClass::CH(),
-                                          RRType::TXT(), RRTTL(3600)));
+                                          RRType::TXT(), RRTTL(0)));
     version->addRdata(generic::TXT("BIND10 0.0.0 (pre-alpha)"));
+
+    version_ns = RRsetPtr(new RRset(version_name, RRClass::CH(),
+                                    RRType::NS(), RRTTL(0)));
+    version_ns->addRdata(generic::NS(version_name));
 }
 
 const DataSrc*
@@ -91,13 +98,27 @@ StaticDataSrc::findRRset(const Name& qname,
                          const RRType& qtype,
                          RRsetList& target) const
 {
-    if (qname == version_name) {
+    if (qname == version_name &&
+        qclass == version->getClass() && qtype == version->getType()) {
         target.push_back(version);
         return SUCCESS;
-    } else if (qname == authors_name) {
+    } else if (qname == version_name &&
+               qclass == version_ns->getClass() &&
+               qtype == version_ns->getType()) {
+        target.push_back(version_ns);
+        return SUCCESS;
+    } else if (qname == authors_name &&
+               qclass == authors->getClass() && qtype == authors->getType()) {
         target.push_back(authors);
         return SUCCESS;
+    } else if (qname == authors_name &&
+               qclass == authors_ns->getClass() &&
+               qtype == authors_ns->getType()) {
+        target.push_back(authors_ns);
+        return SUCCESS;
     }
+    // XXX: this is not 100% correct.
+    // We should also support the nodata/noerror case.
     return NAME_NOT_FOUND;
 }
 

+ 2 - 0
src/lib/auth/cpp/data_source_static.h

@@ -56,7 +56,9 @@ private:
     const Name authors_name;
     const Name version_name;
     RRsetPtr authors;
+    RRsetPtr authors_ns;
     RRsetPtr version;
+    RRsetPtr version_ns;
 };
 
 }