Use a preference setting to decide whether to bind to the loopback interface only, or all interfaces (Bug 764679); r=dcamp,mfinkle,jgriffin,vingtetun
authorPanos Astithas <past@mozilla.com>
Wed, 20 Jun 2012 16:31:50 +0300
changeset 101929 576e10abf8248f793c1cf9b1c3ae93526923cfa3
parent 101928 92d3a40382aaee7cc38e0396b45e447335a0310e
child 101930 6cbfdf764d22f79f47e2a8470352beaf22f3780b
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp, mfinkle, jgriffin, vingtetun
bugs764679
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Use a preference setting to decide whether to bind to the loopback interface only, or all interfaces (Bug 764679); r=dcamp,mfinkle,jgriffin,vingtetun
b2g/chrome/content/shell.js
browser/devtools/debugger/DebuggerUI.jsm
mobile/android/chrome/content/browser.js
modules/libpref/src/init/all.js
testing/marionette/components/marionettecomponent.js
toolkit/devtools/debugger/server/dbg-server.js
toolkit/devtools/debugger/tests/unit/test_dbgglobal.js
toolkit/devtools/debugger/tests/unit/test_dbgsocket.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -482,17 +482,17 @@ function startDebugger() {
   if (!DebuggerServer.initialized) {
     // Allow remote connections.
     DebuggerServer.init(function () { return true; });
     DebuggerServer.addActors('chrome://browser/content/dbg-browser-actors.js');
   }
 
   let port = Services.prefs.getIntPref('devtools.debugger.remote-port') || 6000;
   try {
-    DebuggerServer.openListener(port, false);
+    DebuggerServer.openListener(port);
   } catch (e) {
     dump('Unable to start debugger server: ' + e + '\n');
   }
 }
 
 window.addEventListener('ContentStart', function(evt) {
   if (Services.prefs.getBoolPref('devtools.debugger.remote-enabled')) {
     startDebugger();
--- a/browser/devtools/debugger/DebuggerUI.jsm
+++ b/browser/devtools/debugger/DebuggerUI.jsm
@@ -437,17 +437,17 @@ ChromeDebuggerProcess.prototype = {
    * Initializes the debugger server.
    */
   _initServer: function RDP__initServer() {
     if (!DebuggerServer.initialized) {
       DebuggerServer.init(this._allowConnection);
       DebuggerServer.addBrowserActors();
     }
     DebuggerServer.closeListener();
-    DebuggerServer.openListener(DebuggerPreferences.remotePort, false);
+    DebuggerServer.openListener(DebuggerPreferences.remotePort);
   },
 
   /**
    * Prompt the user to accept or decline the incoming connection.
    *
    * @return true if the connection should be permitted, false otherwise
    */
   _allowConnection: function RDP__allowConnection() {
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -5669,17 +5669,17 @@ var RemoteDebugger = {
   _start: function rd_start() {
     try {
       if (!DebuggerServer.initialized) {
         DebuggerServer.init(this._allowConnection);
         DebuggerServer.addActors("chrome://browser/content/dbg-browser-actors.js");
       }
 
       let port = this._getPort();
-      DebuggerServer.openListener(port, false);
+      DebuggerServer.openListener(port);
       dump("Remote debugger listening on port " + port);
     } catch(e) {
       dump("Remote debugger didn't start: " + e);
     }
   },
 
   _stop: function rd_start() {
     DebuggerServer.closeListener();
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -315,16 +315,18 @@ pref("toolkit.telemetry.infoURL", "http:
 // i.e. dynamically constructed SQL strings or SQL executed by addons against addon DBs
 pref("toolkit.telemetry.debugSlowSql", false);
 
 // Disable remote debugging protocol logging
 pref("devtools.debugger.log", false);
 // Disable remote debugging connections
 pref("devtools.debugger.remote-enabled", false);
 pref("devtools.debugger.remote-port", 6000);
+// Force debugger server binding on the loopback interface
+pref("devtools.debugger.force-local", true);
 
 // view source
 pref("view_source.syntax_highlight", true);
 pref("view_source.wrap_long_lines", false);
 pref("view_source.editor.external", false);
 pref("view_source.editor.path", "");
 // allows to add further arguments to the editor; use the %LINE% placeholder
 // for jumping to a specific line (e.g. "/line:%LINE%" or "--goto %LINE%")
--- a/testing/marionette/components/marionettecomponent.js
+++ b/testing/marionette/components/marionettecomponent.js
@@ -70,17 +70,17 @@ MarionetteComponent.prototype = {
       try {
         Cu.import('resource:///modules/devtools/dbg-server.jsm');
         DebuggerServer.addActors('chrome://marionette/content/marionette-actors.js');
         // This pref is required for the remote debugger to open a socket,
         // so force it to true.  See bug 761252.
         Services.prefs.setBoolPref('devtools.debugger.remote-enabled', true);
         // Always allow remote connections.
         DebuggerServer.initTransport(function () { return true; });
-        DebuggerServer.openListener(port, true);
+        DebuggerServer.openListener(port);
       }
       catch(e) {
         this.logger.error('exception: ' + e.name + ', ' + e.message);
       }
     }
   },
 
   uninit: function mc_uninit() {
--- a/toolkit/devtools/debugger/server/dbg-server.js
+++ b/toolkit/devtools/debugger/server/dbg-server.js
@@ -118,31 +118,35 @@ var DebuggerServer = {
     this.addActors("chrome://global/content/devtools/dbg-browser-actors.js");
   },
 
   /**
    * Listens on the given port for remote debugger connections.
    *
    * @param aPort int
    *        The port to listen on.
-   * @param aLocalOnly bool
-   *        If true, server will listen on the loopback device.
    */
-  openListener: function DH_openListener(aPort, aLocalOnly) {
+  openListener: function DH_openListener(aPort) {
     if (!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) {
       return false;
     }
     this._checkInit();
 
     if (this._listener) {
       throw "Debugging listener already open.";
     }
 
+    let localOnly = false;
+    // A preference setting can force binding on the loopback interface.
+    if (Services.prefs.getBoolPref("devtools.debugger.force-local")) {
+      localOnly = true;
+    }
+
     try {
-      let socket = new ServerSocket(aPort, aLocalOnly, 4);
+      let socket = new ServerSocket(aPort, localOnly, 4);
       socket.asyncListen(this);
       this._listener = socket;
     } catch (e) {
       dumpn("Could not start debugging listener on port " + aPort + ": " + e);
       throw Cr.NS_ERROR_NOT_AVAILABLE;
     }
 
     return true;
--- a/toolkit/devtools/debugger/tests/unit/test_dbgglobal.js
+++ b/toolkit/devtools/debugger/tests/unit/test_dbgglobal.js
@@ -4,36 +4,36 @@
 Cu.import("resource:///modules/devtools/dbg-server.jsm");
 Cu.import("resource:///modules/devtools/dbg-client.jsm");
 
 function run_test()
 {
   // Should get an exception if we try to interact with DebuggerServer
   // before we initialize it...
   check_except(function() {
-    DebuggerServer.openListener(2929, true);
+    DebuggerServer.openListener(2929);
   });
   check_except(DebuggerServer.closeListener);
   check_except(DebuggerServer.connectPipe);
 
   // Allow incoming connections.
   DebuggerServer.init(function () { return true; });
 
   // These should still fail because we haven't added a createRootActor
   // implementation yet.
   check_except(function() {
-    DebuggerServer.openListener(2929, true);
+    DebuggerServer.openListener(2929);
   });
   check_except(DebuggerServer.closeListener);
   check_except(DebuggerServer.connectPipe);
 
   DebuggerServer.addActors("resource://test/testactors.js");
 
   // Now they should work.
-  DebuggerServer.openListener(2929, true);
+  DebuggerServer.openListener(2929);
   DebuggerServer.closeListener();
 
   // Make sure we got the test's root actor all set up.
   let client1 = DebuggerServer.connectPipe();
   client1.hooks = {
     onPacket: function(aPacket1) {
       do_check_eq(aPacket1.from, "root");
       do_check_eq(aPacket1.applicationType, "xpcshell-tests");
--- a/toolkit/devtools/debugger/tests/unit/test_dbgsocket.js
+++ b/toolkit/devtools/debugger/tests/unit/test_dbgsocket.js
@@ -22,17 +22,17 @@ function really_long() {
   for (let i = 0; i < 18; i++) {
     ret += ret;
   }
   return ret;
 }
 
 function test_socket_conn()
 {
-  DebuggerServer.openListener(2929, true);
+  DebuggerServer.openListener(2929);
 
   let unicodeString = "(╯°□°)╯︵ ┻━┻";
   let transport = debuggerSocketConnect("127.0.0.1", 2929);
   transport.hooks = {
     onPacket: function(aPacket) {
       this.onPacket = function(aPacket) {
         do_check_eq(aPacket.unicode, unicodeString);
         transport.close();