[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3475: Add a DangerousPortEvent subclass of ClientStatusEvent that (vidalia/trunk/src/torcontrol)
Author: edmanm
Date: 2009-01-27 21:32:44 -0500 (Tue, 27 Jan 2009)
New Revision: 3475
Added:
vidalia/trunk/src/torcontrol/dangerousportevent.cpp
vidalia/trunk/src/torcontrol/dangerousportevent.h
Modified:
vidalia/trunk/src/torcontrol/CMakeLists.txt
vidalia/trunk/src/torcontrol/clientstatusevent.cpp
vidalia/trunk/src/torcontrol/clientstatusevent.h
vidalia/trunk/src/torcontrol/torevents.cpp
Log:
Add a DangerousPortEvent subclass of ClientStatusEvent that can be dispatched
whenever Vidalia receives a DANGEROUS_PORT controller client status event.
Modified: vidalia/trunk/src/torcontrol/CMakeLists.txt
===================================================================
--- vidalia/trunk/src/torcontrol/CMakeLists.txt 2009-01-26 03:46:38 UTC (rev 3474)
+++ vidalia/trunk/src/torcontrol/CMakeLists.txt 2009-01-28 02:32:44 UTC (rev 3475)
@@ -20,6 +20,7 @@
controlconnection.cpp
controlreply.cpp
controlsocket.cpp
+ dangerousportevent.cpp
dangerousversionevent.cpp
generalstatusevent.cpp
logevent.cpp
Modified: vidalia/trunk/src/torcontrol/clientstatusevent.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/clientstatusevent.cpp 2009-01-26 03:46:38 UTC (rev 3474)
+++ vidalia/trunk/src/torcontrol/clientstatusevent.cpp 2009-01-28 02:32:44 UTC (rev 3475)
@@ -30,6 +30,8 @@
return CircuitEstablished;
if (!str.compare("CIRCUIT_NOT_ESTABLISHED", Qt::CaseInsensitive))
return CircuitNotEstablished;
+ if (!str.compare("DANGEROUS_PORT", Qt::CaseInsensitive))
+ return DangerousPort;
if (!str.compare("DANGEROUS_SOCKS", Qt::CaseInsensitive))
return DangerousSocks;
if (!str.compare("SOCKS_UNKNOWN_PROTOCOL", Qt::CaseInsensitive))
Modified: vidalia/trunk/src/torcontrol/clientstatusevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/clientstatusevent.h 2009-01-26 03:46:38 UTC (rev 3474)
+++ vidalia/trunk/src/torcontrol/clientstatusevent.h 2009-01-28 02:32:44 UTC (rev 3475)
@@ -31,6 +31,7 @@
CircuitNotEstablished,
NotEnoughDirectoryInfo,
EnoughDirectoryInfo,
+ DangerousPort,
DangerousSocks,
UnknownSocksProtocol,
SocksBadHostname
Added: vidalia/trunk/src/torcontrol/dangerousportevent.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/dangerousportevent.cpp (rev 0)
+++ vidalia/trunk/src/torcontrol/dangerousportevent.cpp 2009-01-28 02:32:44 UTC (rev 3475)
@@ -0,0 +1,38 @@
+/*
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to
+** the terms described in the LICENSE file.
+*/
+
+/*
+** \file dangerousportevent.h
+** \version $Id$
+** \brief Event sent when the client makes a connection to a port listed in
+** their WarnPlaintextPorts or RejectPlaintextPorts settings.
+*/
+
+#include "dangerousportevent.h"
+
+
+DangerousPortEvent::DangerousPortEvent(tc::Severity severity, quint16 port,
+ Result result)
+ : ClientStatusEvent(severity, ClientStatusEvent::DangerousPort),
+ _port(port),
+ _result(result)
+{
+}
+
+DangerousPortEvent::Result
+DangerousPortEvent::resultFromString(const QString &str)
+{
+ if (!str.compare("WARN", Qt::CaseInsensitive))
+ return DangerousPortEvent::Warn;
+ if (!str.compare("REJECT", Qt::CaseInsensitive))
+ return DangerousPortEvent::Reject;
+ return DangerousPortEvent::UnrecognizedResult;
+}
+
Property changes on: vidalia/trunk/src/torcontrol/dangerousportevent.cpp
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: vidalia/trunk/src/torcontrol/dangerousportevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/dangerousportevent.h (rev 0)
+++ vidalia/trunk/src/torcontrol/dangerousportevent.h 2009-01-28 02:32:44 UTC (rev 3475)
@@ -0,0 +1,66 @@
+/*
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to
+** the terms described in the LICENSE file.
+*/
+
+/*
+** \file dangerousversionevent.h
+** \version $Id$
+** \brief Event sent when Tor realizes its version is not recommended
+*/
+
+#ifndef _DANGEROUSPORT_H
+#define _DANGEROUSPORT_H
+
+#include <QString>
+
+#include "clientstatusevent.h"
+
+
+class DangerousPortEvent : public ClientStatusEvent
+{
+
+public:
+ /** Possible actions that Tor takes in response to a client connection
+ * to a plaintext port.
+ */
+ enum Result {
+ UnrecognizedResult,
+ Reject,
+ Warn,
+ };
+
+ /** Constructs a new DangerousPortEvent object, using <b>severity</b>
+ * as the event severity level. <b>port</b> and <b>result</b> describe
+ * the port on which a potential plaintext connection was attempted
+ * and the action Tor took in response, respectively.
+ */
+ DangerousPortEvent(tc::Severity severity, quint16 port, Result result);
+
+ /** Returns the DangerousPortEvent::Result enum value specified in this
+ * event's constructor.
+ */
+ Result result() const { return _result; }
+
+ /** Returns the port specified in this event's constructor.
+ */
+ quint16 port() const { return _port; }
+
+ /** Returns an DangerousPortEvent::Result enum value corresponding to the
+ * event result described in <b>str</b>, or UnrecognizedResult if <b>str</b>
+ * does not contain a valid Result type.
+ */
+ static Result resultFromString(const QString &str);
+
+private:
+ quint16 _port;
+ Result _result;
+};
+
+#endif
+
Property changes on: vidalia/trunk/src/torcontrol/dangerousportevent.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: vidalia/trunk/src/torcontrol/torevents.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torevents.cpp 2009-01-26 03:46:38 UTC (rev 3474)
+++ vidalia/trunk/src/torcontrol/torevents.cpp 2009-01-28 02:32:44 UTC (rev 3475)
@@ -25,6 +25,7 @@
#include "unrecognizedgeneralstatusevent.h"
#include "circuitestablishedevent.h"
#include "dangerousversionevent.h"
+#include "dangerousportevent.h"
#include "bootstrapstatusevent.h"
/** Format of expiry times in address map events. */
@@ -404,8 +405,14 @@
switch (status) {
case ClientStatusEvent::CircuitEstablished:
- event = new CircuitEstablishedEvent(severity); break;
+ event = new CircuitEstablishedEvent(severity);
+ break;
+ case ClientStatusEvent::DangerousPort:
+ event = new DangerousPortEvent(severity, args.value("PORT").toUInt(),
+ DangerousPortEvent::resultFromString(args.value("RESULT")));
+ break;
+
case ClientStatusEvent::Bootstrap:
event = new BootstrapStatusEvent(BootstrapStatus(severity,
BootstrapStatus::statusFromString(args.value("TAG")),