[tbb-commits] [tor-launcher/master] Bug 15657: display host:port if HOSTADDR is provided by Tor.

gk at torproject.org gk at torproject.org
Wed Apr 15 12:42:27 UTC 2015


commit b48d563eaa58b2c423b1eba09aa712787ba5a559
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Fri Apr 10 18:00:23 2015 -0400

    Bug 15657: display host:port if HOSTADDR is provided by Tor.
    
    If a Tor bootstrap status message contains a HOSTADDR value, include
    it within the error alert that we display.
    Also fix a problem where the progress dialog stayed open after an error
    occurred (even though an error alert was displayed as soon as the user
    clicked the "Cancel" button).
---
 src/chrome/content/progress.js |   13 ++++++++++---
 src/components/tl-process.js   |    7 ++++---
 src/components/tl-protocol.js  |    3 ++-
 src/modules/tl-util.jsm        |    5 ++++-
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/chrome/content/progress.js b/src/chrome/content/progress.js
index 30c4370..8208398 100644
--- a/src/chrome/content/progress.js
+++ b/src/chrome/content/progress.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2014, The Tor Project, Inc.
+// Copyright (c) 2015, The Tor Project, Inc.
 // See LICENSE for licensing information.
 //
 // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
@@ -9,6 +9,7 @@ const Cu = Components.utils;
 
 const kTorProcessExitedTopic = "TorProcessExited";
 const kBootstrapStatusTopic = "TorBootstrapStatus";
+const kTorBootstrapErrorTopic = "TorBootstrapError";
 const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -42,6 +43,7 @@ function initDialog()
                   .getService(Ci.nsIObserverService);
     gObsSvc.addObserver(gObserver, kTorProcessExitedTopic, false);
     gObsSvc.addObserver(gObserver, kBootstrapStatusTopic, false);
+    gObsSvc.addObserver(gObserver, kTorBootstrapErrorTopic, false);
     gObsSvc.addObserver(gObserver, kTorLogHasWarnOrErrTopic, false);
   }
   catch (e) {}
@@ -85,6 +87,7 @@ function cleanup()
   {
     gObsSvc.removeObserver(gObserver, kTorProcessExitedTopic);
     gObsSvc.removeObserver(gObserver, kBootstrapStatusTopic);
+    gObsSvc.removeObserver(gObserver, kTorBootstrapErrorTopic);
     gObsSvc.removeObserver(gObserver, kTorLogHasWarnOrErrTopic);
   }
 }
@@ -132,10 +135,14 @@ var gObserver = {
   // nsIObserver implementation.
   observe: function(aSubject, aTopic, aParam)
   {
-    if (kTorProcessExitedTopic == aTopic)
+    if ((kTorProcessExitedTopic == aTopic) ||
+        (kTorBootstrapErrorTopic == aTopic))
     {
+      // In these cases, an error alert will be displayed elsewhere so it is
+      // best to close this window.
       // TODO: provide a way to access tor log e.g., leave this dialog open
-      //       and display the open settings button.
+      //       and display the open settings button or provide a way to do
+      //       that from our error alerts.
       cleanup();
       window.close();
     }
diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index b6dc98f..ef2b12c 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2014, The Tor Project, Inc.
+// Copyright (c) 2015, The Tor Project, Inc.
 // See LICENSE for licensing information.
 //
 // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
@@ -524,10 +524,11 @@ TorProcessService.prototype =
           this.mLastTorWarningPhase = aStatusObj.TAG;
           this.mLastTorWarningReason = aStatusObj.REASON;
 
+          // Notify others that an error will be displayed.
+          this.mObsSvc.notifyObservers(null, "TorBootstrapError", reason);
+
           var msg = TorLauncherUtil.getLocalizedString("tor_bootstrap_failed");
           TorLauncherUtil.showAlert(null, msg + "\n\n" + details);
-        
-          this.mObsSvc.notifyObservers(null, "TorBootstrapError", reason);
         }
       }
     }
diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index 09ec468..559bb37 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2014, The Tor Project, Inc.
+// Copyright (c) 2015, The Tor Project, Inc.
 // See LICENSE for licensing information.
 // TODO: Some code came from torbutton.js (pull in copyright and license?)
 //
@@ -310,6 +310,7 @@ TorProtocolService.prototype =
   //   status.REASON          -- string (optional)
   //   status.COUNT           -- integer (optional)
   //   status.RECOMMENDATION  -- string (optional)
+  //   status.HOSTADDR        -- string (optional)
   // A "TorBootstrapStatus" notification is also sent.
   // Returns null upon failure.
   _parseBootstrapStatus: function(aStatusMsg)
diff --git a/src/modules/tl-util.jsm b/src/modules/tl-util.jsm
index 834d260..ac680a8 100644
--- a/src/modules/tl-util.jsm
+++ b/src/modules/tl-util.jsm
@@ -1,4 +1,4 @@
-// Copyright (c) 2014, The Tor Project, Inc.
+// Copyright (c) 2015, The Tor Project, Inc.
 // See LICENSE for licensing information.
 //
 // vim: set sw=2 sts=2 ts=8 et syntax=javascript:
@@ -182,6 +182,9 @@ let TorLauncherUtil =  // Public
     if (!result)
       result = fallbackStr;
 
+    if ((aKeyword == "REASON") && aStatusObj.HOSTADDR)
+      result += " - " + aStatusObj.HOSTADDR;
+
     return (result) ? result : "";
   },
 



More information about the tbb-commits mailing list