Commit 2d7e66fa authored by Mike Perry's avatar Mike Perry
Browse files

Merge remote-tracking branch 'brade/bug11879-02'

parents fd61cb0e 81fd61c7
......@@ -15,6 +15,9 @@ const kTorLogHasWarnOrErrTopic = "TorLogHasWarnOrErr";
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
"resource://torlauncher/modules/tl-util.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",
"resource://torlauncher/modules/tl-logger.jsm");
var gObsSvc;
var gOpenerCallbackFunc; // Set when opened from network settings.
......@@ -110,7 +113,7 @@ function onCancel()
if (gOpenerCallbackFunc)
{
// TODO: stop the bootstrapping process?
stopTorBootstrap();
gOpenerCallbackFunc(false);
}
else try
......@@ -126,11 +129,35 @@ function onCancel()
function onOpenSettings()
{
stopTorBootstrap();
cleanup();
window.close();
}
function stopTorBootstrap()
{
// Tell tor to disable use of the network; this should stop the bootstrap
// process.
const kErrorPrefix = "Setting DisableNetwork=1 failed: ";
try
{
var svc = Cc["@torproject.org/torlauncher-protocol-service;1"]
.getService(Ci.nsISupports);
svc = svc.wrappedJSObject;
var settings = {};
settings["DisableNetwork"] = true;
var errObj = {};
if (!svc.TorSetConfWithReply(settings, errObj))
TorLauncherLogger.log(5, kErrorPrefix + errObj.details);
}
catch(e)
{
TorLauncherLogger.log(5, kErrorPrefix + e);
}
}
var gObserver = {
// nsIObserver implementation.
observe: function(aSubject, aTopic, aParam)
......
......@@ -275,6 +275,7 @@ TorProcessService.prototype =
TorClearBootstrapError: function()
{
this.mBootstrapErrorOccurred = false;
this.mLastTorWarningPhase = null;
this.mLastTorWarningReason = null;
},
......
......@@ -206,6 +206,8 @@ TorProtocolService.prototype =
// aSettingsObj should be a JavaScript object with keys (property values)
// that correspond to tor config. keys. The value associated with each
// key should be a simple string, a string array, or a Boolean value.
// If an associated value is undefined or null, a key with no value is
// passed in the SETCONF command.
// If a fatal error occurs, null is returned. Otherwise, a reply object is
// returned.
TorSetConf: function(aSettingsObj)
......@@ -221,7 +223,7 @@ TorProtocolService.prototype =
else
cmdArgs += ' ' + key;
var val = aSettingsObj[key];
if (val)
if ((val !== undefined) && (val !== null))
{
var valType = (typeof val);
if ("boolean" == valType)
......
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