Browse Source

use a per-query-context vector of current NS addrs
instead of misusing the upstream_ value that contains servers for forwarding, create an vector that has the 'current' list of NS addresses (workaround until we hook in NSAS)

Jelte Jansen 14 years ago
parent
commit
1efc3bee0b
1 changed files with 21 additions and 13 deletions
  1. 21 13
      src/lib/asiolink/asiolink.cc

+ 21 - 13
src/lib/asiolink/asiolink.cc

@@ -326,19 +326,21 @@ private:
     // if we change this to running and add a sent, we can do
     // if we change this to running and add a sent, we can do
     // decoupled timeouts i think
     // decoupled timeouts i think
     bool done;
     bool done;
-    
 
 
+    // Not using NSAS at this moment, so we keep a list
+    // of 'current' zone servers
+    vector<addr_t> zone_servers_;
 
 
     // (re)send the query to the server.
     // (re)send the query to the server.
     void send() {
     void send() {
-        const int uc = upstream_->size();
+        const int uc = zone_servers_.size();
         if (uc > 0) {
         if (uc > 0) {
             int serverIndex = rand() % uc;
             int serverIndex = rand() % uc;
             dlog("Sending upstream query (" + question_.toText() +
             dlog("Sending upstream query (" + question_.toText() +
-                ") to " + upstream_->at(serverIndex).first);
+                ") to " + zone_servers_.at(serverIndex).first);
             UDPQuery query(io_, question_,
             UDPQuery query(io_, question_,
-                upstream_->at(serverIndex).first,
-                upstream_->at(serverIndex).second, buffer_, this,
+                zone_servers_.at(serverIndex).first,
+                zone_servers_.at(serverIndex).second, buffer_, this,
                 timeout_);
                 timeout_);
             io_.post(query);
             io_.post(query);
         } else {
         } else {
@@ -356,10 +358,15 @@ public:
         buffer_(buffer),
         buffer_(buffer),
         server_(server->clone()),
         server_(server->clone()),
         timeout_(timeout),
         timeout_(timeout),
-        retries_(retries)
+        retries_(retries),
+        zone_servers_()
     {
     {
         dlog("[XX] Started a new RunningQuery");
         dlog("[XX] Started a new RunningQuery");
         done = false;
         done = false;
+
+        dlog("[XX] zone_servers size: " + zone_servers_.size());
+        // hardcoded f.root-servers.net now, should use NSAS
+        zone_servers_.push_back(addr_t("192.5.5.241", 53));
         send();
         send();
     }
     }
 
 
@@ -377,7 +384,7 @@ public:
             Message incoming(Message::PARSE);
             Message incoming(Message::PARSE);
             InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
             InputBuffer ibuf(buffer_->getData(), buffer_->getLength());
             incoming.fromWire(ibuf);
             incoming.fromWire(ibuf);
-            std::cout << "[XX] i received answer: " << incoming.toText() << std::endl;
+            std::cout << "[XX] received answer: " << incoming.toText() << std::endl;
             //
             //
 
 
             if (incoming.getRcode() == Rcode::NOERROR()) {
             if (incoming.getRcode() == Rcode::NOERROR()) {
@@ -395,11 +402,11 @@ public:
                     // address in additional and just use that
                     // address in additional and just use that
     
     
                     // send query to the addresses in the delegation
                     // send query to the addresses in the delegation
-                    bool found_address = false;
-                    upstream_->clear();
+                    bool found_ns_address = false;
+                    zone_servers_.clear();
 
 
                     for (RRsetIterator rrsi = incoming.beginSection(Message::SECTION_ADDITIONAL);
                     for (RRsetIterator rrsi = incoming.beginSection(Message::SECTION_ADDITIONAL);
-                         rrsi != incoming.endSection(Message::SECTION_ADDITIONAL) && !found_address;
+                         rrsi != incoming.endSection(Message::SECTION_ADDITIONAL) && !found_ns_address;
                          rrsi++) {
                          rrsi++) {
                         ConstRRsetPtr rrs = *rrsi;
                         ConstRRsetPtr rrs = *rrsi;
                         if (rrs->getType() == RRType::A()) {
                         if (rrs->getType() == RRType::A()) {
@@ -414,12 +421,13 @@ public:
                                 // to that address and yield, when it
                                 // to that address and yield, when it
                                 // returns, loop again.
                                 // returns, loop again.
                                 
                                 
-                                upstream_->push_back(addr_t(addr_str, 53));
-                                found_address = true;
+                                // should use NSAS
+                                zone_servers_.push_back(addr_t(addr_str, 53));
+                                found_ns_address = true;
                             }
                             }
                         }
                         }
                     }
                     }
-                    if (found_address) {
+                    if (found_ns_address) {
                         // next resolver round
                         // next resolver round
                         buffer_->clear();
                         buffer_->clear();
                         send();
                         send();