[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/master] Add torrc bootstrap option wrt ticket #2821
commit 4c6c98407173d3823613ec662b026f6bfc8ea866
Author: Tomas Touceda <chiiph@xxxxxxxxxx>
Date: Sun Apr 17 15:33:36 2011 -0300
Add torrc bootstrap option wrt ticket #2821
---
src/vidalia/MainWindow.cpp | 14 +++++++++++++-
src/vidalia/config/TorSettings.cpp | 27 +++++++++++++++++++++++++++
src/vidalia/config/TorSettings.h | 9 +++++++++
3 files changed, 49 insertions(+), 1 deletions(-)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index 3c5c789..29c1330 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -1014,8 +1014,20 @@ MainWindow::start()
}
}
- /* Make sure the torrc we want to use really exists. */
QString torrc = settings.getTorrc();
+
+ if(settings.bootstrap()) {
+ QString boottorrc = settings.bootstrapFrom();
+ vNotice(tr("Bootstrapping torrc from %1 to %2")
+ .arg(boottorrc).arg(torrc));
+ if(QFileInfo(boottorrc).exists()) {
+ if(QFile::copy(boottorrc, torrc)) {
+ settings.setBootstrap(false);
+ }
+ }
+ }
+
+ /* Make sure the torrc we want to use really exists. */
if (!torrc.isEmpty()) {
if (!QFileInfo(torrc).exists())
touch_file(torrc, true);
diff --git a/src/vidalia/config/TorSettings.cpp b/src/vidalia/config/TorSettings.cpp
index 046ff72..068537f 100644
--- a/src/vidalia/config/TorSettings.cpp
+++ b/src/vidalia/config/TorSettings.cpp
@@ -42,6 +42,8 @@
#define SETTING_USE_RANDOM_PASSWORD "UseRandomPassword"
#define SETTING_WARN_PLAINTEXT_PORTS "WarnPlaintextPorts"
#define SETTING_REJECT_PLAINTEXT_PORTS "RejectPlaintextPorts"
+#define SETTING_BOOTSTRAP "Bootstrap"
+#define SETTING_BOOTSTRAP_FROM "BootstrapFrom"
/** Default to using hashed password authentication */
#define DEFAULT_AUTH_METHOD PasswordAuth
@@ -88,6 +90,8 @@ TorSettings::TorSettings(TorControl *torControl)
setDefault(SETTING_WARN_PLAINTEXT_PORTS, QList<QVariant>() << 23 << 109
<< 110 << 143);
setDefault(SETTING_REJECT_PLAINTEXT_PORTS, QList<QVariant>());
+ setDefault(SETTING_BOOTSTRAP, false);
+ setDefault(SETTING_BOOTSTRAP_FROM, "");
}
/** Applies any changes to Tor's control port or authentication settings. */
@@ -423,3 +427,26 @@ TorSettings::hashPassword(const QString &password)
.arg(base16_encode(key));
}
+void
+TorSettings::setBootstrap(bool enabled)
+{
+ setValue(SETTING_BOOTSTRAP, enabled);
+}
+
+bool
+TorSettings::bootstrap() const
+{
+ return value(SETTING_BOOTSTRAP).toBool();
+}
+
+void
+TorSettings::setBootstrapFrom(const QString &from)
+{
+ setValue(SETTING_BOOTSTRAP_FROM, from);
+}
+
+QString
+TorSettings::bootstrapFrom() const
+{
+ return QDir::convertSeparators(value(SETTING_BOOTSTRAP_FROM).toString());
+}
diff --git a/src/vidalia/config/TorSettings.h b/src/vidalia/config/TorSettings.h
index a116c61..eb34b42 100644
--- a/src/vidalia/config/TorSettings.h
+++ b/src/vidalia/config/TorSettings.h
@@ -118,6 +118,15 @@ public:
* "tor --hash-password foo". */
static QString hashPassword(const QString &password);
+ /** Returns true if Vidalia needs to bootstrap the torrc file */
+ bool bootstrap() const;
+ /** Enables or disables bootstrap */
+ void setBootstrap(bool enabled);
+ /** Returns the path of the bootstrap torrc file */
+ QString bootstrapFrom() const;
+ /** Sets the location of the bootstrap torrc file */
+ void setBootstrapFrom(const QString &from);
+
private:
/** Returns the AuthenticationMethod enum value for the string
* description of the authentication method given in <b>authMethod</b>. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits