Skip to content

Commit

Permalink
Revert "Implement the remote debugging feature. (#919)" (#999)
Browse files Browse the repository at this point in the history
This reverts commit bb670e8.
  • Loading branch information
hustxiaoc authored Apr 12, 2017
1 parent bb670e8 commit 5785df1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 59 deletions.
4 changes: 0 additions & 4 deletions front-end-node/NodeInspectorOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ WebInspector.NodeInspectorOverrides.prototype = {
var params = Runtime._queryParamsObject;
params['port'] = params['port'] || '5858';
params['ws'] = params['ws'] || (location.host + location.pathname);
if (params['host']) {
params['ws'] += /\?/.test(params['ws']) ? '&' : '?';
params['ws'] += 'host=' + params['host'];
}
params['ws'] += /\?/.test(params['ws']) ? '&' : '?';
params['ws'] += 'port=' + params['port'];
},
Expand Down
20 changes: 2 additions & 18 deletions lib/DebuggerClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var extend = require('util')._extend;
var EventEmitter = require('events').EventEmitter,
inherits = require('util').inherits,
os = require('os'),
DebugConnection = require('./debugger.js');

function createFailingConnection(reason) {
Expand All @@ -22,9 +21,8 @@ function createFailingConnection(reason) {
* @constructor
* @param {number} debuggerPort
*/
function DebuggerClient(debuggerHost, debuggerPort) {
function DebuggerClient(debuggerPort) {
this._conn = createFailingConnection('node-inspector server was restarted');
this._host = debuggerHost;
this._port = debuggerPort;

this.target = null;
Expand All @@ -50,25 +48,11 @@ Object.defineProperties(DebuggerClient.prototype, {
get: function() {
return this._conn.connected && !!this.target;
}
},

isHostMachine: {
get: function() {
var addresses = ['localhost', '0.0.0.0'];
var ifaces = os.networkInterfaces();
for (var name in ifaces) {
var ifaceAddresses = ifaces[name].map( function(iface) {
return iface['address'];
});
addresses = addresses.concat(ifaceAddresses);
}
return (addresses.indexOf(this._host) >= 0);
}
}
});

DebuggerClient.prototype.connect = function() {
this._conn = DebugConnection.attachDebugger(this._host, this._port);
this._conn = DebugConnection.attachDebugger(this._port);
this.pendingEvents = [];
this._conn
.on('connect', this._onConnectionOpen.bind(this))
Expand Down
6 changes: 0 additions & 6 deletions lib/InjectorClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ InjectorClient.prototype.inject = function(cb) {

var _water = [];

if (this.needsInject && !this._debuggerClient.isHostMachine) {
console.log('node process is running on the remote machine.');
console.log('In this case, --inject option is ignored.');
this._noInject = true;
}

if (this.needsInject) {
_water.unshift(
this._injectRequire.bind(this),
Expand Down
4 changes: 1 addition & 3 deletions lib/PageAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ extend(PageAgent.prototype, {
_doGetResourceTree: function(params, done) {
var cwd = this._debuggerClient.target.cwd;
var filename = this._debuggerClient.target.filename;
if (!this._debuggerClient.isHostMachine) {
return done();
}

async.waterfall(
[
this._resolveMainAppScript.bind(this, cwd, filename),
Expand Down
10 changes: 0 additions & 10 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ var definitions = {
_isNodeDebugOption: true,
default: 5858
},
'debug-host': {
type: 'string',
description: 'Host to run Node/V8 debugger.',
usage: {
'--debug-host 127.0.0.1': '',
'--debug-host www.example.com': ''
},
_isNodeInspectorOption: true,
default: '127.0.0.1'
},
'save-live-edit': {
type: 'boolean',
description: 'Save live edit changes to disk (update the edited files).',
Expand Down
16 changes: 5 additions & 11 deletions lib/debug-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ function protocolJson(req, res) {
}

function handleWebSocketConnection(socket) {
var debugPort = this._getDebuggerPort(socket.upgradeReq.url),
debugHost = this._getDebuggerHost(socket.upgradeReq.url);
this._createSession(debugHost, debugPort, socket);
var debugPort = this._getDebuggerPort(socket.upgradeReq.url);
this._createSession(debugPort, socket);
}

function handleServerListening() {
Expand Down Expand Up @@ -145,19 +144,14 @@ DebugServer.prototype._getDebuggerPort = function(url) {
return parseInt((/[\?\&]port=(\d+)/.exec(url) || [null, this._config.debugPort])[1], 10);
};

DebugServer.prototype._getDebuggerHost = function(url) {
return (/[\?\&]host=([0-9.]+)/.exec(url) || [null, this._config.debugHost])[1];
};

DebugServer.prototype._getUrlFromReq = function(req) {
var urlParts = req.headers.host.split(':'),
debugPort = this._getDebuggerPort(req.url),
debugHost = this._getDebuggerHost(req.url);
debugPort = this._getDebuggerPort(req.url);
return buildInspectorUrl(urlParts[0], urlParts[1], debugPort, this._isHTTPS);
};

DebugServer.prototype._createSession = function(debugHost, debugPort, wsConnection) {
return new Session(this._config, debugHost, debugPort, wsConnection);
DebugServer.prototype._createSession = function(debugPort, wsConnection) {
return new Session(this._config, debugPort, wsConnection);
};

DebugServer.prototype.close = function() {
Expand Down
9 changes: 4 additions & 5 deletions lib/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ var Net = require('net'),
/**
* @param {Number} port
*/
function Debugger(host, port){
this._host = host;
function Debugger(port){
this._port = port;
this._connected = false;
this._connection = null;
Expand All @@ -34,7 +33,7 @@ Object.defineProperties(Debugger.prototype, {
});

Debugger.prototype._setupConnection = function() {
var connection = Net.createConnection(this._port, this._host),
var connection = Net.createConnection(this._port),
protocol = new Protocol();

protocol.onResponse = this._processResponse.bind(this);
Expand Down Expand Up @@ -152,6 +151,6 @@ Debugger.prototype.close = function() {
* @param {Number} port
* @type {Debugger}
*/
module.exports.attachDebugger = function(host, port) {
return new Debugger(host, port);
module.exports.attachDebugger = function(port) {
return new Debugger(port);
};
4 changes: 2 additions & 2 deletions lib/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var EventEmitter = require('events').EventEmitter,
HeapProfilerClient = require('./HeapProfilerClient').HeapProfilerClient,
InjectorClient = require('./InjectorClient').InjectorClient;

function Session(config, debuggerHost, debuggerPort, wsConnection) {
this.debuggerClient = new DebuggerClient(debuggerHost, debuggerPort);
function Session(config, debuggerPort, wsConnection) {
this.debuggerClient = new DebuggerClient(debuggerPort);
this.frontendClient = new FrontendClient(wsConnection);
this.injectorClient = new InjectorClient(config, this);
this.consoleClient = new ConsoleClient(config, this);
Expand Down

0 comments on commit 5785df1

Please sign in to comment.