[tor-commits] [vidalia/master] Use consensus bandwidth when microdescriptors is enabled

chiiph at torproject.org chiiph at torproject.org
Fri Mar 9 18:01:40 UTC 2012


commit 66203b2d4c1a5fba5257605d514fe4db0ac93438
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Fri Mar 9 14:53:57 2012 -0300

    Use consensus bandwidth when microdescriptors is enabled
    
    Conflicts:
    
    	src/vidalia/network/NetViewer.cpp
---
 src/torcontrol/RouterDescriptor.cpp |    3 +++
 src/torcontrol/RouterStatus.cpp     |   13 +++++++++++++
 src/torcontrol/RouterStatus.h       |    3 +++
 src/vidalia/network/NetViewer.cpp   |    3 ++-
 4 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/torcontrol/RouterDescriptor.cpp b/src/torcontrol/RouterDescriptor.cpp
index 3634f3e..21643f2 100644
--- a/src/torcontrol/RouterDescriptor.cpp
+++ b/src/torcontrol/RouterDescriptor.cpp
@@ -106,4 +106,7 @@ RouterDescriptor::appendRouterStatusInfo(const RouterStatus &rs)
   _ip = rs.ipAddress();
   _orPort = rs.orPort();
   _dirPort = rs.dirPort();
+  _avgBandwidth = rs.bandwidth();
+  _burstBandwidth = rs.bandwidth();
+  _observedBandwidth = rs.bandwidth();
 }
diff --git a/src/torcontrol/RouterStatus.cpp b/src/torcontrol/RouterStatus.cpp
index 9ee795b..02f13b5 100644
--- a/src/torcontrol/RouterStatus.cpp
+++ b/src/torcontrol/RouterStatus.cpp
@@ -40,6 +40,8 @@ RouterStatus::RouterStatus(const QStringList &status)
   _valid = false;
   _flags = 0;
 
+  _bandwidth = 0;
+
   foreach (QString line, status) {
     if (line.startsWith("r ")) {
       QStringList parts = line.split(" ", QString::SkipEmptyParts);
@@ -83,6 +85,17 @@ RouterStatus::RouterStatus(const QStringList &status)
       foreach (QString flag, flags) {
         _flags |= flagValue(flag);
       }
+    } else if (line.startsWith("w ")) {
+      /* Status flags */
+      QStringList parts = line.split(" ", QString::SkipEmptyParts);
+      parts.removeFirst(); /* Remove the "w" */
+
+      if(parts.size() > 0) {
+        QStringList bw = parts.at(0).split("=", QString::SkipEmptyParts);
+        if(bw.size() == 2) {
+          _bandwidth = (quint64)bw.at(1).toULongLong();
+        }
+      }
     }
   }
 }
diff --git a/src/torcontrol/RouterStatus.h b/src/torcontrol/RouterStatus.h
index c71e548..cff3b8a 100644
--- a/src/torcontrol/RouterStatus.h
+++ b/src/torcontrol/RouterStatus.h
@@ -67,6 +67,8 @@ public:
   Flags flags() const { return _flags; }
   /** Returns true if this router is currently listed as Running. */
   bool isRunning() const { return (flags() & Running); }
+  /** Returns the consensus bandwidth */
+  quint64 bandwidth() const { return _bandwidth; }
 
   /** Returns true if this router status object is valid. This method should
    * be called to verify that the QStringList given in this object's
@@ -89,6 +91,7 @@ private:
   quint16 _orPort;  /**< Current OR port. */
   quint16 _dirPort; /**< Current directory port. */
   Flags _flags;     /**< OR-ed field of the router's current status flags. */
+  quint64 _bandwidth; /**< Consensus bandwidth */
 };
 
 Q_DECLARE_OPERATORS_FOR_FLAGS(RouterStatus::Flags)
diff --git a/src/vidalia/network/NetViewer.cpp b/src/vidalia/network/NetViewer.cpp
index 6a67d57..2ce6b46 100644
--- a/src/vidalia/network/NetViewer.cpp
+++ b/src/vidalia/network/NetViewer.cpp
@@ -312,7 +312,8 @@ void
 NetViewer::loadNetworkStatus()
 {
   NetworkStatus networkStatus = _torControl->getNetworkStatus();
-  foreach (RouterStatus rs, networkStatus) {
+  
+  foreach(RouterStatus rs, networkStatus) {
     if (!rs.isRunning())
       continue;
 





More information about the tor-commits mailing list