GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit b48d563e authored by Kathleen Brade's avatar Kathleen Brade
Browse files

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).
parent 7382cc7c
// 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();
}
......
// 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);
}
}
}
......
// 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)
......
// 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 : "";
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment