Skip to content

Commit

Permalink
s/disable-network/network-disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan-Arrowood committed Feb 5, 2024
1 parent 5464e13 commit 863bbbb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions doc/api/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ meaning of `SIGUSR2` for the said purposes.
* `--report-signal` Sets or resets the signal for report generation
(not supported on Windows). Default signal is `SIGUSR2`.

* `--report-disable-network` Disable the `header.networkInterfaces` reporting.
* `--report-network-disabled` Disable the `header.networkInterfaces` reporting.
Default is `false`.

A report can also be triggered via an API call from a JavaScript application:
Expand Down Expand Up @@ -578,7 +578,7 @@ timestamp, PID, and sequence number.
written. URLs are not supported. Defaults to the current working directory of
the Node.js process.

`disableNetwork` disables the `header.networkInterfaces` reporting.
`networkDisabled` disables the `header.networkInterfaces` reporting.

```js
// Trigger report only on uncaught exceptions.
Expand All @@ -598,7 +598,7 @@ process.report.reportOnSignal = true;
process.report.signal = 'SIGQUIT';

// Disable network interfaces reporting
process.report.disableNetwork = true;
process.report.networkDisabled = true;
```

Configuration on module initialization is also available via
Expand Down
10 changes: 5 additions & 5 deletions lib/internal/process/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ const report = {
validateBoolean(b, 'compact');
nr.setCompact(b);
},
get disableNetwork() {
return nr.getDisableNetwork();
get networkDisabled() {
return nr.getNetworkDisabled();
},
set disableNetwork(b) {
validateBoolean(b, 'disableNetwork');
nr.setDisableNetwork(b);
set networkDisabled(b) {
validateBoolean(b, 'networkDisabled');
nr.setNetworkDisabled(b);
},
get signal() {
return nr.getSignal();
Expand Down
4 changes: 2 additions & 2 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
&EnvironmentOptions::tls_max_v1_3,
kAllowedInEnvvar);

AddOption("--report-disable-network",
AddOption("--report-network-disabled",
"disable network interface diagnostics."
" (default: false)",
&EnvironmentOptions::report_disable_network,
&EnvironmentOptions::report_network_disabled,
kAllowedInEnvvar);
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class EnvironmentOptions : public Options {

std::vector<std::string> user_argv;

bool report_disable_network = false;
bool report_network_disabled = false;

inline DebugOptions* get_debug_options() { return &debug_options_; }
inline const DebugOptions& debug_options() const { return debug_options_; }
Expand Down
24 changes: 12 additions & 12 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ static void WriteNodeReport(Isolate* isolate,
std::ostream& out,
Local<Value> error,
bool compact,
bool disable_network = false);
bool network_disabled = false);
static void PrintVersionInformation(JSONWriter* writer,
bool disable_network = false);
bool network_disabled = false);
static void PrintJavaScriptErrorStack(JSONWriter* writer,
Isolate* isolate,
Local<Value> error,
Expand Down Expand Up @@ -96,7 +96,7 @@ static void WriteNodeReport(Isolate* isolate,
std::ostream& out,
Local<Value> error,
bool compact,
bool disable_network) {
bool network_disabled) {
// Obtain the current time and the pid.
TIME_TYPE tm_struct;
DiagnosticFilename::LocalTime(&tm_struct);
Expand Down Expand Up @@ -177,7 +177,7 @@ static void WriteNodeReport(Isolate* isolate,
}

// Report Node.js and OS version information
PrintVersionInformation(&writer, disable_network);
PrintVersionInformation(&writer, network_disabled);
writer.json_objectend();

if (isolate != nullptr) {
Expand Down Expand Up @@ -259,7 +259,7 @@ static void WriteNodeReport(Isolate* isolate,
}

// Report Node.js version, OS version and machine information.
static void PrintVersionInformation(JSONWriter* writer, bool disable_network) {
static void PrintVersionInformation(JSONWriter* writer, bool network_disabled) {
std::ostringstream buf;
// Report Node version
buf << "v" << NODE_VERSION_STRING;
Expand Down Expand Up @@ -303,7 +303,7 @@ static void PrintVersionInformation(JSONWriter* writer, bool disable_network) {
}

PrintCpuInfo(writer);
if (!disable_network)
if (!network_disabled)
PrintNetworkInterfaceInfo(writer);

char host[UV_MAXHOSTNAMESIZE];
Expand Down Expand Up @@ -921,7 +921,7 @@ std::string TriggerNodeReport(Isolate* isolate,
compact = per_process::cli_options->report_compact;
}

bool disable_network = env->options()->report_disable_network;
bool network_disabled = env->options()->report_network_disabled;

report::WriteNodeReport(
isolate,
Expand All @@ -932,7 +932,7 @@ std::string TriggerNodeReport(Isolate* isolate,
*outstream,
error,
compact,
disable_network);
network_disabled);

// Do not close stdout/stderr, only close files we opened.
if (outfile.is_open()) {
Expand Down Expand Up @@ -983,9 +983,9 @@ void GetNodeReport(Isolate* isolate,
if (isolate != nullptr) {
env = Environment::GetCurrent(isolate);
}
bool disable_network = env->options()->report_disable_network;
bool network_disabled = env->options()->report_network_disabled;
report::WriteNodeReport(
isolate, env, message, trigger, "", out, error, false, disable_network);
isolate, env, message, trigger, "", out, error, false, network_disabled);
}

// External function to trigger a report, writing to a supplied stream.
Expand All @@ -998,9 +998,9 @@ void GetNodeReport(Environment* env,
if (env != nullptr) {
isolate = env->isolate();
}
bool disable_network = env->options()->report_disable_network;
bool network_disabled = env->options()->report_network_disabled;
report::WriteNodeReport(
isolate, env, message, trigger, "", out, error, false, disable_network);
isolate, env, message, trigger, "", out, error, false, network_disabled);
}

} // namespace node
16 changes: 8 additions & 8 deletions src/node_report_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ static void SetCompact(const FunctionCallbackInfo<Value>& info) {
per_process::cli_options->report_compact = compact;
}

static void GetDisableNetwork(const FunctionCallbackInfo<Value>& info) {
static void GetNetworkDisabled(const FunctionCallbackInfo<Value>& info) {
Environment* env = Environment::GetCurrent(info);
info.GetReturnValue().Set(env->options()->report_disable_network);
info.GetReturnValue().Set(env->options()->report_network_disabled);
}

static void SetDisableNetwork(const FunctionCallbackInfo<Value>& info) {
static void SetNetworkDisabled(const FunctionCallbackInfo<Value>& info) {
Mutex::ScopedLock lock(per_process::cli_options_mutex);
Environment* env = Environment::GetCurrent(info);
Isolate* isolate = env->isolate();
env->options()->report_disable_network = info[0]->ToBoolean(isolate)->Value();
env->options()->report_network_disabled = info[0]->ToBoolean(isolate)->Value();
}

static void GetDirectory(const FunctionCallbackInfo<Value>& info) {
Expand Down Expand Up @@ -186,8 +186,8 @@ static void Initialize(Local<Object> exports,
SetMethod(context, exports, "getReport", GetReport);
SetMethod(context, exports, "getCompact", GetCompact);
SetMethod(context, exports, "setCompact", SetCompact);
SetMethod(context, exports, "getDisableNetwork", GetDisableNetwork);
SetMethod(context, exports, "setDisableNetwork", SetDisableNetwork);
SetMethod(context, exports, "getNetworkDisabled", GetNetworkDisabled);
SetMethod(context, exports, "setNetworkDisabled", SetNetworkDisabled);
SetMethod(context, exports, "getDirectory", GetDirectory);
SetMethod(context, exports, "setDirectory", SetDirectory);
SetMethod(context, exports, "getFilename", GetFilename);
Expand All @@ -214,8 +214,8 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(GetReport);
registry->Register(GetCompact);
registry->Register(SetCompact);
registry->Register(GetDisableNetwork);
registry->Register(SetDisableNetwork);
registry->Register(GetNetworkDisabled);
registry->Register(SetNetworkDisabled);
registry->Register(GetDirectory);
registry->Register(SetDirectory);
registry->Register(GetFilename);
Expand Down
16 changes: 8 additions & 8 deletions test/report/test-report-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ assert.throws(() => {
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.compact, true);

// Verify that process.report.reportDisableNetwork behaves properly.
assert.strictEqual(process.report.disableNetwork, false);
process.report.disableNetwork = true;
assert.strictEqual(process.report.disableNetwork, true);
process.report.disableNetwork = false;
assert.strictEqual(process.report.disableNetwork, false);
// Verify that process.report.networkDisabled behaves properly.
assert.strictEqual(process.report.networkDisabled, false);
process.report.networkDisabled = true;
assert.strictEqual(process.report.networkDisabled, true);
process.report.networkDisabled = false;
assert.strictEqual(process.report.networkDisabled, false);
assert.throws(() => {
process.report.disableNetwork = {};
process.report.networkDisabled = {};
}, { code: 'ERR_INVALID_ARG_TYPE' });
assert.strictEqual(process.report.disableNetwork, false);
assert.strictEqual(process.report.networkDisabled, false);

if (!common.isWindows) {
// Verify that process.report.signal behaves properly.
Expand Down
10 changes: 5 additions & 5 deletions test/report/test-report-disable-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ function validate(pid) {
fs.unlinkSync(reports[0]);
}

describe('report disable network option', () => {
describe('report network disabled option', () => {
before(() => {
tmpdir.refresh();
process.report.directory = tmpdir.path;
});

it('should be configurable with --report-disable-network', () => {
const args = ['--report-disable-network', '-e', 'process.report.writeReport()'];
it('should be configurable with --report-network-disabled', () => {
const args = ['--report-network-disabled', '-e', 'process.report.writeReport()'];
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
validate(child.pid);
});

it('should be configurable with report.disableNetwork', () => {
process.report.disableNetwork = true;
it('should be configurable with report.networkDisabled', () => {
process.report.networkDisabled = true;
process.report.writeReport();
validate(process.pid);

Expand Down

0 comments on commit 863bbbb

Please sign in to comment.