Re: [T(A)ILS-dev] About bridges support

Supprimer ce message

Répondre à ce message
Auteur: anonym
Date:  
À: The T(A)ILS public development discussion list
Sujet: Re: [T(A)ILS-dev] About bridges support
New patch which should fix the issue.

It seems there was a race condition of sorts, but I must admitt I don't
completely understand it. It seems the network config window is closed
when Vidalia's Control panel (= main window) updates its UI after
bootstrapping has progressed. The problem is that I can't find any trace
of any code that wants to kill any such external windows when that
occurs... and therefore I base my claim of this race condition only on
my flawed human senses (i.e. when I managed to reproduce the problem, it
*always* occured at the exact same time as bootstrapping bumped the UI).

In the new patch I simply put the popup's to appear in the hook when
vidalia has authenticated to Tor. That should be the last bootstrapping
UI bump that can happen before Tor has received a bridge through
Vidalia. And since this works, my above claim might get some more
validation...

Of course it's no real fix, but it works for now until I've dug deeper
into this. I'd like to see how this one works out for you, just to rule
out that I'm completely wrong.

Cheers!
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/config/NetworkSettings.cpp vidalia-0.2.10/src/vidalia/config/NetworkSettings.cpp
--- vidalia-0.2.10.old/src/vidalia/config/NetworkSettings.cpp    2009-10-03 23:49:21.000000000 +0200
+++ vidalia-0.2.10/src/vidalia/config/NetworkSettings.cpp    2011-02-04 14:24:10.036808000 +0100
@@ -16,6 +16,8 @@


#include "NetworkSettings.h"

+#include <QRegExp>
+
 #define SETTING_FASCIST_FIREWALL    "FascistFirewall"
 #define SETTING_REACHABLE_ADDRESSES "ReachableAddresses"


@@ -291,6 +293,21 @@
return value(SETTING_TUNNEL_DIR_CONNS).toBool();
}

+/** Returns true if no real bridges are configured. */
+bool
+NetworkSettings::noRealBridges() {
+  /* Regexp matches loopback on any port */
+  QRegExp bogusBridge("^127(\\.\\d{1,3}){3}:\\d{1,5}$");
+  QStringList bridges = localValue(SETTING_BRIDGE_LIST).toStringList();
+
+  QStringListIterator it(bridges);
+  while (it.hasNext())
+    if (!it.next().contains(bogusBridge))
+      return false;
+
+  return true;
+}
+
 /** Converts the ProxyType <b>type</b> to a string to store in the
  * configuration file. */
 QString
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/config/NetworkSettings.h vidalia-0.2.10/src/vidalia/config/NetworkSettings.h
--- vidalia-0.2.10.old/src/vidalia/config/NetworkSettings.h    2009-10-03 23:49:21.000000000 +0200
+++ vidalia-0.2.10/src/vidalia/config/NetworkSettings.h    2011-02-04 12:57:28.586808000 +0100
@@ -99,6 +99,9 @@
    * connections through a one-hop circuit. */
   bool getTunnelDirConns();


+  /** Returns true if no real bridges are configured. */
+  bool noRealBridges();
+
 private:
   /** Converts the ProxyType <b>type</b> to a string to store in the
    * configuration file. */
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/MainWindow.cpp vidalia-0.2.10/src/vidalia/MainWindow.cpp
--- vidalia-0.2.10.old/src/vidalia/MainWindow.cpp    2010-08-26 18:55:53.000000000 +0200
+++ vidalia-0.2.10/src/vidalia/MainWindow.cpp    2011-02-07 20:29:43.524808000 +0100
@@ -24,6 +24,7 @@
 #include "ControlPasswordInputDialog.h"
 #include "TorSettings.h"
 #include "ServerSettings.h"
+#include "NetworkSettings.h"
 #ifdef USE_AUTOUPDATE
 #include "UpdatesAvailableDialog.h"
 #endif
@@ -1375,6 +1376,20 @@
     if (status.isValid())
       bootstrapStatusChanged(status);
   }
+
+  NetworkSettings netSettings(_torControl);
+  if (Vidalia::showBridgeConfOnStart() && netSettings.noRealBridges()) {
+    if (!netSettings.getUseBridges()) {
+      netSettings.setUseBridges(true);
+      netSettings.apply();
+    }
+    if (showBridgeHelp() == VMessageBox::Help) {
+      showConfigDialog(ConfigDialog::Network);
+      showHelpDialog("bridges");
+    } else {
+      showConfigDialog(ConfigDialog::Network);
+    }
+  }
 }


/** Called when Vidalia fails to authenticate to Tor. The failure reason is
@@ -1722,6 +1737,37 @@
showConfigDialog(ConfigDialog::Server);
}

+/** Displays a help message explaining how to get and setup bridges. */
+int
+MainWindow::showBridgeHelp()
+{
+  QString bridgeHelp;
+  QTextStream out(&bridgeHelp);
+
+  out << p(tr("You have started T(A)ILS in bridge mode. In order to get "
+              "Internet access you must configure at least one working "
+              "bridge (note that bridges are sometimes offline so it is "
+              "a good idea to configure several of them).")) +
+         p(tr("Note: you might see a bridge listed as 127.0.0.1:*. In "
+              "that case, just ignore it and <b>leave it be</b>. It's "
+              "there to work around a deficiency in Tor's current bridge "
+              "handling - removing it may disable bridge mode.")) +
+         p(tr("If you don't know what a bridge is, please read the "
+              "\"<i>What are bridge relays?</i>\" section in the Vidalia "
+              "help.")) +
+         p(tr("If you don't know any bridges and don't know where to get "
+              "them, please read the \"<i>How do I find a bridge relay?</i>\" "
+              "section of the Vidalia help.")) +
+         p(tr("You can access Vidalia's bridge help by pressing the Help "
+              "button below."))
+      << endl;
+
+  return VMessageBox::information(this, tr("T(A)ILS Bridge Mode Help"),
+                     bridgeHelp,
+                     VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape,
+                     VMessageBox::Help);
+}
+
 /** Called when the user selects the "New Identity" action from the menu. */
 void
 MainWindow::newIdentity()
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/MainWindow.h vidalia-0.2.10/src/vidalia/MainWindow.h
--- vidalia-0.2.10.old/src/vidalia/MainWindow.h    2010-02-25 05:03:32.000000000 +0100
+++ vidalia-0.2.10/src/vidalia/MainWindow.h    2011-02-04 13:55:41.920808000 +0100
@@ -113,6 +113,8 @@
   void showConfigDialog(ConfigDialog::Page page = ConfigDialog::General);
   /** Displays the Configuration dialog, set to the Server page. */
   void showServerConfigDialog();
