-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
58b9497
commit 08a150f
Showing
5 changed files
with
88 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
const { PORT, mustCall, skipIfInspectorDisabled } = require('../common'); | ||
|
||
skipIfInspectorDisabled(); | ||
|
||
const assert = require('assert'); | ||
const { spawn } = require('child_process'); | ||
|
||
function test(arg, expected, done) { | ||
const args = [arg, '-p', 'process.debugPort']; | ||
const proc = spawn(process.execPath, args); | ||
proc.stdout.setEncoding('utf8'); | ||
proc.stderr.setEncoding('utf8'); | ||
let stdout = ''; | ||
let stderr = ''; | ||
proc.stdout.on('data', (data) => stdout += data); | ||
proc.stderr.on('data', (data) => stderr += data); | ||
proc.stdout.on('close', (hadErr) => assert(!hadErr)); | ||
proc.stderr.on('close', (hadErr) => assert(!hadErr)); | ||
proc.stderr.on('data', () => { | ||
if (!stderr.includes('\n')) return; | ||
assert(/Debugger listening on (.+)\./.test(stderr)); | ||
assert.strictEqual(RegExp.$1, expected); | ||
}); | ||
proc.on('exit', (exitCode, signalCode) => { | ||
assert.strictEqual(exitCode, 0); | ||
assert.strictEqual(signalCode, null); | ||
done(); | ||
}); | ||
} | ||
|
||
function one() { | ||
test(`--inspect=${PORT}`, `127.0.0.1:${PORT}`, mustCall(two)); | ||
} | ||
|
||
function two() { | ||
test(`--inspect=0.0.0.0:${PORT}`, `0.0.0.0:${PORT}`, mustCall(three)); | ||
} | ||
|
||
function three() { | ||
test(`--inspect=127.0.0.1:${PORT}`, `127.0.0.1:${PORT}`, mustCall()); | ||
} | ||
|
||
one(); |