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

Bug #9445: Tor Launcher should be more relaxed about bridge line input.

Show "Copy Tor Log To Clipboard" button in wizard if tor logs
  a warning or error.
Fix regression in bridge validation.
Improve bridge list placeholder text.
parent 6c064c5c
......@@ -22,6 +22,7 @@ const kTorProcessReadyTopic = "TorProcessIsReady";
const kTorProcessExitedTopic = "TorProcessExited";
const kTorProcessDidNotStartTopic = "TorProcessDidNotStart";
const kTorBootstrapErrorTopic = "TorBootstrapError";
const kTorLogHasWarnOrErr = "TorLogHasWarnOrErr";
const kWizardProxyRadioGroup = "proxyRadioGroup";
const kWizardFirewallRadioGroup = "firewallRadioGroup";
......@@ -116,8 +117,11 @@ function initDialog()
cancelBtn.parentNode.insertBefore(copyLogBtn, cancelBtn.nextSibling);
}
if (gTorProcessService.TorBootstrapErrorOccurred)
if (gTorProcessService.TorBootstrapErrorOccurred ||
gProtocolSvc.TorLogHasWarnOrErr)
{
wizardShowCopyLogButton();
}
// Use "Connect" as the finish button label (on the last wizard page)..
var finishBtn = document.documentElement.getButton("finish");
......@@ -139,6 +143,7 @@ function initDialog()
}
gObsService.addObserver(gObserver, kTorBootstrapErrorTopic, false);
gObsService.addObserver(gObserver, kTorLogHasWarnOrErr, false);
if (TorLauncherUtil.shouldStartAndOwnTor &&
!gTorProcessService.TorIsProcessReady)
......@@ -211,7 +216,7 @@ function showWizardNavButtons(aShow)
var gObserver = {
observe: function(aSubject, aTopic, aData)
{
if (kTorBootstrapErrorTopic == aTopic)
if ((kTorBootstrapErrorTopic == aTopic) || (kTorLogHasWarnOrErr == aTopic))
{
wizardShowCopyLogButton();
return;
......@@ -956,14 +961,17 @@ function setBridgeListElemValue(aBridgeArray)
// To be consistent with bridges.torproject.org, pre-pend "bridge" to
// each line as it is displayed in the UI.
var bridgeList = [];
for (var i = 0; i < aBridgeArray.length; ++i)
if (aBridgeArray)
{
var s = aBridgeArray[i].trim();
if (s.length > 0)
for (var i = 0; i < aBridgeArray.length; ++i)
{
if (s.toLowerCase().indexOf("bridge") != 0)
s = "bridge " + s;
bridgeList.push(s);
var s = aBridgeArray[i].trim();
if (s.length > 0)
{
if (s.toLowerCase().indexOf("bridge") != 0)
s = "bridge " + s;
bridgeList.push(s);
}
}
}
......
......@@ -44,7 +44,7 @@
<!ENTITY torsettings.firewall.allowedPorts "Allowed Ports:">
<!ENTITY torsettings.useBridges.checkbox "My Internet Service Provider (ISP) blocks connections to the Tor network">
<!ENTITY torsettings.useBridges.label "Enter one or more bridge relays (one per line).">
<!ENTITY torsettings.useBridges.placeholder "address:port">
<!ENTITY torsettings.useBridges.placeholder "address:port OR transport address:port">
<!ENTITY torsettings.copyLog "Copy Tor Log To Clipboard">
<!ENTITY torsettings.bridgeHelpTitle "Bridge Relay Help">
......
......@@ -413,6 +413,22 @@ TorProtocolService.prototype =
this._waitForEventData();
},
// Returns true if the log messages we have captured contain WARN or ERR.
get TorLogHasWarnOrErr()
{
if (!this.mTorLog)
return false;
for (var i = this.mTorLog.length - 1; i >= 0; i--)
{
var logObj = this.mTorLog[i];
if ((logObj.type == "WARN") || (logObj.type == "ERR"))
return true;
}
return false;
},
// Returns captured log message as a text string (one message per line).
TorGetLog: function()
{
......@@ -1203,11 +1219,16 @@ TorProtocolService.prototype =
let msg = s.substr(idx + 1);
switch (eventType)
{
case "WARN":
case "ERR":
// Notify so that Copy Log can be enabled.
var obsSvc = Cc["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService);
obsSvc.notifyObservers(null, "TorLogHasWarnOrErr", null);
// fallthru
case "DEBUG":
case "INFO":
case "NOTICE":
case "WARN":
case "ERR":
var now = new Date();
let logObj = { date: now, type: eventType, msg: msg };
if (!this.mTorLog)
......
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