tor-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
March 2012
- 19 participants
- 1205 discussions
commit b53e10e84412041caccbea642f4c20d6ed5a5581
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Mon Mar 5 09:36:10 2012 -0300
Add a changes file
---
changes/bug5109 | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/changes/bug5109 b/changes/bug5109
new file mode 100644
index 0000000..b9160ef
--- /dev/null
+++ b/changes/bug5109
@@ -0,0 +1,2 @@
+ o Handle tor's bootstrap phases in a more generic way. Fixes bug
+ 5109.
\ No newline at end of file
1
0
commit 1a4439771fb69fd0348c183cb7945326da587b75
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Mon Feb 13 12:37:47 2012 -0300
Add support for MicroDescriptors
---
src/torcontrol/RouterDescriptor.cpp | 95 ++++++++++++++++++++++------------
src/torcontrol/RouterDescriptor.h | 27 ++++++++--
src/torcontrol/TorControl.cpp | 19 +++++++-
src/torcontrol/TorControl.h | 2 +
4 files changed, 104 insertions(+), 39 deletions(-)
diff --git a/src/torcontrol/RouterDescriptor.cpp b/src/torcontrol/RouterDescriptor.cpp
index e63ca20..3634f3e 100644
--- a/src/torcontrol/RouterDescriptor.cpp
+++ b/src/torcontrol/RouterDescriptor.cpp
@@ -21,8 +21,8 @@
/** Constructor. Just assigns the ID and determines whether the router is
* responsive or not based on the presence of a "!" at the start of the ID.
* See tor-spec.txt for details. */
-RouterDescriptor::RouterDescriptor(QStringList descriptor)
-{
+RouterDescriptor::RouterDescriptor(QStringList descriptor, bool microdesc)
+ : _microdesc(microdesc), _observedBandwidth(0), _uptime(0) {
_status = Online;
parseDescriptor(descriptor);
}
@@ -31,38 +31,56 @@ RouterDescriptor::RouterDescriptor(QStringList descriptor)
void
RouterDescriptor::parseDescriptor(QStringList descriptor)
{
- foreach (QString line, descriptor) {
- if (line.startsWith("router ")) {
- QStringList parts = line.remove(0,qstrlen("router ")).split(" ");
- _name = parts.at(0);
- _ip = QHostAddress(parts.at(1));
- _orPort = (quint16)parts.at(2).toUInt();
- _dirPort = (quint16)parts.at(4).toUInt();
- } else if (line.startsWith("platform ")) {
- _platform = line.remove(0,qstrlen("platform "));
- } else if (line.startsWith("published ")) {
- _published = QDateTime::fromString(
- line.remove(0,qstrlen("published ")),
- "yyyy-MM-dd HH:mm:ss");
- _published.setTimeSpec(Qt::UTC);
- } else if (line.startsWith("opt fingerprint ")) {
- _fingerprint = line.remove(0,qstrlen("opt fingerprint "));
- _id = _fingerprint.remove(" ");
- } else if (line.startsWith("fingerprint ")) {
- _fingerprint = line.remove(0,qstrlen("fingerprint "));
- _id = _fingerprint.remove(" ");
- } else if (line.startsWith("uptime ")) {
- _uptime = (quint64)line.remove(0,qstrlen("uptime ")).toULongLong();
- } else if (line.startsWith("bandwidth ")) {
- QStringList bw = line.remove(0,qstrlen("bandwidth ")).split(" ");
- _avgBandwidth = (quint64)bw.at(0).toULongLong();
- _burstBandwidth = (quint64)bw.at(1).toULongLong();
- _observedBandwidth = (quint64)bw.at(2).toULongLong();
- } else if (line.startsWith("contact ")) {
- _contact = line.remove(0,qstrlen("contact "));
- } else if (line.startsWith("hibernating ")) {
- if (line.remove(0,qstrlen("hibernating ")).trimmed() == "1") {
- _status = Hibernating;
+ if(_microdesc) {
+ bool key = false;
+ foreach(QString line, descriptor) {
+ if(line.startsWith("onion-key")) {
+ key = true;
+ } else if(line.startsWith("p ")) {
+ _exitPolicy = line.remove(0,qstrlen("p "));
+ } else if(line.startsWith("family ")) {
+ _family = line.remove(0,qstrlen("family "));
+ }
+
+ if(key)
+ _onionKey += line;
+ if(line.startsWith("-----END RSA PUBLIC KEY-----"))
+ key = false;
+ }
+ } else {
+ foreach (QString line, descriptor) {
+ if (line.startsWith("router ")) {
+ QStringList parts = line.remove(0,qstrlen("router ")).split(" ");
+ _name = parts.at(0);
+ _ip = QHostAddress(parts.at(1));
+ _orPort = (quint16)parts.at(2).toUInt();
+ _dirPort = (quint16)parts.at(4).toUInt();
+ } else if (line.startsWith("platform ")) {
+ _platform = line.remove(0,qstrlen("platform "));
+ } else if (line.startsWith("published ")) {
+ _published = QDateTime::fromString(
+ line.remove(0,qstrlen("published ")),
+ "yyyy-MM-dd HH:mm:ss");
+ _published.setTimeSpec(Qt::UTC);
+ } else if (line.startsWith("opt fingerprint ")) {
+ _fingerprint = line.remove(0,qstrlen("opt fingerprint "));
+ _id = _fingerprint.remove(" ");
+ } else if (line.startsWith("fingerprint ")) {
+ _fingerprint = line.remove(0,qstrlen("fingerprint "));
+ _id = _fingerprint.remove(" ");
+ } else if (line.startsWith("uptime ")) {
+ _uptime = (quint64)line.remove(0,qstrlen("uptime ")).toULongLong();
+ } else if (line.startsWith("bandwidth ")) {
+ QStringList bw = line.remove(0,qstrlen("bandwidth ")).split(" ");
+ _avgBandwidth = (quint64)bw.at(0).toULongLong();
+ _burstBandwidth = (quint64)bw.at(1).toULongLong();
+ _observedBandwidth = (quint64)bw.at(2).toULongLong();
+ } else if (line.startsWith("contact ")) {
+ _contact = line.remove(0,qstrlen("contact "));
+ } else if (line.startsWith("hibernating ")) {
+ if (line.remove(0,qstrlen("hibernating ")).trimmed() == "1") {
+ _status = Hibernating;
+ }
}
}
}
@@ -80,3 +98,12 @@ RouterDescriptor::status()
return tr("Offline");
}
+void
+RouterDescriptor::appendRouterStatusInfo(const RouterStatus &rs)
+{
+ _id = rs.id();
+ _name = rs.name();
+ _ip = rs.ipAddress();
+ _orPort = rs.orPort();
+ _dirPort = rs.dirPort();
+}
diff --git a/src/torcontrol/RouterDescriptor.h b/src/torcontrol/RouterDescriptor.h
index d4ff868..d0c3400 100644
--- a/src/torcontrol/RouterDescriptor.h
+++ b/src/torcontrol/RouterDescriptor.h
@@ -22,6 +22,7 @@
#include <QList>
#include <QHostAddress>
+#include "RouterStatus.h"
class RouterDescriptor
{
@@ -29,16 +30,16 @@ class RouterDescriptor
public:
/** Possible router states. */
- enum RouterStatus {
+ enum RouterStatusEnum {
Online, /**< Router is online and reachable. */
Hibernating, /**< Router is currently hibernating. */
Offline /**< Router is unresponsive. */
};
/** Default constructor. */
- RouterDescriptor() {}
+ RouterDescriptor(bool microdesc = false) : _microdesc(microdesc) {}
/** Constructor. */
- RouterDescriptor(QStringList descriptor);
+ RouterDescriptor(QStringList descriptor, bool microdesc = false);
/** Returns the router's name. */
QString name() const { return _name; }
@@ -86,11 +87,23 @@ public:
/** Sets the descriptors status to Offline if <b>offline</b> is true. */
void setOffline(bool offline) { _status = (offline ? Offline : Online); }
+ /** Microdescriptor */
+ /** Returns the onion key for this router */
+ QString onionKey() const { return _onionKey; }
+ /** Returns this router's family */
+ QString family() const { return _family; }
+ /** Returns this router's exit policy */
+ QString exitPolicy() const { return _exitPolicy; }
+
+ /** Uses the RouterStatus information to update key elements of the
+ * descriptor */
+ void appendRouterStatusInfo(const RouterStatus &rs);
+
private:
/** Parses this router's descriptor for relevant information. */
void parseDescriptor(QStringList descriptor);
- RouterStatus _status; /**< Availability status of this router. */
+ RouterStatusEnum _status;/**< Availability status of this router. */
QString _id; /**< Router's descriptor ID. */
QString _name; /**< The router's name. */
QString _fingerprint; /**< Router's fingerprint. */
@@ -105,6 +118,12 @@ private:
quint64 _burstBandwidth; /**< Burst bandwidth. */
quint64 _observedBandwidth; /**< Observed bandwidth. */
QString _location; /**< Geographic location information. */
+
+ /** Microdescriptor info */
+ bool _microdesc; /** */
+ QString _onionKey; /** Router SSL key */
+ QString _exitPolicy; /** Exit policy */
+ QString _family; /** Family */
};
#endif
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index a73c81d..f87f3a9 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -941,6 +941,20 @@ TorControl::resetConf(QString key, QString *errmsg)
return resetConf(QStringList() << key, errmsg);
}
+bool
+TorControl::useMicrodescriptors(QString *errmsg)
+{
+ if(!errmsg)
+ errmsg = new QString();
+
+ QString mdres, fetchres;
+ if(!getConf("UseMicrodescriptors", mdres, errmsg))
+ return false;
+ if(!getConf("FetchUselessDescriptors", fetchres, errmsg))
+ return false;
+ return (mdres == "1") or (mdres == "auto" and fetchres == "0");
+}
+
/** Returns an unparsed router descriptor for the router whose fingerprint
* matches <b>id</b>. The returned text can later be parsed by the
* RouterDescriptor class. If <b>id</b> is invalid, then an empty
@@ -948,6 +962,9 @@ TorControl::resetConf(QString key, QString *errmsg)
QStringList
TorControl::getRouterDescriptorText(const QString &id, QString *errmsg)
{
+ if(useMicrodescriptors(errmsg))
+ return getInfo("md/id/" + id, errmsg).toStringList();
+
return getInfo("desc/id/" + id, errmsg).toStringList();
}
@@ -957,7 +974,7 @@ TorControl::getRouterDescriptorText(const QString &id, QString *errmsg)
RouterDescriptor
TorControl::getRouterDescriptor(const QString &id, QString *errmsg)
{
- return RouterDescriptor(getRouterDescriptorText(id, errmsg));
+ return RouterDescriptor(getRouterDescriptorText(id, errmsg), useMicrodescriptors());
}
/** Returns the status of the router whose fingerprint matches <b>id</b>. If
diff --git a/src/torcontrol/TorControl.h b/src/torcontrol/TorControl.h
index c16758c..cc486a1 100644
--- a/src/torcontrol/TorControl.h
+++ b/src/torcontrol/TorControl.h
@@ -168,6 +168,8 @@ public:
/** Tells Tor to reset a configuration key back to its default value. */
bool resetConf(QString key, QString *errmsg = 0);
+ /** Returns true if UseMicrodescriptors is enabled */
+ bool useMicrodescriptors(QString *errmsg = 0);
/** Returns an unparsed router descriptor for the router whose fingerprint
* matches <b>id</b>. The returned text can later be parsed by the
* RouterDescriptor class. If <b>id</b> is invalid, then an empty
1
0

[vidalia/master] Remove BootstrapStatus::Status. We will get the description from tor
by chiiph@torproject.org 05 Mar '12
by chiiph@torproject.org 05 Mar '12
05 Mar '12
commit 8144a2ff47fb3bc6c112aaef145912d7fe9f15d5
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Mon Feb 20 18:08:59 2012 -0300
Remove BootstrapStatus::Status. We will get the description from tor
---
src/torcontrol/BootstrapStatus.cpp | 37 ++--------------------------------
src/torcontrol/BootstrapStatus.h | 25 ++--------------------
src/torcontrol/TorControl.cpp | 4 +-
src/torcontrol/TorEvents.cpp | 2 +-
src/vidalia/MainWindow.cpp | 38 +-----------------------------------
5 files changed, 10 insertions(+), 96 deletions(-)
diff --git a/src/torcontrol/BootstrapStatus.cpp b/src/torcontrol/BootstrapStatus.cpp
index 8184ffe..f4e38b8 100644
--- a/src/torcontrol/BootstrapStatus.cpp
+++ b/src/torcontrol/BootstrapStatus.cpp
@@ -20,13 +20,14 @@ BootstrapStatus::BootstrapStatus()
{
_severity = tc::UnrecognizedSeverity;
_reason = tc::UnrecognizedReason;
- _status = UnrecognizedStatus;
+ _status = QString();
_action = UnrecognizedRecommendation;
_percentComplete = -1;
}
/** Constructor. */
-BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
+BootstrapStatus::BootstrapStatus(tc::Severity severity,
+ const QString &status,
int percentComplete,
const QString &description,
const QString &warning,
@@ -42,37 +43,6 @@ BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
_action = action;
}
-/** Converts a string TAG value to a BootstrapStatus enum value. */
-BootstrapStatus::Status
-BootstrapStatus::statusFromString(const QString &str)
-{
- if (!str.compare("CONN_DIR", Qt::CaseInsensitive))
- return ConnectingToDirMirror;
- if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive))
- return HandshakingWithDirMirror;
- if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive))
- return CreatingOneHopCircuit;
- if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive))
- return RequestingNetworkStatus;
- if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive))
- return LoadingNetworkStatus;
- if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive))
- return LoadingAuthorityCertificates;
- if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive))
- return RequestingDescriptors;
- if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive))
- return LoadingDescriptors;
- if (!str.compare("CONN_OR", Qt::CaseInsensitive))
- return ConnectingToEntryGuard;
- if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive))
- return HandshakingWithEntryGuard;
- if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive))
- return EstablishingCircuit;
- if (!str.compare("DONE", Qt::CaseInsensitive))
- return BootstrappingDone;
- return UnrecognizedStatus;
-}
-
/** Returns the action that the Tor software recommended be taken in response
* to this bootstrap status. */
BootstrapStatus::Recommendation
@@ -90,7 +60,6 @@ bool
BootstrapStatus::isValid() const
{
return (_severity != tc::UnrecognizedSeverity
- && _status != UnrecognizedStatus
&& _percentComplete >= 0);
}
diff --git a/src/torcontrol/BootstrapStatus.h b/src/torcontrol/BootstrapStatus.h
index 7526fdb..a2e3297 100644
--- a/src/torcontrol/BootstrapStatus.h
+++ b/src/torcontrol/BootstrapStatus.h
@@ -25,23 +25,6 @@
class BootstrapStatus
{
public:
- /** Currently enumerated bootstrapping states defined by Tor's control
- * protocol (Tor >= 0.2.1.0-alpha-dev. */
- enum Status {
- UnrecognizedStatus,
- ConnectingToDirMirror,
- HandshakingWithDirMirror,
- CreatingOneHopCircuit,
- RequestingNetworkStatus,
- LoadingNetworkStatus,
- LoadingAuthorityCertificates,
- RequestingDescriptors,
- LoadingDescriptors,
- ConnectingToEntryGuard,
- HandshakingWithEntryGuard,
- EstablishingCircuit,
- BootstrappingDone
- };
/** Actions the Tor software might recommend controllers take in response to
* a bootstrap status problem event. */
enum Recommendation {
@@ -55,7 +38,7 @@ public:
/** Constructor. */
BootstrapStatus(tc::Severity severity,
- Status status, int percentComplete,
+ const QString &status, int percentComplete,
const QString &description,
const QString &warning = QString(),
tc::ConnectionStatusReason reason = tc::UnrecognizedReason,
@@ -66,7 +49,7 @@ public:
/** Returns the BootstrapStatus enum value indicated by this bootstrap
* status event. */
- Status status() const { return _status; }
+ QString status() const { return _status; }
/** Returns an integer between 0 and 100 representing an estimate of how
* much of Tor's bootstrapping process it has completed. */
@@ -94,8 +77,6 @@ public:
* phase. */
bool isValid() const;
- /** Converts a string TAG value to a BootstrapStatus enum value. */
- static Status statusFromString(const QString &tag);
/** Converts a string RECOMMENDATION value to a RecommendAction enum
* value. */
static Recommendation actionFromString(const QString &str);
@@ -109,7 +90,7 @@ private:
/** Current bootstrapping status value.
* \sa status
*/
- Status _status;
+ QString _status;
/** Approximate percentage of Tor's bootstrapping process that is complete.
* \sa percentComplete
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index 3cf7467..a73c81d 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -230,7 +230,7 @@ TorControl::getBootstrapPhase()
tc::Severity severity = tc::severityFromString(args.value("status/bootstrap-phase"));
BootstrapStatus status
= BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"));
emit bootstrapStatusChanged(status);
@@ -403,7 +403,7 @@ TorControl::bootstrapStatus(QString *errmsg)
tc::Severity severity = tc::severityFromString(str.section(' ', 0, 0));
QHash<QString,QString> args = string_parse_keyvals(str);
return BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"),
args.value("WARNING"),
diff --git a/src/torcontrol/TorEvents.cpp b/src/torcontrol/TorEvents.cpp
index 588a093..f068f1a 100644
--- a/src/torcontrol/TorEvents.cpp
+++ b/src/torcontrol/TorEvents.cpp
@@ -368,7 +368,7 @@ TorEvents::handleClientStatusEvent(tc::Severity severity,
} else if (! action.compare("BOOTSTRAP", Qt::CaseInsensitive)) {
BootstrapStatus status
= BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"),
args.value("WARNING"),
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index d170d47..166b472 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -804,43 +804,7 @@ MainWindow::bootstrapStatusChanged(const BootstrapStatus &bs)
bs.recommendedAction() != BootstrapStatus::RecommendIgnore);
QString description;
- switch (bs.status()) {
- case BootstrapStatus::ConnectingToDirMirror:
- description = tr("Connecting to a relay directory");
- break;
- case BootstrapStatus::HandshakingWithDirMirror:
- case BootstrapStatus::CreatingOneHopCircuit:
- description = tr("Establishing an encrypted directory connection");
- break;
- case BootstrapStatus::RequestingNetworkStatus:
- description = tr("Retrieving network status");
- break;
- case BootstrapStatus::LoadingNetworkStatus:
- description = tr("Loading network status");
- break;
- case BootstrapStatus::LoadingAuthorityCertificates:
- description = tr("Loading authority certificates");
- break;
- case BootstrapStatus::RequestingDescriptors:
- description = tr("Requesting relay information");
- break;
- case BootstrapStatus::LoadingDescriptors:
- description = tr("Loading relay information");
- break;
- case BootstrapStatus::ConnectingToEntryGuard:
- description = tr("Connecting to the Tor network");
- break;
- case BootstrapStatus::HandshakingWithEntryGuard:
- case BootstrapStatus::EstablishingCircuit:
- description = tr("Establishing a Tor circuit");
- break;
- case BootstrapStatus::BootstrappingDone:
- description = tr("Connected to the Tor network!");
- warn = false; /* probably false anyway */
- break;
- default:
- description = tr("Unrecognized startup status");
- }
+ description = bs.description();
if (warn) {
QString reason;
/* Is it really a good idea to translate these? */
1
0

05 Mar '12
commit f38fa3133b37d8614213ba93c9d5c0d52725c829
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 17:21:17 2012 -0300
Add a way to use +LOADCONF control command
It will be used to apply the new torrc settings
---
src/torcontrol/TorControl.cpp | 11 +++++++++++
src/torcontrol/TorControl.h | 2 ++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index e95f9c7..efa5dfc 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -893,6 +893,17 @@ TorControl::getConf(const QString &key, QString *errmsg)
return map.value(key);
}
+/** Loads the contents as if they were read from disk as the torrc */
+bool
+TorControl::loadConf(const QString &contents, QString *errmsg)
+{
+ ControlCommand cmd("+LOADCONF");
+ ControlReply reply;
+
+ cmd.addArgument(contents + ".");
+ return send(cmd, reply, errmsg);
+}
+
/** Sends a GETCONF message to Tor with the single key and returns a QString
* containing the value returned by Tor */
QString
diff --git a/src/torcontrol/TorControl.h b/src/torcontrol/TorControl.h
index c16758c..3541c86 100644
--- a/src/torcontrol/TorControl.h
+++ b/src/torcontrol/TorControl.h
@@ -157,6 +157,8 @@ public:
* QVariant containing the value returned by Tor. Returns a default
* constructed QVariant on failure. */
QVariant getConf(const QString &key, QString *errmsg = 0);
+ /** Loads the contents as if they were read from disk as the torrc */
+ bool loadConf(const QString &contents, QString *errmsg = 0);
/** Sends a GETCONF message to Tor with the single key and returns a QString
* containing the value returned by Tor */
QString getHiddenServiceConf(const QString &key, QString *errmsg = 0);
1
0

[vidalia/alpha] Add the possibility to consult the ControlReply after a SETCONF
by chiiph@torproject.org 05 Mar '12
by chiiph@torproject.org 05 Mar '12
05 Mar '12
commit 03a56b386626b056fe808021fc3f89bc62d9fc8c
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 17:25:50 2012 -0300
Add the possibility to consult the ControlReply after a SETCONF
This will be used to identify when an error occurs with SETCONF, whether it
is a 553 error or any other kind. If it's a 553, then the option is not
wrong but tor can't apply that change while it is running. Otherwise, it's
an error in the option and it should be treated as such.
---
src/torcontrol/TorControl.cpp | 15 +++++++++------
src/torcontrol/TorControl.h | 6 +++---
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index efa5dfc..77cd567 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -719,7 +719,7 @@ TorControl::setEvents(QString *errmsg)
/** Sets each configuration key in <b>map</b> to the value associated
* with its key. */
bool
-TorControl::setConf(QHash<QString,QString> map, QString *errmsg)
+TorControl::setConf(QHash<QString,QString> map, QString *errmsg, ControlReply *reply)
{
ControlCommand cmd("SETCONF");
@@ -739,25 +739,28 @@ TorControl::setConf(QHash<QString,QString> map, QString *errmsg)
cmd.addArgument(key);
}
}
- return send(cmd, errmsg);
+
+ if(not reply)
+ reply = new ControlReply();
+ return send(cmd, *reply, errmsg);
}
/** Sets a single configuration key to the given value. */
bool
-TorControl::setConf(QString key, QString value, QString *errmsg)
+TorControl::setConf(QString key, QString value, QString *errmsg, ControlReply *reply)
{
QHash<QString,QString> map;
map.insert(key, value);
- return setConf(map, errmsg);
+ return setConf(map, errmsg, reply);
}
/** Sets a single configuration string that is formatted <key=escaped value>.*/
bool
-TorControl::setConf(QString keyAndValue, QString *errmsg)
+TorControl::setConf(QString keyAndValue, QString *errmsg, ControlReply *reply)
{
QHash<QString,QString> map;
map.insert(keyAndValue, "");
- return setConf(map, errmsg);
+ return setConf(map, errmsg, reply);
}
/** Gets values for a set of configuration keys, each of which has a single
diff --git a/src/torcontrol/TorControl.h b/src/torcontrol/TorControl.h
index 3541c86..6a58b71 100644
--- a/src/torcontrol/TorControl.h
+++ b/src/torcontrol/TorControl.h
@@ -134,11 +134,11 @@ public:
bool setEvents(QString *errmsg = 0);
/** Sets each configuration key in <b>map</b> to the value associated with its key. */
- bool setConf(QHash<QString,QString> map, QString *errmsg = 0);
+ bool setConf(QHash<QString,QString> map, QString *errmsg = 0, ControlReply *reply = 0);
/** Sets a single configuration key to the given value. */
- bool setConf(QString key, QString value, QString *errmsg = 0);
+ bool setConf(QString key, QString value, QString *errmsg = 0, ControlReply *reply = 0);
/** Sets a single configuration string that is formatted <key=escaped value>. */
- bool setConf(QString keyAndValue, QString *errmsg = 0);
+ bool setConf(QString keyAndValue, QString *errmsg = 0, ControlReply *reply = 0);
/** Gets values for a set of configuration keys, each of which has a single
* value. */
bool getConf(QHash<QString,QString> &map, QString *errmsg = 0);
1
0

