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

[tor-commits] [vidalia/alpha] Add defaults torrc handling



commit 498a5416a2bc819774617d5021466dd8116b6bb2
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Fri Feb 3 22:04:31 2012 -0300

    Add defaults torrc handling
---
 src/vidalia/MainWindow.cpp         |    8 +++++++-
 src/vidalia/config/TorSettings.cpp |   22 ++++++++++++++++++++++
 src/vidalia/config/TorSettings.h   |    5 +++++
 3 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index 65e1e3c..c3b1954 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -576,7 +576,6 @@ MainWindow::start()
     }
   }
 
-
   /* Check if Tor is already running separately */
   if(settings.getControlMethod() == ControlMethod::Port) {
     if(!settings.autoControlPort() && net_test_connect(settings.getControlAddress(),
@@ -592,6 +591,7 @@ MainWindow::start()
   }
 
   QString torrc = settings.getTorrc();
+  QString torrc_defaults = settings.getDefaultsTorrc();
 
   if(settings.bootstrap()) {
     QString boottorrc = settings.bootstrapFrom();
@@ -603,6 +603,12 @@ MainWindow::start()
       }
     }
   }
+  
+  if(_torControl->getTorVersion() >= 0x020309) {
+    if (!torrc_defaults.isEmpty()) {
+      args << "--defaults-torrc" << torrc_defaults;
+    }
+  }
 
   /* Make sure the torrc we want to use really exists. */
   if (!torrc.isEmpty()) {
diff --git a/src/vidalia/config/TorSettings.cpp b/src/vidalia/config/TorSettings.cpp
index 57e2440..9fa5369 100644
--- a/src/vidalia/config/TorSettings.cpp
+++ b/src/vidalia/config/TorSettings.cpp
@@ -30,6 +30,7 @@
 #define SETTING_TOR_EXECUTABLE      "TorExecutable"
 #define SETTING_TORRC               "Torrc"
 #define SETTING_CONTROL_ADDR        "ControlAddr"
+#define SETTING_DEFAULTS_TORRC      "DefaultsTorrc"
 #define SETTING_CONTROL_PORT        "ControlPort"
 #define SETTING_SOCKET_PATH         "ControlSocket"
 #define SETTING_CONTROL_METHOD      "ControlMethod"
@@ -81,6 +82,7 @@ TorSettings::TorSettings(TorControl *torControl)
 #endif
 
   setDefault(SETTING_TORRC,         Vidalia::dataDirectory() + "/torrc");
+  setDefault(SETTING_DEFAULTS_TORRC,Vidalia::dataDirectory() + "/defaults_torrc");
   setDefault(SETTING_CONTROL_ADDR,  "127.0.0.1");
   setDefault(SETTING_CONTROL_PORT,  9051);
   setDefault(SETTING_AUTH_METHOD,   toString(DEFAULT_AUTH_METHOD));
@@ -196,6 +198,26 @@ TorSettings::setTorrc(const QString &torrc)
   setValue(SETTING_TORRC, torrc);
 }
 
+/** Returns the defaults torrc that will be used when starting Tor. */
+QString
+TorSettings::getDefaultsTorrc() const
+{
+  QString torrc;
+  // TorControl *tc = torControl();
+  // if (tc && tc->isConnected() && tc->getInfo("config-file", torrc))
+  //   return QDir::convertSeparators(torrc);
+  return QDir::convertSeparators(localValue(SETTING_DEFAULTS_TORRC).toString());
+}
+
+/** Sets the defaults torrc that will be used when starting Tor.
+ * \param torrc The defaults torrc to use. 
+ */
+void
+TorSettings::setDefaultsTorrc(const QString &torrc)
+{
+  setValue(SETTING_DEFAULTS_TORRC, torrc);
+}
+
 /** Get the address or hostname used to connect to Tor */
 QHostAddress
 TorSettings::getControlAddress() const
diff --git a/src/vidalia/config/TorSettings.h b/src/vidalia/config/TorSettings.h
index 5038c3d..9e6622e 100644
--- a/src/vidalia/config/TorSettings.h
+++ b/src/vidalia/config/TorSettings.h
@@ -55,6 +55,11 @@ public:
   QString getTorrc() const;
   /** Sets the torrc to use when starting Tor. */
   void setTorrc(const QString &torrc);
+
+  /** Gets the defaults torrc to use when starting Tor. */
+  QString getDefaultsTorrc() const;
+  /** Sets the defaults torrc to use when starting Tor. */
+  void setDefaultsTorrc(const QString &torrc);
   
   /** Get Tor's control interface address. */
   QHostAddress getControlAddress() const;



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