[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r1265: If we get a router name or id in a circ event or from getinf (trunk/src/gui/network)



Author: edmanm
Date: 2006-10-03 14:17:15 -0400 (Tue, 03 Oct 2006)
New Revision: 1265

Modified:
   trunk/src/gui/network/netviewer.cpp
   trunk/src/gui/network/netviewer.h
Log:
If we get a router name or id in a circ event or from getinfo circuit-status 
that is not in our network-status (hey, it happens), we need to 
geolocate the server in addition to adding it to our big server list.


Modified: trunk/src/gui/network/netviewer.cpp
===================================================================
--- trunk/src/gui/network/netviewer.cpp	2006-10-03 15:51:35 UTC (rev 1264)
+++ trunk/src/gui/network/netviewer.cpp	2006-10-03 18:17:15 UTC (rev 1265)
@@ -235,27 +235,38 @@
 {
   /* Get descriptors for all the given IDs */
   QList<RouterDescriptor> rds = _torControl->getDescriptorListById(ids);
-  
+   
   foreach (RouterDescriptor rd, rds) {
     /* Load the router descriptor and add it to the router list. */
     if (!rd.isEmpty()) {
-      ui.treeRouterList->addRouter(rd);
-
-      /* Add this IP to a list whose geographic location we'd like to find. */
-      QHostAddress ip(rd.ip());
-      if (!_resolveQueue.contains(ip)) {
-        _resolveQueue << ip;
-      }
-      if (!_resolveMap.values(rd.ip()).contains(rd.id())) {
-        _resolveMap.insertMulti(rd.ip(), rd.id());
-      }
+      addRouter(rd);
     }
   }
+}
 
+/** Adds a router to our list of servers and retrieves geographic location
+ * information for the server. */
+void
+NetViewer::addRouter(RouterDescriptor rd)
+{
+  /* Add the descriptor to the list of server */
+  ui.treeRouterList->addRouter(rd);
+
+  /* Add this IP to a list whose geographic location we'd like to find. */
+  QHostAddress ip(rd.ip());
+  if (!_resolveQueue.contains(ip)) {
+    _resolveQueue << ip;
+  }
+  if (!_resolveMap.values(rd.ip()).contains(rd.id())) {
+    _resolveMap.insertMulti(rd.ip(), rd.id());
+  }
+
   /* If there are any IPs in the list, then start a timer. We delay resolution
    * because it's likely that we'll receive new descriptors shortly, so we
    * might as well lump them into a single request. */
   if (!_resolveQueue.isEmpty()) {
+    /* Wait RESOLVE_QUEUE_DELAY after the <i>last</i> item inserted into the
+     * queue, before sending the resolve request. */
     _resolveQueueTimer.start(RESOLVE_QUEUE_DELAY);
   }
 }
@@ -371,7 +382,7 @@
           rd = _torControl->getDescriptorByName(hop);
           if (!rd.isEmpty()) {
             /* Add this router to the list of those we know about */
-            ui.treeRouterList->addRouter(rd);
+            addRouter(rd);
           }
         }
       } else {
@@ -407,7 +418,7 @@
         rd = _torControl->getDescriptorById(hop);
         if (!rd.isEmpty()) {
           /* This is a fine time to add this new router to our list */
-          ui.treeRouterList->addRouter(rd);
+          addRouter(rd);
         }
       }
       hop = (rd.isEmpty() ? hop : rd.name());

Modified: trunk/src/gui/network/netviewer.h
===================================================================
--- trunk/src/gui/network/netviewer.h	2006-10-03 15:51:35 UTC (rev 1264)
+++ trunk/src/gui/network/netviewer.h	2006-10-03 18:17:15 UTC (rev 1265)
@@ -82,6 +82,9 @@
 private:
   /** Loads a list of router descriptors from the list of IDs. */
   void loadDescriptors(QStringList ids);
+  /** Adds a router to our list of servers and retrieves geographic location
+   * information for the server. */
+  void addRouter(RouterDescriptor rd);
   /** Convert all hops in <b>circ</b>'s path to server identities.
   * <b>circ</b>'s status and circuit ID will be preserved. */
   Circuit circuitPathIDs(Circuit circ);