Skip to content

Commit

Permalink
crypto: move process.binding('tls_wrap') internal
Browse files Browse the repository at this point in the history
This commit makes the tls_wrap builtin an internal builtin, and
changes usage of the builtin from using process.binding('tls_wrap')
to use internalBinding instead.

Refs: #22160
  • Loading branch information
danbev committed Aug 24, 2018
1 parent 656da16 commit e0c6943
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ const common = require('_tls_common');
const { StreamWrap } = require('_stream_wrap');
const { Buffer } = require('buffer');
const debug = util.debuglog('tls');
const tls_wrap = process.binding('tls_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
const tls_wrap = internalBinding('tls_wrap');
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@
'signal_wrap',
'crypto',
'contextify',
'tcp_wrap']);
'tcp_wrap',
'tls_wrap']);
process.binding = function binding(name) {
return internalBindingWhitelist.has(name) ?
internalBinding(name) :
Expand Down
2 changes: 1 addition & 1 deletion src/tls_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -915,4 +915,4 @@ void TLSWrap::Initialize(Local<Object> target,

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(tls_wrap, node::TLSWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(tls_wrap, node::TLSWrap::Initialize)
4 changes: 3 additions & 1 deletion test/parallel/test-tls-wrap-no-abort.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Flags: --expose-internals
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const util = require('util');
const TLSWrap = process.binding('tls_wrap').TLSWrap;
const { internalBinding } = require('internal/test/binding');
const TLSWrap = internalBinding('tls_wrap').TLSWrap;

// This will abort if internal pointer is not set to nullptr.
util.inspect(new TLSWrap());
2 changes: 1 addition & 1 deletion test/sequential/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
const credentials = require('tls').createSecureContext({ ca, cert, key });

// TLSWrap is exposed, but needs to be instantiated via tls_wrap.wrap().
const tls_wrap = process.binding('tls_wrap');
const tls_wrap = internalBinding('tls_wrap');
testInitialized(
tls_wrap.wrap(tcp._externalStream, credentials.context, true), 'TLSWrap');
}
Expand Down

0 comments on commit e0c6943

Please sign in to comment.