Commit b15da273 authored by Georg Koppen's avatar Georg Koppen
Browse files

Merge remote-tracking branch 'sysrqb/bug25750_6'

parents 9aa5fd46 51c1dfb7
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -2533,7 +2533,8 @@ function requestMoatCaptcha(aProxySettings, aMeekClientPath, aMeekClientArgs)
                     aMeekClientPath, aMeekClientArgs)
                     aMeekClientPath, aMeekClientArgs)
    .then(()=>
    .then(()=>
    {
    {
      let bridgeType = TorLauncherUtil.getCharPref(kPrefBridgeDBType);
      let bridgeType = TorLauncherUtil.getCharPref(kPrefBridgeDBType,
                                                   "obfs4");
      moatRequestor.fetchBridges([bridgeType])
      moatRequestor.fetchBridges([bridgeType])
      .then(aCaptchaInfo =>
      .then(aCaptchaInfo =>
      {
      {
+26 −5
Original line number Original line Diff line number Diff line
// Copyright (c) 2017, The Tor Project, Inc.
// Copyright (c) 2018, The Tor Project, Inc.
// See LICENSE for licensing information.
// See LICENSE for licensing information.
//
//
// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
// vim: set sw=2 sts=2 ts=8 et syntax=javascript:
@@ -19,6 +19,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",


function TorProcessService()
function TorProcessService()
{
{
  this.mDefaultPreferencesAreLoaded = TorLauncherUtil.loadDefaultPreferences();
  if (!this.mDefaultPreferencesAreLoaded)
  {
    throw Components.Exception("Setting (some) default preferences failed!",
                                 Cr.NS_ERROR_NOT_INITIALIZED);
  }

  this.wrappedJSObject = this;
  this.wrappedJSObject = this;
  this.mProtocolSvc = Cc["@torproject.org/torlauncher-protocol-service;1"]
  this.mProtocolSvc = Cc["@torproject.org/torlauncher-protocol-service;1"]
                .getService(Ci.nsISupports).wrappedJSObject;
                .getService(Ci.nsISupports).wrappedJSObject;
@@ -98,6 +105,13 @@ TorProcessService.prototype =
      this.mObsSvc.addObserver(this, kUserQuitTopic, false);
      this.mObsSvc.addObserver(this, kUserQuitTopic, false);
      this.mObsSvc.addObserver(this, kBootstrapStatusTopic, false);
      this.mObsSvc.addObserver(this, kBootstrapStatusTopic, false);


      if (!this.mDefaultPreferencesAreLoaded)
      {
        throw Components.Exception("Default preferences not loaded at " +
                                   "profile-after-change notification!",
                                     Cr.NS_ERROR_NOT_INITIALIZED);
      }

      if (TorLauncherUtil.shouldOnlyConfigureTor)
      if (TorLauncherUtil.shouldOnlyConfigureTor)
      {
      {
        this._controlTor(true, false);
        this._controlTor(true, false);
@@ -272,7 +286,6 @@ TorProcessService.prototype =
  contractID: this.kContractID,
  contractID: this.kContractID,
  classDescription: this.kServiceName,
  classDescription: this.kServiceName,
  classID: this.kClassID,
  classID: this.kClassID,
  implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
  flags: Ci.nsIClassInfo.DOM_OBJECT,
  flags: Ci.nsIClassInfo.DOM_OBJECT,


  // nsIFactory implementation.
  // nsIFactory implementation.
@@ -305,6 +318,13 @@ TorProcessService.prototype =


  TorStartAndControlTor: function(aForceDisableNetwork)
  TorStartAndControlTor: function(aForceDisableNetwork)
  {
  {
    if (!this.mDefaultPreferencesAreLoaded)
    {
      throw Components.Exception("TorLauncher is starting Tor but " +
                                 "the default preferences were not set!",
                                   Cr.NS_ERROR_NOT_INITIALIZED);
    }

    this._startTor(aForceDisableNetwork);
    this._startTor(aForceDisableNetwork);
    let isRunningTor = (this.mTorProcessStatus == this.kStatusStarting) ||
    let isRunningTor = (this.mTorProcessStatus == this.kStatusStarting) ||
                       (this.mTorProcessStatus == this.kStatusRunning);
                       (this.mTorProcessStatus == this.kStatusRunning);
@@ -334,7 +354,7 @@ TorProcessService.prototype =
  mQuitSoon: false,     // Quit was requested by the user; do so soon.
  mQuitSoon: false,     // Quit was requested by the user; do so soon.
  mLastTorWarningPhase: null,
  mLastTorWarningPhase: null,
  mLastTorWarningReason: null,
  mLastTorWarningReason: null,

  mDefaultPreferencesAreLoaded: false,


  // Private Methods /////////////////////////////////////////////////////////
  // Private Methods /////////////////////////////////////////////////////////
  _startTor: function(aForceDisableNetwork)
  _startTor: function(aForceDisableNetwork)
@@ -435,7 +455,8 @@ TorProcessService.prototype =
        if (socksPortArg)
        if (socksPortArg)
        {
        {
          let socksPortFlags = TorLauncherUtil.getCharPref(
          let socksPortFlags = TorLauncherUtil.getCharPref(
                                  "extensions.torlauncher.socks_port_flags");
                                  "extensions.torlauncher.socks_port_flags",
                          "IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth");
          if (socksPortFlags)
          if (socksPortFlags)
            socksPortArg += ' ' + socksPortFlags;
            socksPortArg += ' ' + socksPortFlags;
          args.push("+__SocksPort");
          args.push("+__SocksPort");
@@ -979,7 +1000,7 @@ TorProcessService.prototype =
      let stream = Cc["@mozilla.org/network/safe-file-output-stream;1"]
      let stream = Cc["@mozilla.org/network/safe-file-output-stream;1"]
                     .createInstance(Ci.nsIFileOutputStream);
                     .createInstance(Ci.nsIFileOutputStream);
      stream.init(aFile, 0x02 | 0x08 | 0x20, /* WRONLY CREATE TRUNCATE */
      stream.init(aFile, 0x02 | 0x08 | 0x20, /* WRONLY CREATE TRUNCATE */
                  0600, 0);
                  0o600, 0);
      stream.write(data, data.length);
      stream.write(data, data.length);
      stream.QueryInterface(Ci.nsISafeOutputStream).finish();
      stream.QueryInterface(Ci.nsISafeOutputStream).finish();
    }
    }
+13 −12
Original line number Original line Diff line number Diff line
@@ -13,6 +13,7 @@ const Cr = Components.results;
const Cu = Components.utils;
const Cu = Components.utils;


Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherUtil",
                          "resource://torlauncher/modules/tl-util.jsm");
                          "resource://torlauncher/modules/tl-util.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",
XPCOMUtils.defineLazyModuleGetter(this, "TorLauncherLogger",
@@ -52,7 +53,7 @@ function TorProtocolService()
        this.mControlPort = parseInt(env.get("TOR_CONTROL_PORT"), 10);
        this.mControlPort = parseInt(env.get("TOR_CONTROL_PORT"), 10);


      let useIPC = !isWindows && TorLauncherUtil.getBoolPref(
      let useIPC = !isWindows && TorLauncherUtil.getBoolPref(
                      "extensions.torlauncher.control_port_use_ipc", true);
                      "extensions.torlauncher.control_port_use_ipc", false);
      if (!this.mControlHost && !this.mControlPort && useIPC)
      if (!this.mControlHost && !this.mControlPort && useIPC)
        this.mControlIPCFile = TorLauncherUtil.getTorFile("control_ipc", false);
        this.mControlIPCFile = TorLauncherUtil.getTorFile("control_ipc", false);
      else
      else
@@ -156,7 +157,7 @@ function TorProtocolService()
    if (useIPC === undefined)
    if (useIPC === undefined)
    {
    {
      useIPC = !isWindows && TorLauncherUtil.getBoolPref(
      useIPC = !isWindows && TorLauncherUtil.getBoolPref(
                       "extensions.torlauncher.socks_port_use_ipc", true);
                       "extensions.torlauncher.socks_port_use_ipc", false);
    }
    }


    // Fill in missing SOCKS info from prefs.
    // Fill in missing SOCKS info from prefs.
@@ -182,6 +183,7 @@ function TorProtocolService()
      {
      {
        let socksPort = TorLauncherUtil.getIntPref("network.proxy.socks_port",
        let socksPort = TorLauncherUtil.getIntPref("network.proxy.socks_port",
                                                   0);
                                                   0);
        // This pref is set as 0 by default in Firefox, use 9150 if we get 0.
        this.mSOCKSPortInfo.port = (socksPort != 0) ? socksPort : 9150;
        this.mSOCKSPortInfo.port = (socksPort != 0) ? socksPort : 9150;
      }
      }
    }
    }
@@ -256,7 +258,6 @@ TorProtocolService.prototype =
  contractID: this.kContractID,
  contractID: this.kContractID,
  classDescription: this.kServiceName,
  classDescription: this.kServiceName,
  classID: this.kClassID,
  classID: this.kClassID,
  implementationLanguage: Ci.nsIProgrammingLanguage.JAVASCRIPT,
  flags: Ci.nsIClassInfo.DOM_OBJECT,
  flags: Ci.nsIClassInfo.DOM_OBJECT,


  // nsIFactory implementation.
  // nsIFactory implementation.
@@ -637,10 +638,6 @@ TorProtocolService.prototype =
    let s = "";
    let s = "";
    if (this.mTorLog)
    if (this.mTorLog)
    {
    {
      let dateFmtSvc = Cc["@mozilla.org/intl/scriptabledateformat;1"]
                      .getService(Ci.nsIScriptableDateFormat);
      let dateFormat = dateFmtSvc.dateFormatShort;
      let timeFormat = dateFmtSvc.timeFormatSecondsForce24Hour;
      let eol = (TorLauncherUtil.isWindows) ? "\r\n" : "\n";
      let eol = (TorLauncherUtil.isWindows) ? "\r\n" : "\n";
      let count = this.mTorLog.length;
      let count = this.mTorLog.length;
      if (aCountObj)
      if (aCountObj)
@@ -649,12 +646,16 @@ TorProtocolService.prototype =
      {
      {
        let logObj = this.mTorLog[i];
        let logObj = this.mTorLog[i];
        let secs = logObj.date.getSeconds();
        let secs = logObj.date.getSeconds();
        let timeStr = dateFmtSvc.FormatDateTime("", dateFormat, timeFormat,

                         logObj.date.getFullYear(), logObj.date.getMonth() + 1,
        let options = { year: '2-digit', month: 'numeric', day: 'numeric',
                             logObj.date.getDate(), logObj.date.getHours(),
                hour: 'numeric', minute: 'numeric', second: 'numeric',
                             logObj.date.getMinutes(), secs);
                hour12: false };
        let timeStr = new Intl.DateTimeFormat('en-US', options)
                      .format(logObj.date, options);

        if (' ' == timeStr.substr(-1))
        if (' ' == timeStr.substr(-1))
          timeStr = timeStr.substr(0, timeStr.length - 1);
          timeStr = timeStr.substr(0, timeStr.length - 1);

        let fracSecsStr = "" + logObj.date.getMilliseconds();
        let fracSecsStr = "" + logObj.date.getMilliseconds();
        while (fracSecsStr.length < 3)
        while (fracSecsStr.length < 3)
          fracSecsStr += "0";
          fracSecsStr += "0";
@@ -1506,7 +1507,7 @@ TorProtocolService.prototype =
          else
          else
          {
          {
            var maxEntries =
            var maxEntries =
                    TorLauncherUtil.getIntPref(this.kPrefMaxTorLogEntries, 0);
                    TorLauncherUtil.getIntPref(this.kPrefMaxTorLogEntries, 1000);
            if ((maxEntries > 0) && (this.mTorLog.length >= maxEntries))
            if ((maxEntries > 0) && (this.mTorLog.length >= maxEntries))
              this.mTorLog.splice(0, 1);
              this.mTorLog.splice(0, 1);
          }
          }
+8 −0
Original line number Original line Diff line number Diff line
@@ -39,6 +39,14 @@
                <em:maxVersion>*.*.*</em:maxVersion>
                <em:maxVersion>*.*.*</em:maxVersion>
            </Description>
            </Description>
        </em:targetApplication>
        </em:targetApplication>
        <!-- fennec -->
        <em:targetApplication>
          <Description>
            <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id>
            <em:minVersion>45.0</em:minVersion>
            <em:maxVersion>*</em:maxVersion>
          </Description>
        </em:targetApplication>


    </Description>
    </Description>
</RDF>
</RDF>
+3 −3
Original line number Original line Diff line number Diff line
// Copyright (c) 2013, The Tor Project, Inc.
// Copyright (c) 2018, The Tor Project, Inc.
// See LICENSE for licensing information.
// See LICENSE for licensing information.
// TODO: Based on torbutton-logger.js (pull in copyright and license?)
// TODO: Based on torbutton-logger.js (pull in copyright and license?)
//
//
@@ -108,8 +108,8 @@ let TLLoggerInternal = // Private
  {
  {
    // Register observer
    // Register observer
    var prefs = Cc["@mozilla.org/preferences-service;1"]
    var prefs = Cc["@mozilla.org/preferences-service;1"]
                  .getService(Ci.nsIPrefBranchInternal)
                  .getService(Ci.nsIPrefBranch)
                  .QueryInterface(Ci.nsIPrefBranchInternal);
                  .QueryInterface(Ci.nsIPrefBranch);
    prefs.addObserver("extensions.torlauncher", this, false);
    prefs.addObserver("extensions.torlauncher", this, false);


    this.mLogLevel = TorLauncherUtil.getIntPref(
    this.mLogLevel = TorLauncherUtil.getIntPref(
Loading