05 Mar '12
commit b129228f3e408b431f3747c918d0a5904e3c297f
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 17:18:13 2012 -0300
Remove the HiddenService configuration
It should be readded as a plugin, it has some bugs and it isn't structured
like the rest of the settings which makes it harder to migrate to the new
torrc only approach.
---
src/vidalia/CMakeLists.txt | 6 -
src/vidalia/config/ConfigDialog.cpp | 7 -
src/vidalia/config/Service.cpp | 119 ------
src/vidalia/config/Service.h | 80 -----
src/vidalia/config/ServiceList.cpp | 56 ---
src/vidalia/config/ServiceList.h | 51 ---
src/vidalia/config/ServicePage.cpp | 613 --------------------------------
src/vidalia/config/ServicePage.h | 79 ----
src/vidalia/config/ServicePage.ui | 173 ---------
src/vidalia/config/ServiceSettings.cpp | 167 ---------
src/vidalia/config/ServiceSettings.h | 61 ----
11 files changed, 0 insertions(+), 1412 deletions(-)
diff --git a/src/vidalia/CMakeLists.txt b/src/vidalia/CMakeLists.txt
index 4a28504..3277bf0 100644
--- a/src/vidalia/CMakeLists.txt
+++ b/src/vidalia/CMakeLists.txt
@@ -122,11 +122,7 @@ set(vidalia_SRCS ${vidalia_SRCS}
config/PortValidator.cpp
config/ServerPage.cpp
config/ServerSettings.cpp
- config/Service.cpp
- config/ServiceList.cpp
- config/ServicePage.cpp
config/TorrcDialog.cpp
- config/ServiceSettings.cpp
config/TorSettings.cpp
config/VidaliaSettings.cpp
config/VSettings.cpp
@@ -150,7 +146,6 @@ qt4_wrap_cpp(vidalia_SRCS
config/PortValidator.h
config/ServerPage.h
config/ServerSettings.h
- config/ServicePage.h
config/TorrcDialog.h
config/TorSettings.h
config/VidaliaSettings.h
@@ -218,7 +213,6 @@ qt4_wrap_ui(vidalia_SRCS
config/GeneralPage.ui
config/NetworkPage.ui
config/ServerPage.ui
- config/ServicePage.ui
config/TorrcDialog.ui
log/MessageLog.ui
help/browser/HelpBrowser.ui
diff --git a/src/vidalia/config/ConfigDialog.cpp b/src/vidalia/config/ConfigDialog.cpp
index bb711dc..a2debf5 100644
--- a/src/vidalia/config/ConfigDialog.cpp
+++ b/src/vidalia/config/ConfigDialog.cpp
@@ -19,7 +19,6 @@
#include "ServerPage.h"
#include "AdvancedPage.h"
#include "AppearancePage.h"
-#include "ServicePage.h"
#include "VMessageBox.h"
#include "ServerSettings.h"
#include "NetworkSettings.h"
@@ -84,10 +83,6 @@ ConfigDialog::ConfigDialog(QWidget* parent)
createPageAction(QIcon(IMAGE_SERVER),
tr("Sharing"), "Sharing", grp));
- ui.stackPages->add(new ServicePage(ui.stackPages),
- createPageAction(QIcon(IMAGE_SERVICE),
- tr("Services"), "Services", grp));
-
ui.stackPages->add(new AppearancePage(ui.stackPages),
createPageAction(QIcon(IMAGE_APPEARANCE),
tr("Appearance"), "Appearance", grp));
@@ -277,8 +272,6 @@ ConfigDialog::help()
help("config.appearance"); break;
case Advanced:
help("config.advanced"); break;
- case Service:
- help("config.services"); break;
default:
help("config.general"); break;
}
diff --git a/src/vidalia/config/Service.cpp b/src/vidalia/config/Service.cpp
deleted file mode 100644
index c880529..0000000
--- a/src/vidalia/config/Service.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#include "Service.h"
-
-
-/** Default Constructor */
-Service::Service()
-{
-}
-
-/** Constructor to create a new Service with initial settings */
-Service::Service(QString serviceAddress, QString virtualPort,
- QString physicalAddressPort, QString serviceDirectory, bool enabled)
-{
- _serviceAddress = serviceAddress;
- _virtualPort = virtualPort;
- _physicalAddressPort = physicalAddressPort;
- _serviceDirectory = serviceDirectory;
- _enabled = enabled;
-}
-
-/** Destructor */
-Service::~Service()
-{
-}
-
-/** Sets the deploy status of a service */
-void Service::setEnabled(bool enabled)
-{
- _enabled = enabled;
-}
-
-/** Sets the adress of a service */
-void Service::setServiceAddress(QString serviceAddress)
-{
- _serviceAddress = serviceAddress;
-}
-
-/** Sets the virtualPort of a service */
-void Service::setVirtualPort(QString virtualPort)
-{
- _virtualPort = virtualPort;
-}
-
-/** Sets the physical Adress and the local port of a service */
-void Service::setPhysicalAddressPort(QString physicalAddressPort)
-{
- _physicalAddressPort = physicalAddressPort;
-}
-
-/** Sets the service directory of a service */
-void Service::setServiceDirectory(QString serviceDirectory)
-{
- _serviceDirectory = serviceDirectory;
-}
-
-/** Sets the additional options of a service e.g. excludeNodes */
-void Service::setAdditionalServiceOptions(QString options)
-{
- _additionalServiceOptions = options;
-}
-
-/** Writes service class data from <b>myObj</b> to the QDataStream
- * <b>out</b>. */
-QDataStream&operator<<(QDataStream &out, const Service &myObj)
-{
- out << myObj.serviceAddress();
- out << myObj.virtualPort();
- out << myObj.physicalAddressPort();
- out << myObj.serviceDirectory();
- out << myObj.enabled();
- out << myObj.additionalServiceOptions();
-
- return out;
-}
-
-/** Reads service class data in from the QDataStream <b>in</b> and
- populates * the <b>myObj</b> object accordingly. */
-QDataStream&operator>>(QDataStream &in, Service &myObj)
-{
- QString serviceAddress;
- QString virtualPort;
- QString physicalAddressPort;
- QString serviceDirectory;
- bool enabled;
- QString additionalServiceOptions;
-
- /* Read in from the data stream */
- in >> serviceAddress >> virtualPort >> physicalAddressPort
- >> serviceDirectory >> enabled >> additionalServiceOptions;
-
- /* Set the appropriate class member variables */
- myObj.setServiceAddress(serviceAddress);
- myObj.setVirtualPort(virtualPort);
- myObj.setPhysicalAddressPort(physicalAddressPort);
- myObj.setServiceDirectory(serviceDirectory);
- myObj.setEnabled(enabled);
- myObj.setAdditionalServiceOptions(additionalServiceOptions);
-
- /* Return the updated data stream */
- return in;
-}
-
-/** Creates a string by concatenating the values of the service. */
-QString
-Service::toString()
-{
- return _serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort +
- "#"+ _serviceDirectory +"#"+ _enabled + "#"+ _additionalServiceOptions;
-}
-
diff --git a/src/vidalia/config/Service.h b/src/vidalia/config/Service.h
deleted file mode 100644
index 6c6a790..0000000
--- a/src/vidalia/config/Service.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#ifndef _SERVICE_H
-#define _SERVICE_H
-
-#include <QString>
-#include <QList>
-#include <QMetaType>
-
-
-class Service
-{
-public:
- /** Default constructor. */
- Service();
- /** Constructor to create a new Service with initial settings */
- Service(QString serviceAddress, QString virtualPort,
- QString physicalAddressPort, QString serviceDirectory, bool enabled);
- /** Destructor */
- virtual ~Service();
- /** Returns the service Adress of the service */
- QString serviceAddress() const { return _serviceAddress; }
- /** Returns the listeningPort of the service */
- QString virtualPort() const { return _virtualPort; }
- /** Returns the physical Adresse and the local Port of the service */
- QString physicalAddressPort() const { return _physicalAddressPort; }
- /** Returns the service directory of the service */
- QString serviceDirectory() const { return _serviceDirectory; }
- /** Returns the deployed status of a service */
- bool enabled() const { return _enabled; }
- /** Returns the additional options of a service e.g. excludeNodes */
- QString additionalServiceOptions() const
- { return _additionalServiceOptions; }
- /** Sets the adress of a service */
- void setServiceAddress(QString serviceAddress);
- /** Sets the listening port of a service */
- void setVirtualPort(QString virtualPort);
- /** Sets the physical Adress and the local Port of a service */
- void setPhysicalAddressPort(QString physicalAddressPort);
- /** Sets the service directory of a service */
- void setServiceDirectory(QString serviceDirectory);
- /** Sets the deployed status a service */
- void setEnabled(bool enabled);
- /** Sets the additional options of a service e.g. excludeNodes */
- void setAdditionalServiceOptions(QString options);
- /** Writes service class data from <b>myObj</b> to the QDataStream
- * <b>out</b>. */
- friend QDataStream& operator<<(QDataStream &out, const Service &myObj);
- /** Reads service class data in from the QDataStream <b>in</b> and
- populates * the <b>myObj</b> object accordingly. */
- friend QDataStream& operator>>(QDataStream &in, Service &myObj);
- /** this method creates a string by concatenating the values of the service */
- QString toString();
-
-private:
- /** The adress of the service */
- QString _serviceAddress;
- /** The listening Port of the service */
- QString _virtualPort;
- /** The physical Adress and the local port of teh service */
- QString _physicalAddressPort;
- /** the directory of the service */
- QString _serviceDirectory;
- /** The Enabled status of the service */
- bool _enabled;
- /** Some additional service options, not configured/displayed by Vidalia */
- QString _additionalServiceOptions;
-
-};
-Q_DECLARE_METATYPE(Service);
-#endif /*SERIVCE_H_*/
-
diff --git a/src/vidalia/config/ServiceList.cpp b/src/vidalia/config/ServiceList.cpp
deleted file mode 100644
index fd644f0..0000000
--- a/src/vidalia/config/ServiceList.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#include "ServiceList.h"
-
-
-/** Default constructor. */
-ServiceList::ServiceList()
-{
-}
-
-/** Constructor to create a new Servicelist with initial settings */
-void ServiceList::addService(Service service)
-{
- _services.append(service);
-}
-
-/** Destructor */
-ServiceList::~ServiceList()
-{
-}
-
-/* Sets the serviceList */
-void ServiceList::setServices(QList<Service> services)
-{
- _services = services;
-}
-
-/** Writes ServiceList class data from <b>myObj</b> to the QDataStream
- * <b>out</b>. */
-QDataStream&operator<<(QDataStream &out, const ServiceList &myObj)
-{
- out << myObj.services(); /* Write the services*/
- return out;
-}
-
-/** Reads ServiceList class data in from the QDataStream <b>in</b> and
- populates * the <b>myObj</b> object accordingly. */
-QDataStream&operator>>(QDataStream &in, ServiceList &myObj)
-{
- QList<Service> services;
- /* Read in from the data stream */
- in >> services;
- /* Set the appropriate class member variables */
- myObj.setServices(services);
- /* Return the updated data stream */
- return in;
-}
-
diff --git a/src/vidalia/config/ServiceList.h b/src/vidalia/config/ServiceList.h
deleted file mode 100644
index a5c216d..0000000
--- a/src/vidalia/config/ServiceList.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#ifndef _SERVICELIST_H
-#define _SERVICELIST_H
-
-#include "Service.h"
-
-#include <QList>
-
-
-class ServiceList
-{
-public:
-
- /** Default constructor. */
- ServiceList();
- /** Destructor */
- virtual ~ServiceList();
- /** Returns the list of services */
- void addService(Service service);
- /** Sets the lists of services */
- void setServices(QList<Service> services);
- /** Returns the list of services */
- QList<Service> services() const {
- return _services;
- }
- /** Writes ServiceList class data from <b>myObj</b> to the QDataStream
- * <b>out</b>. */
- friend QDataStream& operator<<(QDataStream &out, const ServiceList &myObj);
- /** Reads ServiceList class data in from the QDataStream <b>in</b> and
- populates * the <b>myObj</b> object accordingly. */
- friend QDataStream& operator>>(QDataStream &in, ServiceList &myObj);
-
-private:
-
- /** The list of Services */
- QList<Service> _services;
-
-};
-Q_DECLARE_METATYPE(ServiceList);
-
-#endif
-
diff --git a/src/vidalia/config/ServicePage.cpp b/src/vidalia/config/ServicePage.cpp
deleted file mode 100644
index ac412f9..0000000
--- a/src/vidalia/config/ServicePage.cpp
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#include "ServicePage.h"
-#include "Service.h"
-#include "ServiceList.h"
-#include "VMessageBox.h"
-#include "ConfigDialog.h"
-#include "IpValidator.h"
-#include "DomainValidator.h"
-#include "Vidalia.h"
-
-#include "stringutil.h"
-#include "file.h"
-
-#include <QHeaderView>
-#include <QClipboard>
-#include <QFile>
-#include <QTextStream>
-
-
-/** Constructor */
-ServicePage::ServicePage(QWidget *parent)
-: ConfigPage(parent, "Services")
-{
- /* Invoke the Qt Designer generated object setup routine */
- ui.setupUi(this);
- /* A QMap, mapping from the row number to the Entity for
- * all services */
- _services = new QMap<int, Service>();
- /* A QMap, mapping from the directory path to the Entity for
- * all Tor services */
- _torServices = new QMap<QString, Service>();
-
- ui.serviceWidget->horizontalHeader()->resizeSection(0, 150);
- ui.serviceWidget->horizontalHeader()->resizeSection(1, 89);
- ui.serviceWidget->horizontalHeader()->resizeSection(2, 100);
- ui.serviceWidget->horizontalHeader()->resizeSection(3, 120);
- ui.serviceWidget->horizontalHeader()->resizeSection(4, 60);
- ui.serviceWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
- ui.serviceWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
- ui.serviceWidget->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
- ui.serviceWidget->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch);
- ui.serviceWidget->verticalHeader()->hide();
-
- connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addService()));
- connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeService()));
- connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyToClipboard()));
- connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseDirectory()));
- connect(ui.serviceWidget, SIGNAL(itemClicked(QTableWidgetItem*)),
- this, SLOT(serviceSelectionChanged()));
- connect(ui.serviceWidget, SIGNAL(itemChanged(QTableWidgetItem*)),
- this, SLOT(valueChanged()));
-}
-
-/** Destructor */
-ServicePage::~ServicePage()
-{
- delete _services;
- delete _torServices;
-}
-
-/** Called when the user changes the UI translation. */
-void
-ServicePage::retranslateUi()
-{
- ui.retranslateUi(this);
-}
-
-/** Saves changes made to settings on the Server settings page. */
-bool
-ServicePage::save(QString &errmsg)
-{
- ServiceSettings serviceSettings(Vidalia::torControl());
- QList<Service> serviceList;
- QList<Service> publishedServices;
- int index = 0;
-
- while(index < ui.serviceWidget->rowCount()) {
- QString address = ui.serviceWidget->item(index,0)->text();
- QString virtualPort = ui.serviceWidget->item(index,1)->text();
- QString physicalAddress = ui.serviceWidget->item(index,2)->text();
- QString directoryPath = ui.serviceWidget->item(index,3)->text();
- bool enabled = _services->value(index).enabled();
- Service temp(address, virtualPort, physicalAddress, directoryPath,
- enabled);
- temp.setAdditionalServiceOptions(
- _services->value(ui.serviceWidget->currentRow()).additionalServiceOptions());
- serviceList.push_back(temp);
- if(enabled) {
- publishedServices.push_back(temp);
- }
- index++;
- }
-
- bool save = checkBeforeSaving(serviceList);
- if(save) {
- ServiceList sList;
- if(serviceList.size() > 0) {
- sList.setServices(serviceList);
- } else {
- _services = new QMap<int, Service>();
- sList.setServices(_services->values());
- }
- serviceSettings.setServices(sList);
- if(publishedServices.size() > 0) {
- startServicesInTor(publishedServices);
- } else {
- QString errmsg1 = tr("Error while trying to unpublish all services");
- QString &errmsg = errmsg1;
- serviceSettings.unpublishAllServices(&errmsg);
- }
- return true;
- } else {
- errmsg = tr("Please configure at least a service directory and a virtual "
- "port for each service you want to save. Remove the other ones.");
- return false;
- }
-}
-
-/** this method checks if either all services have minimal
- * configuration or not */
-bool
-ServicePage::checkBeforeSaving(QList<Service> serviceList)
-{
- bool result = true;
- foreach(Service s, serviceList) {
- if(s.serviceDirectory().isEmpty() || s.virtualPort().isEmpty()) {
- result = false;
- break;
- }
- }
- return result;
-}
-
-/** this method generates the configuration string for a list of services */
-void
-ServicePage::startServicesInTor(QList<Service> services)
-{
- ServiceSettings serviceSettings(Vidalia::torControl());
- QString serviceConfString;
- QString errmsg = "Error while trying to publish services.";
- QListIterator<Service> it(services);
-
- while(it.hasNext()) {
- Service temp = it.next();
- serviceConfString.append("hiddenservicedir=" +
- string_escape(temp.serviceDirectory()) + " ");
- serviceConfString.append("hiddenserviceport=" +
- string_escape(temp.virtualPort() +
- (temp.physicalAddressPort().isEmpty() ? "" : " " +
- temp.physicalAddressPort())));
- serviceConfString.append(" " + temp.additionalServiceOptions());
- }
- serviceSettings.applyServices(serviceConfString, &errmsg);
-}
-
-/** Loads previously saved settings */
-void
-ServicePage::load()
-{
- ServiceSettings serviceSettings(Vidalia::torControl());
- QList<Service> torServiceList;
-
- ui.removeButton->setEnabled(false);
- ui.copyButton->setEnabled(false);
- ui.browseButton->setEnabled(false);
- // get all services
- _services->clear();
- _torServices->clear();
-
- QString torConfigurationString = serviceSettings.getHiddenServiceDirectories();
- torServiceList = extractSingleServices(torConfigurationString);
- QList<Service> completeList = torServiceList;
- // the services stored with vidalia
- ServiceList serviceList = serviceSettings.getServices();
- QList<Service> serviceSettingsList = serviceList.services();
- QListIterator<Service> it(serviceSettingsList);
- // check whether a service is already in the list because he is published
- while(it.hasNext()) {
- Service temp = it.next();
- if(isServicePublished(temp, torServiceList) == false) {
- completeList.push_back(temp);
- }
- }
- // generate the _services data structure used during vidalia session
- QListIterator<Service> it2(completeList);
- int index = 0;
- while (it2.hasNext()) {
- Service tempService = it2.next();
- _services->insert(index, tempService);
- index++;
- }
- initServiceTable(_services);
-}
-
-/** this method returns a list of services by parsing the configuration
- * string given by the tor controller */
-QList<Service>
-ServicePage::extractSingleServices(QString conf)
-{
- QList<Service> list;
- QStringList strList = conf.split("250 HiddenServiceDir");
- strList.removeFirst();
- QListIterator<QString> it(strList);
- //for each service directory splitted string = service
- while(it.hasNext()) {
- QString temp = it.next();
- list.push_back(generateService(temp));
- }
- return list;
-}
-
-/** this return a Service by parseing the configuration string
- * of Tor and storeing its values into the object */
-Service
-ServicePage::generateService(QString s)
-{
- QString additionalOptions = s;
- // remove directory
- int index = additionalOptions.indexOf("250",1);
- additionalOptions.remove(0, index+4);
- // remove the first appearance of the port
- int startindex = additionalOptions.indexOf("hiddenserviceport", 0,
- Qt::CaseInsensitive);
- int endindex = additionalOptions.indexOf("250", startindex);
- if(endindex != -1) {
- additionalOptions.remove(startindex, (endindex-startindex)+4);
- //remove all appearances of "250"
- while(additionalOptions.contains("250")) {
- int i = additionalOptions.indexOf("250", 0);
- additionalOptions.remove(i, 4);
- }
- // prepare for correct quotation
- if (!additionalOptions.endsWith('\n')) {
- additionalOptions.append("\n");
- }
- //quote the values
- int j = additionalOptions.indexOf("=", 0);
- while(j != -1) {
- additionalOptions.insert(j+1, "\"");
- int end = additionalOptions.indexOf("\n", j);
- additionalOptions.insert(end, "\"");
- j = additionalOptions.indexOf("=", end);
- }
- //replace the line brakes with a space and create one single line
- additionalOptions.replace(QString("\n"), QString(" "));
- } else {
- additionalOptions = "";
- }
-
- QString address, virtualPort, physAddressPort, serviceDir;
- // service directory
- QStringList strList = s.split("\n");
- QString tempServiceDir = strList.first().trimmed();
- serviceDir = tempServiceDir.remove(0, 1);
- //virtual port
- QStringList strList2 = s.split("HiddenServicePort");
- strList2.removeFirst();
- QStringList strList3 = strList2.first().split("\n");
- QStringList strList4 = strList3.first().split(" ");
- if(strList4.size() > 0) {
- QString tempVirtualPort = strList4.first();
- virtualPort = tempVirtualPort.remove(0, 1);
- strList4.removeFirst();
- //physical address:port
- if(!strList4.isEmpty()) {
- physAddressPort = strList4.first().trimmed();
- }
- } else {
- QString tempVirtualPort = strList3.first();
- virtualPort = tempVirtualPort.remove(0, 1);
- }
- //get .onion address
- QString serviceHostnameDir = serviceDir;
- serviceHostnameDir.append("/");
- serviceHostnameDir.append("hostname");
- QFile file(serviceHostnameDir);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- address = "[Directory not found]";
- } else {
- QTextStream in(&file);
- QString hostname;
- while (!in.atEnd()) {
- hostname.append(in.readLine());
- }
- address = hostname;
- }
- Service service(address, virtualPort, physAddressPort, serviceDir, true);
- service.setAdditionalServiceOptions(additionalOptions);
- _torServices->insert(serviceDir, service);
- return service;
-}
-
-/** this method checks either a service is published or not */
-bool
-ServicePage::isServicePublished(Service service, QList<Service> torServices)
-{
- QListIterator<Service> it(torServices);
- while(it.hasNext()) {
- Service temp = it.next();
- if(temp.serviceDirectory().compare(service.serviceDirectory()) == 0) {
- return true;
- }
- }
- return false;
-}
-
-/** this method creates/displays the values for each service
- * shown in the service listing */
-void
-ServicePage::initServiceTable(QMap<int, Service>* services)
-{
- // clean the widget
- int rows = ui.serviceWidget->rowCount();
- for(int i = 0; i < rows; i++) {
- ui.serviceWidget->removeRow(0);
- }
- //for each service
- int index = 0;
- while(index < services->size()) {
- Service tempService = services->value(index);
- ui.serviceWidget->insertRow(index);
- QTableWidgetItem *cboxitem = new QTableWidgetItem();
- cboxitem->setFlags(Qt::ItemIsSelectable);
- QTableWidgetItem *addressitem = new QTableWidgetItem();
- addressitem->setFlags(Qt::ItemIsSelectable);
- if(tempService.serviceAddress().length() < 0) {
- addressitem->setText(tempService.serviceAddress());
- } else {
- QString serviceHostnameDir = tempService.serviceDirectory();
- serviceHostnameDir.append("/");
- serviceHostnameDir.append("hostname");
- QFile file(serviceHostnameDir);
- if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- addressitem->setText("[Directory not found]");
- } else {
- QTextStream in(&file);
- QString hostname;
- while (!in.atEnd()) {
- hostname.append(in.readLine());
- }
- addressitem->setText(hostname);
- tempService.setServiceAddress(hostname);
- }
- }
- addressitem->setData(32, addressitem->text());
- QTableWidgetItem *serviceDir =
- new QTableWidgetItem(tempService.serviceDirectory(), 0);
- serviceDir->setData(32, tempService.serviceDirectory());
- QTableWidgetItem* virtualportitem =
- new QTableWidgetItem(tempService.virtualPort(), 0);
- virtualportitem->setData(32, tempService.virtualPort());
- QTableWidgetItem* targetitem =
- new QTableWidgetItem(tempService.physicalAddressPort(),0);
- targetitem->setData(32, tempService.physicalAddressPort());
- if(tempService.enabled()) {
- cboxitem->setCheckState(Qt::Checked);
- serviceDir->setFlags(Qt::ItemIsSelectable);
- } else {
- cboxitem->setCheckState(Qt::Unchecked);
- }
- cboxitem->setTextAlignment(Qt::AlignCenter);
- ui.serviceWidget->setItem(index, 0, addressitem);
- ui.serviceWidget->setItem(index, 1, virtualportitem);
- ui.serviceWidget->setItem(index, 2, targetitem);
- ui.serviceWidget->setItem(index, 3, serviceDir);
- ui.serviceWidget->setItem(index, 4, cboxitem);
- index++;
- }
-}
-
-/** this method is called when the user clicks the "Add"-Button
- * it generates a new empty table entrie(row) */
-void
-ServicePage::addService()
-{
- int rows = ui.serviceWidget->rowCount();
- ui.serviceWidget->insertRow(rows);
- QTableWidgetItem *address = new QTableWidgetItem("["+tr("Created by Tor")+"]");
- address->setFlags(Qt::ItemIsSelectable);
- QTableWidgetItem *dummy = new QTableWidgetItem();
- QTableWidgetItem *dummy2 = new QTableWidgetItem();
- QTableWidgetItem *dummy3 = new QTableWidgetItem();
- QTableWidgetItem *cboxitem = new QTableWidgetItem();
- cboxitem->setFlags(Qt::ItemIsSelectable);
- cboxitem->setCheckState(Qt::Checked);
- ui.serviceWidget->setItem(rows, 0, address);
- ui.serviceWidget->setItem(rows, 1, dummy);
- ui.serviceWidget->setItem(rows, 2, dummy2);
- ui.serviceWidget->setItem(rows, 3, dummy3);
- ui.serviceWidget->setItem(rows, 4, cboxitem);
- Service s;
- s.setEnabled(true);
- _services->insert(rows, s);
-}
-
-/** this method is called when the user clicks the "Remove"-Button
- * it removes a service/row of the service listing */
-void
-ServicePage::removeService()
-{
- int rows = ui.serviceWidget->rowCount();
- int selrow = ui.serviceWidget->currentRow();
- if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
- VMessageBox::Ok);
- return;
- } else {
- ui.serviceWidget->removeRow(selrow);
- //decrease all other service keys
- for(int i = 0; i < (rows-selrow-1); i++) {
- int index = i+selrow;
- Service s = _services->take(index+1);
- _services->insert(index, s);
- }
- }
- serviceSelectionChanged();
-}
-
-/** this method is called when the user clicks on the "Copy"-Button, it
- * copies the .onion-Address of the selected service into the clipboard */
-void
-ServicePage::copyToClipboard()
-{
- int selrow = ui.serviceWidget->currentRow();
- if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
- VMessageBox::Ok);
- return;
- } else {
- QString onionAddress = ui.serviceWidget->item(selrow,0)->text();
- QClipboard *clipboard = QApplication::clipboard();
- QString clipboardText;
- QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0);
- clipboardText.append(selectedItem->text());
- clipboard->setText(clipboardText);
- }
-}
-
-/** this method is called when the user clicks on the "Brows"-Button it opens
- * a QFileDialog to choose a service directory */
-void
-ServicePage::browseDirectory()
-{
- int selrow = ui.serviceWidget->currentRow();
- if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
- VMessageBox::Ok);
- return;
- } else {
- QString dirname =
- QFileDialog::getExistingDirectory(this,
- tr("Select Service Directory"), "",
- QFileDialog::ShowDirsOnly
- | QFileDialog::DontResolveSymlinks);
-
- if (dirname.isEmpty()) {
- return;
- }
- ui.serviceWidget->item(selrow,3)->setText(dirname);
- Service s = _services->take(selrow);
- s.setServiceDirectory(dirname);
- _services->insert(selrow, s);
- }
-}
-
-/** this method is called when the selects an other tablewidgetitem */
-void
-ServicePage::serviceSelectionChanged()
-{
- bool emptyTable = false;
- if(ui.serviceWidget->rowCount() > 0) {
- ui.removeButton->setEnabled(true);
- ui.copyButton->setEnabled(true);
- ui.browseButton->setEnabled(true);
- } else {
- ui.removeButton->setEnabled(false);
- ui.copyButton->setEnabled(false);
- ui.browseButton->setEnabled(false);
- emptyTable = true;
- }
- int currentRow = ui.serviceWidget->currentRow();
- if(emptyTable == false) {
- QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0);
- if(item != NULL) {
- bool b = item->text().contains(".onion");
- ui.copyButton->setEnabled(b);
- }
- }
-
- QString selDir = _services->value(ui.serviceWidget->currentRow()).
- serviceDirectory();
- QList<QString> strList = _torServices->keys();
- if(selDir.length() > 0) {
- QListIterator<QString> it(strList);
- while(it.hasNext()) {
- QString temp = it.next();
- if(selDir.compare(temp) == 0) {
- ui.browseButton->setEnabled(false);
- break;
- }
- }
- }
- // if the user has clicked on the checkbox cell
- if(ui.serviceWidget->currentColumn() == 4) {
- Service service = _services->take(currentRow);
- QTableWidgetItem* item = ui.serviceWidget->item(currentRow,4);
- if(service.enabled()) {
- item->setCheckState(Qt::Unchecked);
- service.setEnabled(false);
- } else {
- item->setCheckState(Qt::Checked);
- service.setEnabled(true);
- }
- _services->insert(currentRow, service);
- }
-}
-
-/** this method is called when the user finished editing a cell and it provides
- * that only valid values are set */
-void
-ServicePage::valueChanged()
-{
- int pos = 0;
- QIntValidator* portValidator = new QIntValidator(1, 65535, this);
- DomainValidator* domainValidator = new DomainValidator(this);
- IpValidator* ipValidator = new IpValidator(this);
- QTableWidgetItem* item = ui.serviceWidget->currentItem();
- if (item == NULL || item->text() == NULL || item->text().length() == 0) {
- // nothing to validate here
- return;
- }
- QString text = item->text();
- switch (item->column()) {
- case 1: // virtual port
- if(portValidator->validate(text, pos) == QValidator::Acceptable) {
- // correct data; buffer value in user role 32
- item->setData(32, text);
- } else {
- //incorrect data; restore value from user role 32
- VMessageBox::warning(this, tr("Error"),
- tr("Virtual Port may only contain valid port numbers [1..65535]."),
- VMessageBox::Ok);
- item->setText(item->data(32).toString());
- }
- break;
- case 2: // target
- if(text.contains(":")) {
- // check for <address>:<port>
- QStringList strList = text.split(":");
- if (strList.size() != 2) {
- goto invalid;
- }
- QString address = strList.at(0);
- QString port = strList.at(1);
- if((address.compare("localhost") != 0 &&
- ipValidator->validate(address, pos) != QValidator::Acceptable &&
- domainValidator->validate(address, pos) != QValidator::Acceptable) ||
- portValidator->validate(port, pos) != QValidator::Acceptable) {
- goto invalid;
- }
- } else { // either <address> or <port>
- if (text.compare("localhost") != 0 &&
- ipValidator->validate(text, pos) != QValidator::Acceptable &&
- domainValidator->validate(text, pos) != QValidator::Acceptable &&
- portValidator->validate(text, pos) != QValidator::Acceptable) {
- goto invalid;
- }
- }
- goto valid;
- invalid:
- VMessageBox::warning(this, tr("Error"),
- tr("Target may only contain address:port, address, or port."),
- VMessageBox::Ok);
- item->setText(item->data(32).toString());
- break;
- valid:
- item->setData(32, text);
- break;
- case 3: // service directory
- // compare with directories of other enabled services
- for (int index = 0; index < ui.serviceWidget->rowCount(); index++) {
- // skip own row
- if(index == item->row()) {
- continue;
- }
- QTableWidgetItem* compareWith = ui.serviceWidget->item(index, 3);
- if(compareWith != NULL) {
- QString actualDir = compareWith->text();
- if(actualDir.length() > 0 && text.compare(actualDir) == 0) {
- // service directory already in use
- VMessageBox::warning(this, tr("Error"),
- tr("Directory already in use by another service."),
- VMessageBox::Ok);
- item->setText(item->data(32).toString());
- return;
- }
- }
- }
- // correct data; buffer value in user role 32
- item->setData(32, text);
- break;
- }
-}
-
diff --git a/src/vidalia/config/ServicePage.h b/src/vidalia/config/ServicePage.h
deleted file mode 100644
index 622673f..0000000
--- a/src/vidalia/config/ServicePage.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#ifndef _SERVICEPAGE_H
-#define _SERVICEPAGE_H
-
-#include "ui_ServicePage.h"
-#include "ConfigPage.h"
-#include "TorSettings.h"
-#include "ServiceSettings.h"
-#include "ExitPolicy.h"
-
-#include "TorControl.h"
-
-
-class ServicePage : public ConfigPage
-{
- Q_OBJECT
-
-public:
- /** Default Constructor */
- ServicePage(QWidget *parent = 0);
- /** Default Destructor */
- ~ServicePage();
- /** Saves the changes on this page */
- bool save(QString &errmsg);
- /** Loads the settings for this page */
- void load();
- /** Initialize the service table */
- void initServiceTable(QMap<int, Service>* _services);
- /** Called when the user changes the UI translation. */
- virtual void retranslateUi();
-
-private slots:
- /** Called whenever the user clicks on the 'add' button. */
- void addService();
- /** Called whenever the user clicks on the 'remove' button. */
- void removeService();
- /** Called whenever the user clicks on the 'copy' button. */
- void copyToClipboard();
- /** Called whenever the user clicks on the 'browse' button. */
- void browseDirectory();
- /** Called whenever the user selects a different service. */
- void serviceSelectionChanged();
- /** Returns a list of services by parsing the configuration string given
- * by the Tor controller. */
- QList<Service> extractSingleServices(QString conf);
- /** Returns a Service by parsing the configuration string from Tor and
- * storing its values into the Service object. */
- Service generateService(QString serviceString);
- /** Starts all services in <b>services</b>, with Tor. */
- void startServicesInTor(QList<Service> services);
- /** Returns true if <b>service</b> is published. */
- bool isServicePublished(Service service, QList<Service> torServices);
- /** Returns true if all services have the required minimal configuration. */
- bool checkBeforeSaving(QList<Service> services);
- /** Called when the user finished editing a cell and checks that only valid
- * values are set. */
- void valueChanged();
-
-private:
- /** A QMap, mapping from the row number in the table to the service Entity */
- QMap<int, Service>* _services;
- /** A QList, consisting of all running services before vidalia starts */
- QMap<QString, Service>* _torServices;
-
- /** Qt Designer generated object */
- Ui::ServicePage ui;
-};
-
-#endif
-
diff --git a/src/vidalia/config/ServicePage.ui b/src/vidalia/config/ServicePage.ui
deleted file mode 100644
index 8fc6c57..0000000
--- a/src/vidalia/config/ServicePage.ui
+++ /dev/null
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ServicePage</class>
- <widget class="QWidget" name="ServicePage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>600</width>
- <height>400</height>
- </rect>
- </property>
- <property name="minimumSize">
- <size>
- <width>600</width>
- <height>400</height>
- </size>
- </property>
- <property name="windowTitle">
- <string notr="true"/>
- </property>
- <layout class="QVBoxLayout">
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="title">
- <string>Provided Hidden Services</string>
- </property>
- <layout class="QGridLayout">
- <item row="0" column="0" rowspan="5">
- <widget class="QTableWidget" name="serviceWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="textElideMode">
- <enum>Qt::ElideLeft</enum>
- </property>
- <property name="showGrid">
- <bool>true</bool>
- </property>
- <column>
- <property name="text">
- <string>Onion Address</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Virtual Port</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Target</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Directory Path</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Enabled</string>
- </property>
- </column>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QToolButton" name="addButton">
- <property name="toolTip">
- <string>Add new service to list</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/list-add.png</normaloff>:/images/22x22/list-add.png</iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="removeButton">
- <property name="toolTip">
- <string>Remove selected service from list</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/list-remove.png</normaloff>:/images/22x22/list-remove.png</iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QToolButton" name="copyButton">
- <property name="toolTip">
- <string>Copy onion address of selected service to clipboard</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/edit-copy.png</normaloff>:/images/22x22/edit-copy.png</iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QToolButton" name="browseButton">
- <property name="toolTip">
- <string>Browse in local file system and choose directory for selected service</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset resource="../res/vidalia.qrc">
- <normaloff>:/images/22x22/folder.png</normaloff>:/images/22x22/folder.png</iconset>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>21</width>
- <height>46</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>141</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../res/vidalia.qrc"/>
- </resources>
- <connections/>
-</ui>
diff --git a/src/vidalia/config/ServiceSettings.cpp b/src/vidalia/config/ServiceSettings.cpp
deleted file mode 100644
index 3c6fa91..0000000
--- a/src/vidalia/config/ServiceSettings.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#include "ServiceSettings.h"
-#include "TorSettings.h"
-
-#include "stringutil.h"
-
-/* Service Settings */
-#define SETTING_SERVICE_VIRTUAL_PORT "Service/VirtualPort"
-#define SETTING_SERVICE_ADDRESS "Service/ServiceAddress"
-#define SETTING_SERVICE_PHYSICAL_ADDRESS "Service/ServicePhysicalAddress"
-#define SETTING_SERVICE_ENABLED "Service/Enabled"
-#define SETTING_TOR_SERVICES "Service/Services"
-
-/** Constructor.
- * \param torControl a TorControl object used to read and apply the Service
- * configuration settings.
- */
-ServiceSettings::ServiceSettings(TorControl *torControl)
-{
- _torControl = torControl;
- setDefault(SETTING_SERVICE_VIRTUAL_PORT , 0);
- setDefault(SETTING_SERVICE_PHYSICAL_ADDRESS, "127.0.0.1:0");
- setDefault(SETTING_SERVICE_ENABLED, "true");
-}
-
-/** Set ServiceList to serialise it */
-void
-ServiceSettings::setServices(ServiceList service)
-{
- QStringList serviceList;
- if(service.services().size() > 0) {
- QList<Service> services = service.services();
- foreach (Service tempService, services) {
- serviceList << tempService.toString();
- }
- }
- setValue(SETTING_TOR_SERVICES, serviceList);
-}
-
-/** Get serialised ServiceList */
-ServiceList
-ServiceSettings::getServices()
-{
- QString address,virtualPort,physAddrPort,serviceDir,enabledS,additionalData;
- bool enabled = false;
- QStringList stringList;
- ServiceList services;
-
- stringList = value(SETTING_TOR_SERVICES).toStringList();
- foreach (QString s, stringList) {
- QStringList skippedList = s.split("#");
- address = skippedList.first();
- skippedList.removeFirst();
- virtualPort = skippedList.first();
- skippedList.removeFirst();
- physAddrPort = skippedList.first();
- skippedList.removeFirst();
- serviceDir = skippedList.first();
- skippedList.removeFirst();
- enabledS = skippedList.first();
- skippedList.removeFirst();
- additionalData = skippedList.first();
- if(enabledS.compare("x1") == 0) {
- enabled = true;
- }
- Service service(address, virtualPort, physAddrPort, serviceDir, enabled);
- service.setAdditionalServiceOptions(additionalData);
- services.addService(service);
- }
- return services;
-}
-
-/** Returns the virtual port for a specific service*/
-QString
-ServiceSettings::getVirtualPort()
-{
- QString port = value(SETTING_SERVICE_VIRTUAL_PORT).toString();
- return port;
-}
-
-/** Set the virtual port for a specific service*/
-void
-ServiceSettings::setVirtualPort(QString servicePort)
-{
- setValue(SETTING_SERVICE_VIRTUAL_PORT, servicePort);
-}
-
-/** Returns the .onion - service address for a specific service */
-QString
-ServiceSettings::getServiceAddress()
-{
- QString addr = value(SETTING_SERVICE_ADDRESS).toString();
- return addr;
-}
-
-/** Set the .onion - service address or hostname for a specific service */
-void
-ServiceSettings::setServiceAddress(QString addr)
-{
- setValue(SETTING_SERVICE_ADDRESS, addr);
-}
-
-/** Returns the physical address for a specific service */
-QString
-ServiceSettings::getPhysicalAddressPort()
-{
- QString addr = value(SETTING_SERVICE_PHYSICAL_ADDRESS).toString();
- return addr;
-}
-
-/** Set the physical address or hostname for a specific service */
-void
-ServiceSettings::setPhysicalAddressPort(QString addr)
-{
- setValue(SETTING_SERVICE_PHYSICAL_ADDRESS, addr);
-}
-
-/** Returns if the Service is enabled */
-bool
-ServiceSettings::isEnabled()
-{
- return value(SETTING_SERVICE_ENABLED).toBool();
-}
-
-/** Set the service enabled */
-void
-ServiceSettings::setEnabled(bool boolean)
-{
- setValue(SETTING_SERVICE_ENABLED, boolean);
-}
-
-/** Get all service directories from Tor */
-QString
-ServiceSettings::getHiddenServiceDirectories()
-{
- /*XXX: Domenik: Why does this always try to getconf hiddenserviceoptions
- * even if the socket is not connected? */
- QString value = _torControl->getHiddenServiceConf("hiddenserviceoptions");
- return value;
-}
-
-/** Set all services the user wants to start and send it to the
- * Tor Controller*/
-void
-ServiceSettings::applyServices(QString value, QString *errmsg)
-{
- _torControl->setConf(value, errmsg);
- _torControl->saveConf(errmsg);
-}
-
-/** Unpublish all HiddenServices */
-void
-ServiceSettings::unpublishAllServices(QString *errmsg)
-{
- _torControl->resetConf("HiddenServiceDir", errmsg);
- _torControl->saveConf(errmsg);
-}
-
diff --git a/src/vidalia/config/ServiceSettings.h b/src/vidalia/config/ServiceSettings.h
deleted file mode 100644
index 946dc62..0000000
--- a/src/vidalia/config/ServiceSettings.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-** This file is part of Vidalia, and is subject to the license terms in the
-** LICENSE file, found in the top level directory of this distribution. If you
-** did not receive the LICENSE file with this file, you may obtain it from the
-** Vidalia source package distributed by the Vidalia Project at
-** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
-** including this file, may be copied, modified, propagated, or distributed
-** except according to the terms described in the LICENSE file.
-*/
-
-#ifndef _SERVICESETTINGS_H
-#define _SERVICESETTINGS_H
-
-#include <TorControl.h>
-#include <ServiceList.h>
-#include <VidaliaSettings.h>
-#include <ExitPolicy.h>
-
-
-/* XXX: Domenik: Shouldn't this inherit AbstractTorSettings like the rest of
- * the settings classes? */
-class ServiceSettings : private VidaliaSettings
-{
-public:
- /** Constructor */
- ServiceSettings(TorControl *torControl);
- /** Returns the service port for a specific service*/
- QString getVirtualPort();
- /** Set the service port for a specific service*/
- void setVirtualPort(QString servicePort);
- /** Returns the .onion - service address for a specific service */
- QString getServiceAddress();
- /** Set the .onion - service address for a specific service */
- void setServiceAddress(QString serviceAddress);
- /** Returns the service address or hostname for a specific service */
- QString getPhysicalAddressPort();
- /** Set the service address or hostname for a specific service */
- void setPhysicalAddressPort(QString physicalAddress);
- /** Returns if the Service is enabled */
- bool isEnabled();
- /** Set the service enabled */
- void setEnabled(bool enabled);
- /** Returns a ServiceList containing all services */
- ServiceList getServices();
- /** Set ServiceList to serialise it */
- void setServices(ServiceList services);
- /** Get Service Directories */
- QString getHiddenServiceDirectories();
- /** Set all services the user wants to start and send it to the
- * Tor Controller */
- void applyServices(QString value, QString *errmsg);
- /** Unpublish all services */
- void unpublishAllServices(QString *errmsg);
-
-private:
- /** A TorControl object used to talk to Tor. */
- TorControl* _torControl;
-};
-
-#endif
-
1
0

05 Mar '12
commit f207eae3bf56a7c462190355089a23c74a5f846f
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 22:09:14 2012 -0300
Add volatile value handling to VSettings
---
src/vidalia/config/VSettings.cpp | 14 ++++++++++++++
src/vidalia/config/VSettings.h | 9 ++++++++-
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/src/vidalia/config/VSettings.cpp b/src/vidalia/config/VSettings.cpp
index aab0f9b..ca8cdd4 100644
--- a/src/vidalia/config/VSettings.cpp
+++ b/src/vidalia/config/VSettings.cpp
@@ -103,3 +103,17 @@ VSettings::allSettings() const
return settings;
}
+QVariant
+VSettings::volatileValue(const QString &key,
+ const QVariant &defaultVal)
+{
+ if(_volatileSettings.count(key) == 0)
+ return defaultVal;
+ return _volatileSettings.value(key);
+}
+
+void
+VSettings::setVolatileValue(const QString &key, const QVariant &val)
+{
+ _volatileSettings.insert(key, val);
+}
diff --git a/src/vidalia/config/VSettings.h b/src/vidalia/config/VSettings.h
index ed31255..50357fc 100644
--- a/src/vidalia/config/VSettings.h
+++ b/src/vidalia/config/VSettings.h
@@ -57,9 +57,16 @@ protected:
* point. */
QMap<QString, QVariant> allSettings() const;
+ virtual QVariant volatileValue(const QString &key,
+ const QVariant &defaultVal = QVariant());
+ virtual void setVolatileValue(const QString &key, const QVariant &val);
+
private:
/** Association of setting key names to default setting values. */
- QHash<QString, QVariant> _defaults;
+ QHash<QString, QVariant> _defaults;
+
+ /** Stores values that last as long as Vidalia lives as a process */
+ QMap<QString, QVariant> _volatileSettings;
};
#endif
1
0

