Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
9049c1f
tls: introduce `secureContext` for `tls.connect`
indutny Dec 11, 2015
9f0ef5a
doc: fix heading type for v4.6.2 changelog
Nov 8, 2016
1dfb5b5
v8: update make-v8.sh to use git
Nov 1, 2016
620cdc5
tools: fix release script on macOS 10.12
evanlucas Sep 28, 2016
8807981
doc: fix typo in http.md
anu0012 Oct 18, 2016
f472c09
doc: reference signal(7) for the list of signals
emadb Oct 27, 2016
f669a08
src: fix typo rval to value
maasencioh Oct 11, 2016
a7ae887
governance: expand use of CTC issue tracker
Trott Oct 6, 2016
af645a0
doc: explain why GitHub merge button is not used
jalafel Oct 12, 2016
4f8bf1b
doc: explains why Reviewed-By is added in PRs
jalafel Oct 12, 2016
695ee1e
doc: highlight deprecated API in ToC
ilfroloff Sep 2, 2016
4de7a6e
build: fix config.gypi target
danbev Oct 12, 2016
9a192a9
net: fix ambiguity in EOF handling
indutny Oct 12, 2016
132425a
doc: specify that errno is a number, not a string
Oct 10, 2016
f9b24f4
test: use npm sandbox in test-npm-install
joaocgreis Oct 13, 2016
68ccc7a
doc: update reference to list hash algorithms in crypto.md
sstern6 Oct 11, 2016
e564cb6
doc: add ctc-review label information
Trott Oct 13, 2016
3b839d1
doc: remove confusing reference in governance doc
Trott Oct 13, 2016
279e30c
doc: add CTC meeting minutes for 2016-10-12
mhdawson Oct 13, 2016
3cefd65
build: export openssl symbols on windows
bnoordhuis Apr 18, 2016
84849f1
build: export more openssl symbols on Windows
Jul 10, 2016
4238460
lib: remove let from for loops
Sep 30, 2016
9b9762c
streams: fix regression in `unpipe()`
addaleax Oct 18, 2016
d9c3364
test: add regression test for `unpipe()`
Oct 18, 2016
c8dccf2
tools: avoid let in for loops
jalafel Oct 12, 2016
4a6bd86
test: fix flaky test-child-process-fork-dgram
Trott Oct 14, 2016
c94482b
http: 451 status code "Unavailable For Legal Reasons"
mbarinov Dec 21, 2015
bd99b2d
test: checking if error constructor is assert.AssertionError
larissayvette Oct 12, 2016
a038fcc
test: add regression test for instanceof
fhinkel Oct 19, 2016
a64af39
test: remove duplicate required module
Trott Oct 18, 2016
c1e5e66
doc: improve header styling for API docs
Fishrock123 Sep 27, 2016
e9c6aff
doc: add 2016-10-19 CTC meeting minutes
joshgav Oct 19, 2016
1a701f1
doc: add 2016-09-28 CTC meeting minutes
joshgav Oct 27, 2016
8240092
doc: add 2016-10-05 CTC meeting minutes
joshgav Oct 27, 2016
9dad98b
doc: add 2016-10-26 CTC meeting minutes
Trott Oct 28, 2016
d1d207b
doc: add Sakthipriyan to the CTC
rvagg Nov 2, 2016
bf25994
tls: fix leak of WriteWrap+TLSWrap combination
indutny Nov 12, 2016
0f41058
doc: clarify relation between a file and a module
marzelin Oct 11, 2016
f9baa11
tools: remove dangling eslint symlink
sam-github Oct 26, 2016
80a26c7
test: writable stream finished state
Sep 27, 2016
ba4a3ed
test: writable stream ending state
Sep 22, 2016
40ef239
test: writable stream needDrain state
Sep 27, 2016
2b2dde8
doc: add italoacasas to collaborators
Nov 18, 2016
00a1782
doc: update CONTRIBUTING.md to address editing PRs
gibfahn Oct 19, 2016
91fce10
deps: back port OpenBSD fix in c-ares/c-ares
qbit Oct 23, 2016
527db40
test: add coverage for execFileSync() errors
cjihrig Oct 20, 2016
bb2fdf5
build: cherry pick V8 change for windows DLL support
stefanmb Jul 20, 2016
f21c2b9
build: configure --shared
sxa Jul 4, 2016
0138b4d
build: windows sharedlib support
Nov 16, 2016
e97723b
build: abstract out shared library suffix
Jul 12, 2016
12da258
https: fix memory leak with https.request()
imyller Sep 18, 2016
03f7031
test: remove call to `net.Socket.resume()`
ALJCepeda Sep 21, 2016
b3fccc2
test: enable cyrillic punycode test case
bnoordhuis Sep 21, 2016
cec5e36
test: fix test-cluster-worker-init.js flakyness
imyller Sep 21, 2016
f0192ec
src: don't abort when c-ares initialization fails
bnoordhuis Sep 22, 2016
bdb6cf9
win,msi: mark INSTALLDIR property as secure
joaocgreis Sep 26, 2016
347547a
test: expand test coverage for url.js
jun-oka Sep 30, 2016
a3a184d
lib: fix TypeError in v8-polyfill
geek Sep 30, 2016
3919edb
build: don't build icu with -fno-rtti
bnoordhuis Sep 30, 2016
7904066
test: refactor test-net-server-max-connections
Trott Oct 4, 2016
c48c318
doc: change ./node to node in debugger.md
AnnaMag Oct 5, 2016
475fe96
doc: simplify process.memoryUsage() example code
watson Nov 12, 2016
9a02414
zlib: fix raw inflate with custom dictionary
thusoy Sep 20, 2016
748e424
debugger: make listen address configurable
bnoordhuis Oct 10, 2015
524ebfb
doc: child_process .stdio accepts a String type
skovhus Nov 19, 2016
66e26cd
doc: child_process.execSync .stdio default is pipe
skovhus Nov 20, 2016
4c47446
deps: make gtest output tap
bnoordhuis Aug 9, 2016
7c73105
build: run cctests as part of test-ci target
bnoordhuis Aug 10, 2016
eb34f68
deps: revert default gtest reporter change
mscdex Oct 17, 2016
747013b
test: output tap13 instead of almost-tap
jbergstroem Oct 12, 2016
36abbbe
gtest: output tap comments as yamlish
jbergstroem Oct 25, 2016
02e6c84
gitignore: ignore all tap files
jbergstroem Oct 25, 2016
4571c84
dgram: generalized send queue to handle close
mcollina May 30, 2016
a2621a2
test: remove FIXME pummel/test-tls-securepair-client
ALJCepeda Sep 24, 2016
3b448a7
lib: changed var to const in linkedlist
AdriVanHoudt Sep 17, 2016
fafffd4
test: fix test-child-process-fork-regr-gh-2847
santigimeno Oct 6, 2016
fc77cbb
doc: make node(1) more consistent with tradition
strugee Oct 8, 2016
b4353e9
src: fix typo in #endif comment
juanandresnyc Oct 9, 2016
e5d2a95
src: remove out-of-date TODO comment
danbev Oct 10, 2016
51b251d
test: add coverage for spawnSync() killSignal
cjihrig Oct 6, 2016
462c640
doc: fix typo in email address in README
Trott Oct 5, 2016
6d742b3
test: remove err timer from test-http-set-timeout
BethGriggs Oct 24, 2016
9d5e7f5
test: use strict assertions in module loader test
bnoordhuis Oct 24, 2016
533ce48
tools: make --repeat work with -j in test.py
Trott Oct 24, 2016
f18f3b6
util: use template strings
a0viedo Oct 17, 2016
ed31f9c
benchmark: add microbenchmarks for ES Map
rvagg Jul 7, 2016
59d821d
build: use wxneeded on openbsd
qbit Oct 21, 2016
bcd156f
test: refactor test-async-wrap-check-providers
Oct 26, 2016
b0476c5
test: fix flaky test-fs-watch-recursive on OS X
Trott Oct 26, 2016
e08173a
doc: fix outdate ninja link
lovexi Oct 25, 2016
d9955fb
test: add test for HTTP client "aborted" event
kemitchell Jun 22, 2016
5e820ae
doc: update Diagnostics WG info
joshgav Oct 27, 2016
2c75886
test: move timer-dependent test to sequential
Trott Nov 3, 2016
861b689
doc: update GOVERNANCE.md to use "meeting chair"
Trott Nov 3, 2016
d3c25c1
doc: update minute-taking procedure for CTC
Trott Nov 2, 2016
c5181ed
build: reduce noise from doc target
danbev Nov 4, 2016
96bdfae
test: improve test-debugger-util-regression
santigimeno Nov 6, 2016
f6f0b38
events: pass the original listener added by once
davidtaikocha Apr 29, 2016
3b5cede
src: renaming ares_task struct to node_ares_task
danbev Jun 20, 2016
51e09d0
src: normalize malloc, realloc
mhdawson Sep 1, 2016
62e83b3
src: Malloc/Calloc size 0 returns non-null pointer
Trott Sep 17, 2016
9389572
crypto: fix faulty logic in iv size check
bnoordhuis Oct 11, 2016
50a4471
http: fix connection upgrade checks
mscdex Aug 23, 2016
54c38eb
tickprocessor: apply c++filt manually on mac
indutny Sep 10, 2016
b1bd1c4
tools: allow test.py to use full paths of tests
reconbot Nov 19, 2016
9144d37
test: cleanup test-dgram-error-message-address
Goyapa Oct 5, 2016
c1effb1
deps: fix build with libc++ 3.8.0
jbergstroem Nov 23, 2016
cc36a63
test: remove watchdog in test-debug-signal-cluster
Trott Nov 5, 2016
4e73e75
2016-12-06, Version 4.7.0 'Argon' (LTS)
Nov 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
debugger: make listen address configurable
`--debug=1.2.3.4:5678` and `--debug=example.com:5678` are now accepted,
likewise the `--debug-brk` and `--debug-port` switch.  The latter is
now something of a misnomer but it's undocumented and for internal use
only so it shouldn't matter too much.

