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.

The exact behaviour is this:

When "-bridgeconf" is sent an argument to Vidalia, Vidalia will check if
it has any non-bogus (i.e. non-loopback) bridges configured. If a real
bridge is configured, Vidalia operates as it does normally. But if
there's no real bridge configured, Vidalia will open the network
configuration settings page, activate UseBridges, and show a T(A)ILS
specifig pop-up saying:

> 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).
>
> If you don't know what a bridge is, please read the "What are bridge
> relays?" section in the Vidalia help.
>
> If you don't know any bridges and don't know where to get them,
> please
> read the "How do I find a bridge relay?" section of the Vidalia help.
>
> You can access Vidalia's bridge help by pressing the Help button
> below.


As stated, the popup's help button will open the Vidalia help about
bridges, describing what they are and how to get one.

More specifically, a bogus bridge is described by the following regexp:

    ^127\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}$


i.e. any bridge on the loopback 127/8 IP address block.

That's all.

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-04 13:55:58.591808000 +0100
@@ -24,6 +24,7 @@
 #include "ControlPasswordInputDialog.h"
 #include "TorSettings.h"
 #include "ServerSettings.h"
+#include "NetworkSettings.h"
 #ifdef USE_AUTOUPDATE
 #include "UpdatesAvailableDialog.h"
 #endif
@@ -212,6 +213,16 @@
   ui.chkShowOnStartup->setChecked(settings.showMainWindowAtStart());
   if (ui.chkShowOnStartup->isChecked())
     show(); 
+
+  NetworkSettings netSettings(_torControl);
+  if (Vidalia::showBridgeConfOnStart() && netSettings.noRealBridges()) {
+    netSettings.setUseBridges(true);
+    netSettings.apply();
+    showConfigDialog(ConfigDialog::Network);
+    if (showBridgeHelp() == VMessageBox::Help)
+      showHelpDialog("bridges");
+  }
+
   /* Optimistically hope that the tray icon gets added. */
   _trayIcon.show();
 }
@@ -1722,6 +1733,33 @@
   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("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