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

[tor-commits] [vidalia/alpha] Add the configured router to the router list immediately



commit 62d910fa32174c1edc53598d88979193fe30e244
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Fri Mar 16 14:35:59 2012 -0300

    Add the configured router to the router list immediately
---
 src/torcontrol/RouterDescriptor.cpp |   22 ++++++++++++++++++++++
 src/torcontrol/RouterDescriptor.h   |    5 +++++
 src/vidalia/network/NetViewer.cpp   |    5 +++++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/torcontrol/RouterDescriptor.cpp b/src/torcontrol/RouterDescriptor.cpp
index 26051c1..0fead9c 100644
--- a/src/torcontrol/RouterDescriptor.cpp
+++ b/src/torcontrol/RouterDescriptor.cpp
@@ -14,6 +14,7 @@
 */
 
 #include "RouterDescriptor.h"
+#include "TorControl.h"
 
 #include <QtGlobal>
 
@@ -110,3 +111,24 @@ RouterDescriptor::appendRouterStatusInfo(const RouterStatus &rs)
   _burstBandwidth = rs.bandwidth();
   _observedBandwidth = rs.bandwidth();
 }
+
+RouterDescriptor *
+RouterDescriptor::fromTorControl(TorControl *tc)
+{
+  RouterDescriptor *rd = new RouterDescriptor(QStringList(), true);
+
+  if(tc->isConnected()) {
+    rd->_id = tc->getInfo("fingerprint").toString();
+    rd->_name = tc->getConf("Nickname").toString();
+    rd->_ip = QHostAddress(tc->getInfo("address").toString());
+    rd->_orPort = (quint16)tc->getConf("ORPort").toUInt();
+    rd->_dirPort = (quint16)tc->getConf("DirPort").toUInt();
+    rd->_avgBandwidth = (quint64)tc->getConf("BandwidthRate").toLongLong();
+    rd->_burstBandwidth = (quint64)tc->getConf("BandwidthBurst").toLongLong();
+    rd->_observedBandwidth = rd->_avgBandwidth;
+
+    rd->_status = Offline;
+  }
+
+  return rd;
+}
diff --git a/src/torcontrol/RouterDescriptor.h b/src/torcontrol/RouterDescriptor.h
index fdedae4..a43821b 100644
--- a/src/torcontrol/RouterDescriptor.h
+++ b/src/torcontrol/RouterDescriptor.h
@@ -24,6 +24,8 @@
 
 #include "RouterStatus.h"
 
+class TorControl;
+
 class RouterDescriptor
 {
   Q_DECLARE_TR_FUNCTIONS(RouterDescriptor)
@@ -99,6 +101,9 @@ public:
    *  descriptor */
   void appendRouterStatusInfo(const RouterStatus &rs);
 
+  /** Creates a RouterDescriptor from the control port information */
+  static RouterDescriptor *fromTorControl(TorControl *tc);
+
 private:
   /** Parses this router's descriptor for relevant information. */
   void parseDescriptor(QStringList descriptor);
diff --git a/src/vidalia/network/NetViewer.cpp b/src/vidalia/network/NetViewer.cpp
index 052bc90..4407588 100644
--- a/src/vidalia/network/NetViewer.cpp
+++ b/src/vidalia/network/NetViewer.cpp
@@ -18,6 +18,7 @@
 #include "RouterListItem.h"
 #include "Vidalia.h"
 #include "VMessageBox.h"
+#include "ServerSettings.h"
 
 #include <QMessageBox>
 #include <QToolBar>
@@ -345,6 +346,10 @@ NetViewer::preLoadNetworkStatus()
 {
   NetworkStatus networkStatus = _torControl->getNetworkStatus();
 
+  ServerSettings settings(_torControl);
+  if(settings.isServerEnabled())
+    _routers << *RouterDescriptor::fromTorControl(_torControl);
+
   foreach(RouterStatus rs, networkStatus) {
     if (!rs.isRunning())
       continue;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits