[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r4059: Add signals for another pile of status events (mostly server (vidalia/trunk/src/torcontrol)
Author: edmanm
Date: 2009-08-19 21:03:42 -0400 (Wed, 19 Aug 2009)
New Revision: 4059
Modified:
vidalia/trunk/src/torcontrol/TorControl.cpp
vidalia/trunk/src/torcontrol/TorControl.h
vidalia/trunk/src/torcontrol/TorEvents.cpp
vidalia/trunk/src/torcontrol/TorEvents.h
Log:
Add signals for another pile of status events (mostly server related).
Modified: vidalia/trunk/src/torcontrol/TorControl.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/TorControl.cpp 2009-08-19 16:20:08 UTC (rev 4058)
+++ vidalia/trunk/src/torcontrol/TorControl.cpp 2009-08-20 01:03:42 UTC (rev 4059)
@@ -46,6 +46,25 @@
RELAY_SIGNAL(_eventHandler, SIGNAL(dangerousPort(quint16, bool)));
RELAY_SIGNAL(_eventHandler, SIGNAL(socksError(tc::SocksError, QString)));
RELAY_SIGNAL(_eventHandler, SIGNAL(bootstrapStatusChanged(BootstrapStatus)));
+ RELAY_SIGNAL(_eventHandler, SIGNAL(clockSkewed(int, QString)));
+ RELAY_SIGNAL(_eventHandler, SIGNAL(bug(QString)));
+ RELAY_SIGNAL(_eventHandler, SIGNAL(dnsHijacked()));
+ RELAY_SIGNAL(_eventHandler, SIGNAL(dnsUseless()));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(externalAddressChanged(QHostAddress, QString)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(checkingOrPortReachability(QHostAddress, quint16)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(orPortReachabilityFinished(QHostAddress,quint16,bool)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(checkingDirPortReachability(QHostAddress, quint16)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(dirPortReachabilityFinished(QHostAddress,quint16,bool)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(serverDescriptorRejected(QHostAddress, quint16, QString)));
+ RELAY_SIGNAL(_eventHandler,
+ SIGNAL(serverDescriptorAccepted(QHostAddress, quint16)));
+ RELAY_SIGNAL(_eventHandler, SIGNAL(serverDescriptorAccepted()));
/* Create an instance of a connection to Tor's control interface and give
* it an object to use to handle asynchronous events. */
Modified: vidalia/trunk/src/torcontrol/TorControl.h
===================================================================
--- vidalia/trunk/src/torcontrol/TorControl.h 2009-08-19 16:20:08 UTC (rev 4058)
+++ vidalia/trunk/src/torcontrol/TorControl.h 2009-08-20 01:03:42 UTC (rev 4059)
@@ -297,6 +297,75 @@
*/
void socksError(tc::SocksError type, const QString &destination);
+ /** Emitted when Tor decides the clients external IP address has changed
+ * to <b>ip</b>. If <b>hostname</b> is non-empty, Tor obtained the new
+ * value for <b>ip</b> by resolving <b>hostname</b>.
+ */
+ void externalAddressChanged(const QHostAddress &ip, const QString &hostname);
+
+ /** Indicates that Tor has determined the client's clock is potentially
+ * skewed by <b>skew</b> seconds relative to <b>source</b>.
+ */
+ void clockSkewed(int skew, const QString &source);
+
+ /** Emitted when Tor has encountered an internal bug. <b>reason</b> is
+ * Tor's description of the bug.
+ */
+ void bug(const QString &reason);
+
+ /** Emitted when Tor determines that the user's DNS provider is providing
+ * an address for non-existent domains when it should really be saying
+ * "NXDOMAIN".
+ */
+ void dnsHijacked();
+
+ /** Emitted when Tor determines that the user's DNS provider is providing
+ * a hijacked address even for well-known websites.
+ */
+ void dnsUseless();
+
+ /** Indicates Tor has started testing the reachability of its OR port
+ * using the IP address <b>ip</b> and port <b>port</b>.
+ */
+ void checkingOrPortReachability(const QHostAddress &ip, quint16 port);
+
+ /** Tor has completed testing the reachability of its OR port using
+ * the IP address <b>ip</b> and port <b>port</b>. If the user's OR port
+ * was reachable, <b>reachable</b> will be set to true.
+ */
+ void orPortReachabilityFinished(const QHostAddress &ip, quint16 port,
+ bool reachable);
+
+ /** Indicates Tor has started testing the reachability of its directory
+ * port using the IP address <b>ip</b> and port <b>port</b>.
+ */
+ void checkingDirPortReachability(const QHostAddress &ip, quint16 port);
+
+ /** Tor has completed testing the reachability of its directory port using
+ * the IP address <b>ip</b> and port <b>port</b>. If the user's directory
+ * port was reachable, <b>reachable</b> will be set to true.
+ */
+ void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port,
+ bool reachable);
+
+ /** Emitted when the directory authority with IP address <b>ip</b> and
+ * port <b>port</b> rejected the user's server descriptor. <b>reason</b>
+ * describes why the descriptor was rejected (e.g., malformed, skewed
+ * clock, etc.).
+ */
+ void serverDescriptorRejected(const QHostAddress &ip, quint16 port,
+ const QString &reason);
+
+ /** Emitted when the directory authority with IP address <b>ip</b> and
+ * port <b>port</b> accepted the user's server descriptor.
+ */
+ void serverDescriptorAccepted(const QHostAddress &ip, quint16 port);
+
+ /** Emitted when at least one directory authority has accepted the user's
+ * server descriptor.
+ */
+ void serverDescriptorAccepted();
+
private:
/** Instantiates a connection used to talk to Tor's control port */
ControlConnection* _controlConn;
Modified: vidalia/trunk/src/torcontrol/TorEvents.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/TorEvents.cpp 2009-08-19 16:20:08 UTC (rev 4058)
+++ vidalia/trunk/src/torcontrol/TorEvents.cpp 2009-08-20 01:03:42 UTC (rev 4059)
@@ -24,6 +24,7 @@
#include "stringutil.h"
+#include <QHostAddress>
#include <QMetaType>
/** Format of expiry times in address map events. */
@@ -331,6 +332,17 @@
else if (! reason.compare("OBSOLETE", Qt::CaseInsensitive)
|| ! reason.compare("OLD", Qt::CaseInsensitive))
emit dangerousTorVersion(tc::ObsoleteTorVersion, current, recommended);
+ } else if (! action.compare("CLOCK_SKEW", Qt::CaseInsensitive)) {
+ int skew;
+ bool ok = false;
+ if (args.contains("SKEW"))
+ skew = args.value("SKEW").toInt(&ok);
+ else if (args.contains("MIN_SKEW"))
+ skew = args.value("MIN_SKEW").toInt(&ok);
+ if (ok)
+ emit clockSkewed(skew, args.value("SOURCE"));
+ } else if (! action.compare("BUG", Qt::CaseInsensitive)) {
+ emit bug(args.value("REASON"));
}
}
@@ -371,9 +383,73 @@
const QString &action,
const QHash<QString,QString> &args)
{
- Q_UNUSED(severity);
- Q_UNUSED(action);
- Q_UNUSED(args);
+ if (! action.compare("EXTERNAL_ADDRESS", Qt::CaseInsensitive)) {
+ emit externalAddressChanged(QHostAddress(args.value("ADDRESS")),
+ args.value("HOSTNAME"));
+ } else if (! action.compare("CHECKING_REACHABILITY", Qt::CaseInsensitive)) {
+ if (args.contains("ORADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("ORADDRESS"));
+ if (! pair.first.isNull())
+ emit checkingOrPortReachability(pair.first, pair.second);
+ } else if (args.contains("DIRADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("DIRADDRESS"));
+ if (! pair.first.isNull())
+ emit checkingDirPortReachability(pair.first, pair.second);
+ }
+ } else if (! action.compare("REACHABILITY_SUCCEEDED", Qt::CaseInsensitive)) {
+ if (args.contains("ORADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("ORADDRESS"));
+ if (! pair.first.isNull())
+ emit orPortReachabilityFinished(pair.first, pair.second, true);
+ } else if (args.contains("DIRADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("DIRADDRESS"));
+ if (! pair.first.isNull())
+ emit dirPortReachabilityFinished(pair.first, pair.second, true);
+ }
+ } else if (! action.compare("REACHABILITY_FAILED", Qt::CaseInsensitive)) {
+ if (args.contains("ORADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("ORADDRESS"));
+ if (! pair.first.isNull())
+ emit orPortReachabilityFinished(pair.first, pair.second, false);
+ } else if (args.contains("DIRADDRESS")) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("DIRADDRESS"));
+ if (! pair.first.isNull())
+ emit dirPortReachabilityFinished(pair.first, pair.second, false);
+ }
+ } else if (! action.compare("GOOD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) {
+ emit serverDescriptorAccepted();
+ } else if (! action.compare("ACCEPTED_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("DIRAUTH"));
+ if (! pair.first.isNull())
+ emit serverDescriptorAccepted(pair.first, pair.second);
+ } else if (! action.compare("BAD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) {
+ QPair<QHostAddress,quint16> pair = splitAddress(args.value("DIRAUTH"));
+ if (! pair.first.isNull())
+ emit serverDescriptorRejected(pair.first, pair.second,
+ args.value("REASON"));
+ } else if (! action.compare("DNS_HIJACKED", Qt::CaseInsensitive)) {
+ emit dnsHijacked();
+ } else if (! action.compare("DNS_USELESS", Qt::CaseInsensitive)) {
+ emit dnsUseless();
+ }
}
+/** Splits a string in the form "IP:PORT" into a QHostAddress and quint16
+ * pair. If either portion is invalid, a default-constructed QPair() is
+ * returned. */
+QPair<QHostAddress,quint16>
+TorEvents::splitAddress(const QString &address)
+{
+ bool ok;
+ int idx = address.indexOf(":");
+ if (idx <= 0 || idx >= address.length()-1)
+ return QPair<QHostAddress,quint16>();
+ QHostAddress ip = QHostAddress(address.mid(0, idx));
+ quint16 port = static_cast<quint16>(address.mid(idx+1).toUInt(&ok));
+ if (ip.isNull() || ! ok)
+ return QPair<QHostAddress,quint16>();
+ return QPair<QHostAddress,quint16>(ip, port);
+}
+
+
Modified: vidalia/trunk/src/torcontrol/TorEvents.h
===================================================================
--- vidalia/trunk/src/torcontrol/TorEvents.h 2009-08-19 16:20:08 UTC (rev 4058)
+++ vidalia/trunk/src/torcontrol/TorEvents.h 2009-08-20 01:03:42 UTC (rev 4059)
@@ -139,12 +139,85 @@
*/
void socksError(tc::SocksError error, const QString &destination);
+ /** Emitted when Tor has encountered an internal bug. <b>reason</b> is
+ * Tor's description of the bug.
+ */
+ void bug(const QString &reason);
+
+ /** Emitted when Tor decides the clients external IP address has changed
+ * to <b>ip</b>. If <b>hostname</b> is non-empty, Tor obtained the new
+ * value for <b>ip</b> by resolving <b>hostname</b>.
+ */
+ void externalAddressChanged(const QHostAddress &ip, const QString &hostname);
+
+ /** Indicates that Tor has determined the client's clock is potentially
+ * skewed by <b>skew</b> seconds relative to <b>source</b>.
+ */
+ void clockSkewed(int skew, const QString &source);
+
+ /** Emitted when Tor determines that the user's DNS provider is providing
+ * an address for non-existent domains when it should really be saying
+ * "NXDOMAIN".
+ */
+ void dnsHijacked();
+
+ /** Emitted when Tor determines that the user's DNS provider is providing
+ * a hijacked address even for well-known websites.
+ */
+ void dnsUseless();
+
+ /** Indicates Tor has started testing the reachability of its OR port
+ * using the IP address <b>ip</b> and port <b>port</b>.
+ */
+ void checkingOrPortReachability(const QHostAddress &ip, quint16 port);
+
+ /** Tor has completed testing the reachability of its OR port using
+ * the IP address <b>ip</b> and port <b>port</b>. If the user's OR port
+ * was reachable, <b>reachable</b> will be set to true.
+ */
+ void orPortReachabilityFinished(const QHostAddress &ip, quint16 port,
+ bool reachable);
+
+ /** Indicates Tor has started testing the reachability of its directory
+ * port using the IP address <b>ip</b> and port <b>port</b>.
+ */
+ void checkingDirPortReachability(const QHostAddress &ip, quint16 port);
+
+ /** Tor has completed testing the reachability of its directory port using
+ * the IP address <b>ip</b> and port <b>port</b>. If the user's directory
+ * port was reachable, <b>reachable</b> will be set to true.
+ */
+ void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port,
+ bool reachable);
+
+ /** Emitted when the directory authority with IP address <b>ip</b> and
+ * port <b>port</b> rejected the user's server descriptor. <b>reason</b>
+ * describes why the descriptor was rejected (e.g., malformed, skewed
+ * clock, etc.).
+ */
+ void serverDescriptorRejected(const QHostAddress &ip, quint16 port,
+ const QString &reason);
+
+ /** Emitted when the directory authority with IP address <b>ip</b> and
+ * port <b>port</b> accepted the user's server descriptor.
+ */
+ void serverDescriptorAccepted(const QHostAddress &ip, quint16 port);
+
+ /** Emitted when at least one directory authority has accepted the user's
+ * server descriptor.
+ */
+ void serverDescriptorAccepted();
+
private:
/** Parses the event type from the event message */
static Event parseEventType(const ReplyLine &line);
/** Converts a string to an Event */
static Event toTorEvent(const QString &event);
-
+ /** Splits a string in the form "IP:PORT" into a QHostAddress and quint16
+ * pair. If either portion is invalid, a default-constructed QPair() is
+ * returned. */
+ static QPair<QHostAddress,quint16> splitAddress(const QString &address);
+
/** Handle a bandwidth update event */
void handleBandwidthUpdate(const ReplyLine &line);
/** Handle a circuit status event */