05 Mar '12
commit e02be82611aadb48a6ed4d37c9eace40f26bbc0c
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 22:09:55 2012 -0300
Handle volatiles from the AbstractTorSettings
---
src/vidalia/config/AbstractTorSettings.cpp | 10 ++++++++++
src/vidalia/config/AbstractTorSettings.h | 6 ++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/vidalia/config/AbstractTorSettings.cpp b/src/vidalia/config/AbstractTorSettings.cpp
index 5f1b8aa..e1941f9 100644
--- a/src/vidalia/config/AbstractTorSettings.cpp
+++ b/src/vidalia/config/AbstractTorSettings.cpp
@@ -128,3 +128,13 @@ AbstractTorSettings::setValue(const QString &key, const QVariant &value)
}
}
+/** Saves the value <b>val</b> for the setting <b>key</b> to the local
+ * settings file. */
+void
+AbstractTorSettings::setVolatileValue(const QString &key, const QVariant &value)
+{
+ if (value != volatileValue(key)) {
+ setChanged(true);
+ VSettings::setVolatileValue(key, value);
+ }
+}
diff --git a/src/vidalia/config/AbstractTorSettings.h b/src/vidalia/config/AbstractTorSettings.h
index 4c5d1b7..676d01a 100644
--- a/src/vidalia/config/AbstractTorSettings.h
+++ b/src/vidalia/config/AbstractTorSettings.h
@@ -19,6 +19,10 @@
#include "VSettings.h"
#include "TorControl.h"
+#define with_torrc_value(VAL) \
+ QStringList ret = Vidalia::torrc()->value((VAL)); \
+ if(ret.size() > 0)
+
class AbstractTorSettings : public VSettings
{
Q_OBJECT
@@ -55,6 +59,8 @@ protected:
/** Saves the value <b>val</b> for the setting <b>key</b> to the local
* settings file. */
virtual void setValue(const QString &key, const QVariant &value);
+
+ virtual void setVolatileValue(const QString &key, const QVariant &value);
/** Returns true if the given QVariant contains an empty value, depending on
* the data type. For example, 0 is considered an empty integer and "" is
1
0
commit 498a5416a2bc819774617d5021466dd8116b6bb2
Author: Tomás Touceda <chiiph(a)torproject.org>
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;
1
0

05 Mar '12
commit fa3f968392247de08fbc99e3cc20107c38e25d9a
Author: Tomás Touceda <chiiph(a)torproject.org>
Date: Fri Feb 3 22:16:26 2012 -0300
Migrate TorSettings to the new structure
---
src/vidalia/config/TorSettings.cpp | 131 ++++++++++++++++++++++--------------
src/vidalia/config/TorSettings.h | 2 +-
2 files changed, 81 insertions(+), 52 deletions(-)
diff --git a/src/vidalia/config/TorSettings.cpp b/src/vidalia/config/TorSettings.cpp
index 9fa5369..85164d0 100644
--- a/src/vidalia/config/TorSettings.cpp
+++ b/src/vidalia/config/TorSettings.cpp
@@ -29,8 +29,8 @@
/* Tor Settings */
#define SETTING_TOR_EXECUTABLE "TorExecutable"
#define SETTING_TORRC "Torrc"
-#define SETTING_CONTROL_ADDR "ControlAddr"
#define SETTING_DEFAULTS_TORRC "DefaultsTorrc"
+#define SETTING_CONTROL_ADDR "ControlListenAddress"
#define SETTING_CONTROL_PORT "ControlPort"
#define SETTING_SOCKET_PATH "ControlSocket"
#define SETTING_CONTROL_METHOD "ControlMethod"
@@ -61,6 +61,7 @@
#define TOR_ARG_HASHED_PASSWORD "HashedControlPassword"
#define TOR_ARG_COOKIE_AUTH "CookieAuthentication"
#define TOR_ARG_SOCKSPORT "SocksPort"
+#define TOR_ARG_CONTROLFILE "ControlPortWriteToFile"
/** Generate random control passwords of 16 characters */
#define PASSWORD_LEN 16
@@ -91,35 +92,51 @@ TorSettings::TorSettings(TorControl *torControl)
setDefault(SETTING_DATA_DIRECTORY, "");
setDefault(SETTING_CONTROL_PASSWORD, "");
setDefault(SETTING_USE_RANDOM_PASSWORD, true);
- 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, "");
- setDefault(SETTING_AUTOCONTROL, true);
+ setDefault(SETTING_AUTOCONTROL, false);
}
/** Applies any changes to Tor's control port or authentication settings. */
bool
TorSettings::apply(QString *errmsg)
{
- QHash<QString, QString> conf;
- QString hashedPassword;
-
- conf.insert(SETTING_CONTROL_PORT,
- localValue(SETTING_CONTROL_PORT).toString());
-
- if(localValue(SETTING_AUTOCONTROL).toBool())
- conf.insert(TOR_ARG_SOCKSPORT, "auto");
- else
- conf.insert(TOR_ARG_SOCKSPORT, "9050");
+ Torrc *torrc = Vidalia::torrc();
+ torrc->setValue(SETTING_CONTROL_PORT,
+ QString::number(volatileValue(SETTING_CONTROL_PORT).toInt()));
+
+ torrc->clear(QStringList()
+ << TOR_ARG_SOCKSPORT
+ << SETTING_CONTROL_PORT);
+
+ torrc->setValue(SETTING_DATA_DIRECTORY, volatileValue(SETTING_DATA_DIRECTORY).toString());
+
+ if(volatileValue(SETTING_AUTOCONTROL).toBool()) {
+ torrc->setValue(SETTING_CONTROL_PORT, "auto");
+ torrc->setValue(TOR_ARG_SOCKSPORT, "auto");
+ torrc->setValue(TOR_ARG_CONTROLFILE, QString("%1/port.conf").arg(getDataDirectory()));
+ } else {
+ QString socks = "9050", control = "9051";
+ {
+ with_torrc_value(TOR_ARG_SOCKSPORT)
+ socks = ret.at(0);
+ }
+ {
+ with_torrc_value(TOR_ARG_SOCKSPORT)
+ control = ret.at(0);
+ }
+ torrc->setValue(TOR_ARG_SOCKSPORT, socks);
+ torrc->setValue(SETTING_CONTROL_PORT, control);
+ }
+
+ QString hashedPassword;
AuthenticationMethod authMethod =
toAuthenticationMethod(localValue(SETTING_AUTH_METHOD).toString());
switch (authMethod) {
case CookieAuth:
- conf.insert(TOR_ARG_COOKIE_AUTH, "1");
- conf.insert(TOR_ARG_HASHED_PASSWORD, "");
+ torrc->setValue(TOR_ARG_COOKIE_AUTH, "1");
+ torrc->setValue(TOR_ARG_HASHED_PASSWORD, "");
break;
case PasswordAuth:
hashedPassword = useRandomPassword()
@@ -130,34 +147,33 @@ TorSettings::apply(QString *errmsg)
*errmsg = tr("Failed to hash the control password.");
return false;
}
- conf.insert(TOR_ARG_COOKIE_AUTH, "0");
- conf.insert(TOR_ARG_HASHED_PASSWORD, hashedPassword);
+ torrc->setValue(TOR_ARG_COOKIE_AUTH, "0");
+ if(not useRandomPassword())
+ torrc->setValue(TOR_ARG_HASHED_PASSWORD, hashedPassword);
break;
default:
- conf.insert(TOR_ARG_COOKIE_AUTH, "0");
- conf.insert(TOR_ARG_HASHED_PASSWORD, "");
+ torrc->setValue(TOR_ARG_COOKIE_AUTH, "0");
+ torrc->setValue(TOR_ARG_HASHED_PASSWORD, "");
}
- conf.insert(SETTING_WARN_PLAINTEXT_PORTS,
- localValue(SETTING_WARN_PLAINTEXT_PORTS).toStringList().join(","));
- conf.insert(SETTING_REJECT_PLAINTEXT_PORTS,
- localValue(SETTING_REJECT_PLAINTEXT_PORTS).toStringList().join(","));
-
- return torControl()->setConf(conf, errmsg);
+ return torrc->apply(Vidalia::torControl(), errmsg);
}
/** Gets the location of Tor's data directory. */
QString
-TorSettings::getDataDirectory() const
+TorSettings::getDataDirectory()
{
- return QDir::convertSeparators(value(SETTING_DATA_DIRECTORY).toString());
+ with_torrc_value(SETTING_DATA_DIRECTORY) {
+ return ret.at(0);
+ }
+ return QDir::convertSeparators(volatileValue(SETTING_DATA_DIRECTORY).toString());
}
/** Sets the location to use as Tor's data directory. */
void
TorSettings::setDataDirectory(const QString &dataDirectory)
{
- setValue(SETTING_DATA_DIRECTORY, dataDirectory);
+ setVolatileValue(SETTING_DATA_DIRECTORY, dataDirectory);
}
/** Returns a fully-qualified path to Tor's executable, including the
@@ -222,7 +238,10 @@ TorSettings::setDefaultsTorrc(const QString &torrc)
QHostAddress
TorSettings::getControlAddress() const
{
- QString addr = localValue(SETTING_CONTROL_ADDR).toString();
+ QString addr = defaultValue(SETTING_CONTROL_ADDR).toString();
+ with_torrc_value(SETTING_CONTROL_ADDR) {
+ addr = ret.at(0);
+ }
return QHostAddress(addr);
}
@@ -230,35 +249,42 @@ TorSettings::getControlAddress() const
void
TorSettings::setControlAddress(const QHostAddress &addr)
{
- setValue(SETTING_CONTROL_ADDR, addr.toString());
+ setVolatileValue(SETTING_CONTROL_ADDR, addr.toString());
}
/** Get the control port used to connect to Tor */
quint16
TorSettings::getControlPort() const
{
- return (quint16)value(SETTING_CONTROL_PORT).toInt();
+ quint16 port = defaultValue(SETTING_CONTROL_PORT).toInt();
+ with_torrc_value(SETTING_CONTROL_PORT) {
+ port = (quint16)ret.at(0).toUInt();
+ }
+ return port;
}
/** Set the control port used to connect to Tor */
void
TorSettings::setControlPort(quint16 port)
{
- setValue(SETTING_CONTROL_PORT, port);
+ setVolatileValue(SETTING_CONTROL_PORT, port);
}
/** Get the path for ControlSocket */
QString
TorSettings::getSocketPath() const
{
- return value(SETTING_SOCKET_PATH).toString();
+ with_torrc_value(SETTING_SOCKET_PATH) {
+ return ret.at(0);
+ }
+ return defaultValue(SETTING_SOCKET_PATH).toString();
}
/** Set the path for ControlSocket */
void
TorSettings::setSocketPath(const QString &path)
{
- setValue(SETTING_SOCKET_PATH, path);
+ setVolatileValue(SETTING_SOCKET_PATH, path);
}
/** Get the current control method */
@@ -343,10 +369,12 @@ QList<quint16>
TorSettings::getWarnPlaintextPorts() const
{
QList<quint16> out;
- QList<QVariant> ports;
+ QStringList ports;
- ports = value(SETTING_WARN_PLAINTEXT_PORTS).toList();
- foreach (QVariant port, ports) {
+ ports = Vidalia::torrc()->value(SETTING_WARN_PLAINTEXT_PORTS);
+ if(ports.size() > 0)
+ ports = ports.at(0).split(",");
+ foreach (QString port, ports) {
out << port.toUInt();
}
return out;
@@ -357,11 +385,11 @@ TorSettings::getWarnPlaintextPorts() const
void
TorSettings::setWarnPlaintextPorts(const QList<quint16> &ports)
{
- QList<QVariant> warnList;
+ QStringList warnList;
foreach (quint16 port, ports) {
- warnList << QVariant(port);
+ warnList << QString::number(port);
}
- setValue(SETTING_WARN_PLAINTEXT_PORTS, warnList);
+ setValue(SETTING_WARN_PLAINTEXT_PORTS, warnList.join(","));
}
/** Returns the current list of ports that will cause Tor to reject the
@@ -370,10 +398,11 @@ QList<quint16>
TorSettings::getRejectPlaintextPorts() const
{
QList<quint16> out;
- QList<QVariant> ports;
-
- ports = value(SETTING_REJECT_PLAINTEXT_PORTS).toList();
- foreach (QVariant port, ports) {
+ QStringList ports;
+ ports = Vidalia::torrc()->value(SETTING_REJECT_PLAINTEXT_PORTS);
+ if(ports.size() > 0)
+ ports = ports.at(0).split(",");
+ foreach (QString port, ports) {
out << port.toUInt();
}
return out;
@@ -384,11 +413,11 @@ TorSettings::getRejectPlaintextPorts() const
void
TorSettings::setRejectPlaintextPorts(const QList<quint16> &ports)
{
- QList<QVariant> rejectList;
+ QStringList rejectList;
foreach (quint16 port, ports) {
- rejectList << QVariant(port);
+ rejectList << QString::number(port);
}
- setValue(SETTING_REJECT_PLAINTEXT_PORTS, rejectList);
+ setValue(SETTING_REJECT_PLAINTEXT_PORTS, rejectList.join(","));
}
/** Returns the string description of the authentication method specified by
@@ -484,11 +513,11 @@ TorSettings::bootstrapFrom() const
bool
TorSettings::autoControlPort() const
{
- return value(SETTING_AUTOCONTROL).toBool();
+ return getControlPort() == 0;
}
void
TorSettings::setAutoControlPort(const bool autoControl)
{
- setValue(SETTING_AUTOCONTROL, autoControl);
+ setVolatileValue(SETTING_AUTOCONTROL, autoControl);
}
diff --git a/src/vidalia/config/TorSettings.h b/src/vidalia/config/TorSettings.h
index 9e6622e..2fdf1e5 100644
--- a/src/vidalia/config/TorSettings.h
+++ b/src/vidalia/config/TorSettings.h
@@ -47,7 +47,7 @@ public:
void setExecutable(const QString &torExecutable);
/** Gets the location of Tor's data directory. */
- QString getDataDirectory() const;
+ QString getDataDirectory();
/** Sets the location to use for Tor's data directory. */
void setDataDirectory(const QString &dataDir);
1
0