`--inspect=1.2.3.4:5678` and `--inspect=example.com:5678` are also
accepted but don't use the host name yet; they still bind to the
default address.

Fixes: #3306
PR-URL: #3316
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
bnoordhuis authored and Myles Borins committed Nov 22, 2016
commit 748e424163a616a1d2e77dc36d03c6326e961d0d
7 changes: 4 additions & 3 deletions lib/_debug_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ exports.start = function start() {
process._rawDebug(err.stack || err);
});

agent.listen(process._debugAPI.port, function() {
var addr = this.address();
process._rawDebug('Debugger listening on port %d', addr.port);
agent.listen(process._debugAPI.port, process._debugAPI.host, function() {
const addr = this.address();
const host = net.isIPv6(addr.address) ? `[${addr.address}]` : addr.address;
process._rawDebug('Debugger listening on %s:%d', host, addr.port);
process._debugAPI.notifyListen();
});

Expand Down
8 changes: 7 additions & 1 deletion src/debug-agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ using v8::Integer;
using v8::Isolate;
using v8::Local;
using v8::Locker;
using v8::NewStringType;
using v8::Object;
using v8::String;
using v8::Value;
Expand All @@ -69,7 +70,7 @@ Agent::~Agent() {
}


bool Agent::Start(int port, bool wait) {
bool Agent::Start(const std::string& host, int port, bool wait) {
int err;

if (state_ == kRunning)
Expand All @@ -85,6 +86,7 @@ bool Agent::Start(int port, bool wait) {
goto async_init_failed;
uv_unref(reinterpret_cast<uv_handle_t*>(&child_signal_));

host_ = host;
port_ = port;
wait_ = wait;

Expand Down Expand Up @@ -211,6 +213,10 @@ void Agent::InitAdaptor(Environment* env) {
Local<Object> api = t->GetFunction()->NewInstance();
api->SetAlignedPointerInInternalField(0, this);

api->Set(String::NewFromUtf8(isolate, "host",
NewStringType::kNormal).ToLocalChecked(),
String::NewFromUtf8(isolate, host_.data(), NewStringType::kNormal,
host_.size()).ToLocalChecked());
api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_));

env->process_object()->Set(String::NewFromUtf8(isolate, "_debugAPI"), api);
Expand Down
4 changes: 3 additions & 1 deletion src/debug-agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "v8-debug.h"

#include <string.h>
#include <string>

// Forward declaration to break recursive dependency chain with src/env.h.
namespace node {
Expand Down Expand Up @@ -73,7 +74,7 @@ class Agent {
typedef void (*DispatchHandler)(node::Environment* env);

// Start the debugger agent thread
bool Start(int port, bool wait);
bool Start(const std::string& host, int port, bool wait);
// Listen for debug events
void Enable();
// Stop the debugger agent
Expand Down Expand Up @@ -112,6 +113,7 @@ class Agent {

State state_;

std::string host_;
int port_;
bool wait_;

Expand Down
56 changes: 48 additions & 8 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <string>
#include <vector>

#if defined(NODE_HAVE_I18N_SUPPORT)
Expand Down Expand Up @@ -139,6 +141,7 @@ static unsigned int preload_module_count = 0;
static const char** preload_modules = nullptr;
static bool use_debug_agent = false;
static bool debug_wait_connect = false;
static std::string debug_host; // NOLINT(runtime/string)
static int debug_port = 5858;
static bool prof_process = false;
static bool v8_is_profiling = false;
Expand Down Expand Up @@ -3288,20 +3291,55 @@ static bool ParseDebugOpt(const char* arg) {
debug_wait_connect = true;
port = arg + sizeof("--debug-brk=") - 1;
} else if (!strncmp(arg, "--debug-port=", sizeof("--debug-port=") - 1)) {
// XXX(bnoordhuis) Misnomer, configures port and listen address.
port = arg + sizeof("--debug-port=") - 1;
} else {
return false;
}

if (port != nullptr) {
debug_port = atoi(port);
if (debug_port < 1024 || debug_port > 65535) {
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
PrintHelp();
exit(12);
if (port == nullptr) {
return true;
}

std::string* const the_host = &debug_host;
int* const the_port = &debug_port;

// FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js.
// It seems reasonable to support [address]:port notation
// in net.Server#listen() and net.Socket#connect().
const size_t port_len = strlen(port);
if (port[0] == '[' && port[port_len - 1] == ']') {
the_host->assign(port + 1, port_len - 2);
return true;
}

const char* const colon = strrchr(port, ':');
if (colon == nullptr) {
// Either a port number or a host name. Assume that
// if it's not all decimal digits, it's a host name.
for (size_t n = 0; port[n] != '\0'; n += 1) {
if (port[n] < '0' || port[n] > '9') {
*the_host = port;
return true;
}
}
} else {
const bool skip = (colon > port && port[0] == '[' && colon[-1] == ']');
the_host->assign(port + skip, colon - skip);
}

char* endptr;
errno = 0;
const char* const digits = colon != nullptr ? colon + 1 : port;
const long result = strtol(digits, &endptr, 10); // NOLINT(runtime/int)
if (errno != 0 || *endptr != '\0' || result < 1024 || result > 65535) {
fprintf(stderr, "Debug port must be in range 1024 to 65535.\n");
PrintHelp();
exit(12);
}

*the_port = static_cast<int>(result);

return true;
}

Expand Down Expand Up @@ -3539,9 +3577,11 @@ static void StartDebug(Environment* env, bool wait) {

env->debugger_agent()->set_dispatch_handler(
DispatchMessagesDebugAgentCallback);
debugger_running = env->debugger_agent()->Start(debug_port, wait);
debugger_running =
env->debugger_agent()->Start(debug_host, debug_port, wait);
if (debugger_running == false) {
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port);
fprintf(stderr, "Starting debugger on %s:%d failed\n",
debug_host.c_str(), debug_port);
fflush(stderr);
return;
}
Expand Down
7 changes: 2 additions & 5 deletions test/parallel/test-cluster-disconnect-handles.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ cluster.schedulingPolicy = cluster.SCHED_RR;
if (cluster.isMaster) {
let isKilling = false;
const handles = require('internal/cluster').handles;
// FIXME(bnoordhuis) lib/cluster.js scans the execArgv arguments for
// debugger flags and renumbers any port numbers it sees starting
// from the default port 5858. Add a '.' that circumvents the
// scanner but is ignored by atoi(3). Heinous hack.
cluster.setupMaster({ execArgv: [`--debug=${common.PORT}.`] });
const address = common.hasIPv6 ? '[::1]' : common.localhostIPv4;
cluster.setupMaster({ execArgv: [`--debug=${address}:${common.PORT}`] });
const worker = cluster.fork();
worker.once('exit', common.mustCall((code, signal) => {
assert.strictEqual(code, 0, 'worker did not exit normally');
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-debug-port-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ child.stderr.setEncoding('utf8');

const checkMessages = common.mustCall(() => {
for (let port = PORT_MIN; port <= PORT_MAX; port += 1) {
assert(stderr.includes(`Debugger listening on port ${port}`));
const re = RegExp(`Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):${port}`);
assert(re.test(stderr));
}
});

Expand Down
5 changes: 2 additions & 3 deletions test/parallel/test-debug-port-from-cmdline.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ function processStderrLine(line) {
function assertOutputLines() {
var expectedLines = [
'Starting debugger agent.',
'Debugger listening on port ' + debugPort
'Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):' + debugPort,
];

assert.equal(outputLines.length, expectedLines.length);
for (var i = 0; i < expectedLines.length; i++)
assert.equal(outputLines[i], expectedLines[i]);

assert(RegExp(expectedLines[i]).test(outputLines[i]));
}
5 changes: 3 additions & 2 deletions test/parallel/test-debug-port-numbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ function kill(child) {

process.on('exit', function() {
for (const child of children) {
const one = RegExp(`Debugger listening on port ${child.test.port}`);
const two = RegExp(`connecting to 127.0.0.1:${child.test.port}`);
const port = child.test.port;
const one = RegExp(`Debugger listening on (\\[::\\]|0\.0\.0\.0):${port}`);
const two = RegExp(`connecting to 127.0.0.1:${port}`);
assert(one.test(child.test.stdout));
assert(two.test(child.test.stdout));
}
Expand Down
10 changes: 6 additions & 4 deletions test/parallel/test-debug-signal-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ process.on('exit', function onExit() {

const expectedLines = [
'Starting debugger agent.',
'Debugger listening on port ' + (port + 0),
'Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):' + (port + 0),
'Starting debugger agent.',
'Debugger listening on port ' + (port + 1),
'Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):' + (port + 1),
'Starting debugger agent.',
'Debugger listening on port ' + (port + 2),
'Debugger listening on (\\[::\\]|0\\.0\\.0\\.0):' + (port + 2),
];

function assertOutputLines() {
Expand All @@ -79,5 +79,7 @@ function assertOutputLines() {
outputLines.sort();
expectedLines.sort();

assert.deepStrictEqual(outputLines, expectedLines);
assert.equal(outputLines.length, expectedLines.length);
for (var i = 0; i < expectedLines.length; i++)
assert(RegExp(expectedLines[i]).test(outputLines[i]));
}
47 changes: 47 additions & 0 deletions test/sequential/test-debug-host-port.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const spawn = require('child_process').spawn;

let run = () => {};
function test(args, re) {
const next = run;
run = () => {
const options = {encoding: 'utf8'};
const proc = spawn(process.execPath, args.concat(['-e', '0']), options);
let stderr = '';
proc.stderr.setEncoding('utf8');
proc.stderr.on('data', (data) => {
stderr += data;
if (re.test(stderr)) proc.kill();
});
proc.on('exit', common.mustCall(() => {
assert(re.test(stderr));
next();
}));
};
}

test(['--debug-brk'], /Debugger listening on (\[::\]|0\.0\.0\.0):5858/);
test(['--debug-brk=1234'], /Debugger listening on (\[::\]|0\.0\.0\.0):1234/);
test(['--debug-brk=127.0.0.1'], /Debugger listening on 127\.0\.0\.1:5858/);
test(['--debug-brk=127.0.0.1:1234'], /Debugger listening on 127\.0\.0\.1:1234/);
test(['--debug-brk=localhost'],
/Debugger listening on (\[::\]|127\.0\.0\.1):5858/);
test(['--debug-brk=localhost:1234'],
/Debugger listening on (\[::\]|127\.0\.0\.1):1234/);

if (common.hasIPv6) {
test(['--debug-brk=::'], /Debug port must be in range 1024 to 65535/);
test(['--debug-brk=::0'], /Debug port must be in range 1024 to 65535/);
test(['--debug-brk=::1'], /Debug port must be in range 1024 to 65535/);
test(['--debug-brk=[::]'], /Debugger listening on \[::\]:5858/);
test(['--debug-brk=[::0]'], /Debugger listening on \[::\]:5858/);
test(['--debug-brk=[::]:1234'], /Debugger listening on \[::\]:1234/);
test(['--debug-brk=[::0]:1234'], /Debugger listening on \[::\]:1234/);
test(['--debug-brk=[::ffff:127.0.0.1]:1234'],
/Debugger listening on \[::ffff:127\.0\.0\.1\]:1234/);
}

run(); // Runs tests in reverse order.