inspector: don't bind to 0.0.0.0 by default · nodejs/node@08a150f · GitHub
Skip to content

Commit 08a150f

Browse files
bnoordhuisrvagg
authored andcommitted
inspector: don't bind to 0.0.0.0 by default
Change the bind address from 0.0.0.0 to 127.0.0.1 and start respecting the address part of `--inspect=<address>:<port>` so that the bind address can be overridden by the user. Fixes: #21349 PR-URL: #21376 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 58b9497 commit 08a150f

5 files changed

Lines changed: 88 additions & 25 deletions

File tree

src/inspector_agent.cc

Lines changed: 34 additions & 18 deletions

src/inspector_agent.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class Agent {
2929
~Agent();
3030

3131
// Start the inspector agent thread
32-
bool Start(v8::Platform* platform, const char* path, int port, bool wait);
32+
bool Start(v8::Platform* platform, const char* path,
33+
const char* address, int port, bool wait);
3334
// Stop the inspector agent
3435
void Stop();
3536

src/node.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,10 @@ static struct {
232232
}
233233

234234
bool StartInspector(Environment *env, const char* script_path,
235-
int port, bool wait) {
235+
const char* host, int port, bool wait) {
236236
#if HAVE_INSPECTOR
237-
return env->inspector_agent()->Start(platform_, script_path, port, wait);
237+
return env->inspector_agent()->Start(platform_, script_path,
238+
host, port, wait);
238239
#else
239240
return true;
240241
#endif // HAVE_INSPECTOR
@@ -246,7 +247,7 @@ static struct {
246247
void PumpMessageLoop(Isolate* isolate) {}
247248
void Dispose() {}
248249
bool StartInspector(Environment *env, const char* script_path,
249-
int port, bool wait) {
250+
const char* host, int port, bool wait) {
250251
env->ThrowError("Node compiled with NODE_USE_V8_PLATFORM=0");
251252
return false; // make compiler happy
252253
}
@@ -4092,8 +4093,9 @@ static void DispatchMessagesDebugAgentCallback(Environment* env) {
40924093
static void StartDebug(Environment* env, const char* path, bool wait) {
40934094
CHECK(!debugger_running);
40944095
if (use_inspector) {
4095-
debugger_running = v8_platform.StartInspector(env, path, inspector_port,
4096-
wait);
4096+
debugger_running = v8_platform.StartInspector(env, path,
4097+
inspector_host.c_str(),
4098+
inspector_port, wait);
40974099
} else {
40984100
env->debugger_agent()->set_dispatch_handler(
40994101
DispatchMessagesDebugAgentCallback);

test/inspector/inspector-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ exports.startNodeForInspectorTest = function(callback) {
446446
clearTimeout(timeoutId);
447447
console.log('[err]', text);
448448
if (found) return;
449-
const match = text.match(/Debugger listening on port (\d+)/);
449+
const match = text.match(/Debugger listening on 127\.0\.0\.1:(\d+)\./);
450450
found = true;
451451
child.stderr.removeListener('data', dataCallback);
452452
assert.ok(match, text);
Lines changed: 44 additions & 0 deletions

0 commit comments

Comments
 (0)