[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-launcher/master] Split Tor process starting code from control code.



commit ce36cfd72d78422148bead146aecfa452a1b9c90
Author: Tails developers <amnesia@xxxxxxxx>
Date:   Mon Feb 17 20:20:28 2014 +0100

    Split Tor process starting code from control code.
    
    This separation is useful for supporting configuration of already
    started, system-wide Tor instances.
---
 src/chrome/locale/en/torlauncher.properties |    1 +
 src/components/tl-process.js                |   26 +++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/chrome/locale/en/torlauncher.properties b/src/chrome/locale/en/torlauncher.properties
index bd8646e..3d5ee3f 100644
--- a/src/chrome/locale/en/torlauncher.properties
+++ b/src/chrome/locale/en/torlauncher.properties
@@ -7,6 +7,7 @@ torlauncher.tor_exited=Tor unexpectedly exited.
 torlauncher.please_restart_app=Please restart this application.
 torlauncher.tor_controlconn_failed=Could not connect to Tor control port.
 torlauncher.tor_failed_to_start=Tor failed to start.
+torlauncher.tor_control_failed=Failed to take control of Tor.
 torlauncher.tor_bootstrap_failed=Tor failed to establish a Tor network connection.
 torlauncher.tor_bootstrap_failed_details=%1$S failed (%2$S).
 
diff --git a/src/components/tl-process.js b/src/components/tl-process.js
index f97fa59..b542fc4 100644
--- a/src/components/tl-process.js
+++ b/src/components/tl-process.js
@@ -90,7 +90,10 @@ TorProcessService.prototype =
       this.mObsSvc.addObserver(this, kBootstrapStatusTopic, false);
 
       if (TorLauncherUtil.shouldStartAndOwnTor)
+      {
         this._startTor();
+        this._controlTor();
+      }
     }
     else if ("quit-application-granted" == aTopic)
     {
@@ -340,7 +343,24 @@ TorProcessService.prototype =
       p.runwAsync(args, args.length, this, false);
       this.mTorProcess = p;
       this.mTorProcessStartTime = Date.now();
+    }
+    catch (e)
+    {
+      this.mTorProcessStatus = this.kStatusExited;
+      var s = TorLauncherUtil.getLocalizedString("tor_failed_to_start");
+      TorLauncherUtil.showAlert(null, s);
+      TorLauncherLogger.safelog(4, "_startTor error: ", e);
+    }
+  }, // _startTor()
+
+
+  _controlTor: function()
+  {
+    var isInitialBootstrap =
+          TorLauncherUtil.getBoolPref(this.kPrefPromptAtStartup);
 
+    try
+    {
       this._monitorTorProcessStartup();
 
       if (isInitialBootstrap)
@@ -378,11 +398,11 @@ TorProcessService.prototype =
     catch (e)
     {
       this.mTorProcessStatus = this.kStatusExited;
-      var s = TorLauncherUtil.getLocalizedString("tor_failed_to_start");
+      var s = TorLauncherUtil.getLocalizedString("tor_control_failed");
       TorLauncherUtil.showAlert(null, s);
-      TorLauncherLogger.safelog(4, "_startTor error: ", e);
+      TorLauncherLogger.safelog(4, "_controlTor error: ", e);
     }
-  }, // _startTor()
+  }, // controlTor()
 
   _monitorTorProcessStartup: function()
   {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits