[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3481: Catch DANGEROUS_PORT status events and add a handler that al (vidalia/trunk/src/vidalia)
Author: edmanm
Date: 2009-01-30 00:28:21 -0500 (Fri, 30 Jan 2009)
New Revision: 3481
Modified:
vidalia/trunk/src/vidalia/mainwindow.cpp
vidalia/trunk/src/vidalia/mainwindow.h
Log:
Catch DANGEROUS_PORT status events and add a handler that alerts the user,
giving them the option to ignore future warnings for this port.
Modified: vidalia/trunk/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.cpp 2009-01-30 05:20:24 UTC (rev 3480)
+++ vidalia/trunk/src/vidalia/mainwindow.cpp 2009-01-30 05:28:21 UTC (rev 3481)
@@ -28,6 +28,7 @@
#include <net.h>
#include <clientstatusevent.h>
#include <dangerousversionevent.h>
+#include <dangerousportevent.h>
#include <vmessagebox.h>
#include <procutil.h>
@@ -262,6 +263,13 @@
if (bse)
bootstrapStatusChanged(bse->status());
cse->accept();
+ } else if (cse->status() == ClientStatusEvent::DangerousPort) {
+ DangerousPortEvent *dpe = dynamic_cast<DangerousPortEvent *>(cse);
+ if (dpe) {
+ bool rejected = (dpe->result() == DangerousPortEvent::Reject);
+ warnDangerousPort(dpe->port(), rejected);
+ }
+ cse->accept();
}
} else if (event->type() == CustomEventType::GeneralStatusEvent) {
GeneralStatusEvent *gse = dynamic_cast<GeneralStatusEvent *>(event);
@@ -1427,6 +1435,66 @@
}
}
+/** Called when Tor thinks the user has tried to connect to a port that
+ * typically is used for unencrypted applications. Warns the user and allows
+ * them to ignore future warnings on <b>port</b>. */
+void
+MainWindow::warnDangerousPort(quint16 port, bool rejected)
+{
+ QString warning, application;
+ QMessageBox dlg(QMessageBox::Warning,
+ tr("Potentially Unsafe Connection"), QString(),
+ QMessageBox::Ok | QMessageBox::Ignore);
+
+ switch (port) {
+ case 23:
+ application = tr(", probably Telnet, ");
+ break;
+
+ case 109:
+ case 110:
+ case 143:
+ application = tr(", probably an email client, ");
+ break;
+
+ default:
+ application = " ";
+ }
+
+ warning = p(tr("One of your applications%1appears to be making a "
+ "potentially unencrypted and unsafe connection to port %2. "
+ "Anything sent over this connection could be monitored. "
+ "Please check your application's configuration and use "
+ "only encrypted protocols, such as SSL, if possible.")
+ .arg(application).arg(port));
+ if (rejected) {
+ warning.append(p(tr("Tor has automatically closed your connection in "
+ "order to protect your anonymity.")));
+ }
+ dlg.setText(warning);
+
+ int ret = dlg.exec();
+ if (ret == QMessageBox::Ignore) {
+ TorSettings settings;
+ QList<quint16> ports;
+ int idx;
+
+ ports = settings.getWarnPlaintextPorts();
+ idx = ports.indexOf(port);
+ if (idx >= 0) {
+ ports.removeAt(idx);
+ settings.setWarnPlaintextPorts(ports);
+ }
+
+ ports = settings.getRejectPlaintextPorts();
+ idx = ports.indexOf(port);
+ if (idx >= 0) {
+ ports.removeAt(idx);
+ settings.setRejectPlaintextPorts(ports);
+ }
+ }
+}
+
/** Creates and displays Vidalia's About dialog. */
void
MainWindow::showAboutDialog()
Modified: vidalia/trunk/src/vidalia/mainwindow.h
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.h 2009-01-30 05:20:24 UTC (rev 3480)
+++ vidalia/trunk/src/vidalia/mainwindow.h 2009-01-30 05:28:21 UTC (rev 3481)
@@ -190,6 +190,10 @@
/** Called when Tor thinks its version is old or unrecommended, and displays
* a message notifying the user. */
void dangerousTorVersion();
+ /** Called when Tor thinks the user has tried to connect to a port that
+ * typically is used for unencrypted applications. Warns the user and allows
+ * them to ignore future warnings on <b>port</b>. */
+ void warnDangerousPort(quint16 port, bool rejected);
/** Called when Tor's bootstrapping status changes. <b>bse</b> represents
* Tor's current estimate of its bootstrapping progress. */
void bootstrapStatusChanged(const BootstrapStatus &bs);