+  /** Displays a help message explaining how to get and setup bridges. */
+  int showBridgeHelp();
   /** Called when the "show on startup" checkbox is toggled. */
   void toggleShowOnStartup(bool checked);
   /** Called when the web browser or IM client have stopped */
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/Vidalia.cpp vidalia-0.2.10/src/vidalia/Vidalia.cpp
--- vidalia-0.2.10.old/src/vidalia/Vidalia.cpp    2010-08-26 19:30:56.000000000 +0200
+++ vidalia-0.2.10/src/vidalia/Vidalia.cpp    2011-02-04 13:32:26.429808000 +0100
@@ -41,14 +41,15 @@
 #include <stdlib.h>


 /* Available command-line arguments. */
-#define ARG_LANGUAGE   "lang"     /**< Argument specifying language.    */
-#define ARG_GUISTYLE   "style"    /**< Argument specfying GUI style.    */
-#define ARG_RESET      "reset"    /**< Reset Vidalia's saved settings.  */
-#define ARG_HELP       "help"     /**< Display usage informatino.       */
-#define ARG_DATADIR    "datadir"  /**< Directory to use for data files. */
-#define ARG_PIDFILE    "pidfile"  /**< Location and name of our pidfile.*/
-#define ARG_LOGFILE    "logfile"  /**< Location of our logfile.         */
-#define ARG_LOGLEVEL   "loglevel" /**< Log verbosity.                   */
+#define ARG_LANGUAGE   "lang"       /**< Argument specifying language.    */
+#define ARG_GUISTYLE   "style"      /**< Argument specfying GUI style.    */
+#define ARG_RESET      "reset"      /**< Reset Vidalia's saved settings.  */
+#define ARG_HELP       "help"       /**< Display usage informatino.       */
+#define ARG_DATADIR    "datadir"    /**< Directory to use for data files. */
+#define ARG_PIDFILE    "pidfile"    /**< Location and name of our pidfile.*/
+#define ARG_LOGFILE    "logfile"    /**< Location of our logfile.         */
+#define ARG_LOGLEVEL   "loglevel"   /**< Log verbosity.                   */
+#define ARG_BRIDGECONF "bridgeconf" /**< Display network conf on start.   */
 #define ARG_READ_PASSWORD_FROM_STDIN  \
   "read-password-from-stdin" /**< Read password from stdin. */


@@ -59,6 +60,7 @@
 TorControl* Vidalia::_torControl = 0;  /**< Main TorControl object.          */
 Log Vidalia::_log;
 QList<QTranslator *> Vidalia::_translators;
+bool Vidalia::_showBridgeConfOnStart = false;



/** Catches debugging messages from Qt and sends them to Vidalia's logs. If Qt
@@ -125,6 +127,9 @@
/* Set the GUI style appropriately. */
setStyle(_args.value(ARG_GUISTYLE));

+  if (_args.contains(ARG_BRIDGECONF))
+    _showBridgeConfOnStart = true;
+
   /* Creates a TorControl object, used to talk to Tor. */
   _torControl = new TorControl();


@@ -218,6 +223,10 @@
   out << trow(tcol("-"ARG_LANGUAGE" &lt;language&gt;") + 
               tcol(tr("Sets Vidalia's language.") +
                    "<br>[" + LanguageSupport::languageCodes().join("|") + "]"));
+  out << trow(tcol("-"ARG_BRIDGECONF) + 
+              tcol(tr("Shows the bridge configuration dialog immediately "
+                      "after Vidalia has started and informs the user how to "
+                      "get and setup bridges.")));
   out << "</table>";


   VMessageBox::information(0, 
diff -Naur -x build -x doc -x res vidalia-0.2.10.old/src/vidalia/Vidalia.h vidalia-0.2.10/src/vidalia/Vidalia.h
--- vidalia-0.2.10.old/src/vidalia/Vidalia.h    2009-06-25 04:56:47.000000000 +0200
+++ vidalia-0.2.10/src/vidalia/Vidalia.h    2011-02-04 13:53:21.892808000 +0100
@@ -74,6 +74,10 @@


/** Returns Vidalia's main TorControl object. */
static TorControl* torControl() { return _torControl; }
+
+ /** Returns true if we should show the network config page on start and
+ * guide the user through setting up bridges. */
+ static bool showBridgeConfOnStart() { return _showBridgeConfOnStart; }

   /** Returns the location Vidalia uses for its data files. */
   static QString dataDirectory();
@@ -158,6 +162,7 @@
   static TorControl* _torControl;      /**< Vidalia's main TorControl object.*/
   static Log _log; /**< Logs debugging messages to file or stdout. */
   static QList<QTranslator *> _translators; /**< List of installed translators. */
+  static bool _showBridgeConfOnStart;
 };


#endif