src: move process.binding('tcp_wrap') to internal
This commit makes the tcp_wrap builtin an internal builtin, and changes usage of the builtin from using process.binding('tcp_wrap') to use internalBinding instead. Refs: https://github.com/nodejs/node/issues/22160 PR-URL: https://github.com/nodejs/node/pull/22432 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
56e331a2a2
commit
57d98bc732
@ -33,10 +33,10 @@ const { StreamWrap } = require('_stream_wrap');
|
|||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const debug = util.debuglog('tls');
|
const debug = util.debuglog('tls');
|
||||||
const tls_wrap = process.binding('tls_wrap');
|
const tls_wrap = process.binding('tls_wrap');
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const { internalBinding } = require('internal/bootstrap/loaders');
|
||||||
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
||||||
const { owner_symbol } = require('internal/async_hooks').symbols;
|
const { owner_symbol } = require('internal/async_hooks').symbols;
|
||||||
const { internalBinding } = require('internal/bootstrap/loaders');
|
|
||||||
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
|
const { SecureContext: NativeSecureContext } = internalBinding('crypto');
|
||||||
const {
|
const {
|
||||||
ERR_INVALID_ARG_TYPE,
|
ERR_INVALID_ARG_TYPE,
|
||||||
|
@ -352,7 +352,8 @@
|
|||||||
'stream_wrap',
|
'stream_wrap',
|
||||||
'signal_wrap',
|
'signal_wrap',
|
||||||
'crypto',
|
'crypto',
|
||||||
'contextify']);
|
'contextify',
|
||||||
|
'tcp_wrap']);
|
||||||
process.binding = function binding(name) {
|
process.binding = function binding(name) {
|
||||||
return internalBindingWhitelist.has(name) ?
|
return internalBindingWhitelist.has(name) ?
|
||||||
internalBinding(name) :
|
internalBinding(name) :
|
||||||
|
@ -27,7 +27,7 @@ const { Process } = process.binding('process_wrap');
|
|||||||
const { WriteWrap } = internalBinding('stream_wrap');
|
const { WriteWrap } = internalBinding('stream_wrap');
|
||||||
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
||||||
const { TTY } = process.binding('tty_wrap');
|
const { TTY } = process.binding('tty_wrap');
|
||||||
const { TCP } = process.binding('tcp_wrap');
|
const { TCP } = internalBinding('tcp_wrap');
|
||||||
const { UDP } = process.binding('udp_wrap');
|
const { UDP } = process.binding('udp_wrap');
|
||||||
const SocketList = require('internal/socket_list');
|
const SocketList = require('internal/socket_list');
|
||||||
const { owner_symbol } = require('internal/async_hooks').symbols;
|
const { owner_symbol } = require('internal/async_hooks').symbols;
|
||||||
|
@ -48,7 +48,7 @@ const {
|
|||||||
TCP,
|
TCP,
|
||||||
TCPConnectWrap,
|
TCPConnectWrap,
|
||||||
constants: TCPConstants
|
constants: TCPConstants
|
||||||
} = process.binding('tcp_wrap');
|
} = internalBinding('tcp_wrap');
|
||||||
const {
|
const {
|
||||||
Pipe,
|
Pipe,
|
||||||
PipeConnectWrap,
|
PipeConnectWrap,
|
||||||
|
@ -375,4 +375,4 @@ Local<Object> AddressToJS(Environment* env,
|
|||||||
|
|
||||||
} // namespace node
|
} // namespace node
|
||||||
|
|
||||||
NODE_BUILTIN_MODULE_CONTEXT_AWARE(tcp_wrap, node::TCPWrap::Initialize)
|
NODE_MODULE_CONTEXT_AWARE_INTERNAL(tcp_wrap, node::TCPWrap::Initialize)
|
||||||
|
@ -444,7 +444,8 @@ function _mustCallInner(fn, criteria = 1, field) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.hasMultiLocalhost = function hasMultiLocalhost() {
|
exports.hasMultiLocalhost = function hasMultiLocalhost() {
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const t = new TCP(TCPConstants.SOCKET);
|
const t = new TCP(TCPConstants.SOCKET);
|
||||||
const ret = t.bind('127.0.0.2', 0);
|
const ret = t.bind('127.0.0.2', 0);
|
||||||
t.close();
|
t.close();
|
||||||
|
@ -7,7 +7,8 @@ if (common.isWindows)
|
|||||||
const dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { kStateSymbol } = require('internal/dgram');
|
const { kStateSymbol } = require('internal/dgram');
|
||||||
const { TCP, constants } = process.binding('tcp_wrap');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { TCP, constants } = internalBinding('tcp_wrap');
|
||||||
const TYPE = 'udp4';
|
const TYPE = 'udp4';
|
||||||
|
|
||||||
// Throw when the fd is occupied according to https://github.com/libuv/libuv/pull/1851.
|
// Throw when the fd is occupied according to https://github.com/libuv/libuv/pull/1851.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (common.isWindows)
|
if (common.isWindows)
|
||||||
@ -6,7 +7,8 @@ if (common.isWindows)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const dgram = require('dgram');
|
const dgram = require('dgram');
|
||||||
const { UDP } = process.binding('udp_wrap');
|
const { UDP } = process.binding('udp_wrap');
|
||||||
const { TCP, constants } = process.binding('tcp_wrap');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { TCP, constants } = internalBinding('tcp_wrap');
|
||||||
const _createSocketHandle = dgram._createSocketHandle;
|
const _createSocketHandle = dgram._createSocketHandle;
|
||||||
|
|
||||||
// Return a negative number if the "existing fd" is invalid.
|
// Return a negative number if the "existing fd" is invalid.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
require('../common');
|
||||||
|
|
||||||
@ -5,14 +6,15 @@ require('../common');
|
|||||||
// being generated by Environment::NewFunctionTemplate.
|
// being generated by Environment::NewFunctionTemplate.
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
|
||||||
[
|
[
|
||||||
process.binding('udp_wrap').UDP.prototype.bind6,
|
process.binding('udp_wrap').UDP.prototype.bind6,
|
||||||
process.binding('tcp_wrap').TCP.prototype.bind6,
|
internalBinding('tcp_wrap').TCP.prototype.bind6,
|
||||||
process.binding('udp_wrap').UDP.prototype.send6,
|
process.binding('udp_wrap').UDP.prototype.send6,
|
||||||
process.binding('tcp_wrap').TCP.prototype.bind,
|
internalBinding('tcp_wrap').TCP.prototype.bind,
|
||||||
process.binding('udp_wrap').UDP.prototype.close,
|
process.binding('udp_wrap').UDP.prototype.close,
|
||||||
process.binding('tcp_wrap').TCP.prototype.open
|
internalBinding('tcp_wrap').TCP.prototype.open
|
||||||
].forEach((binding, i) => {
|
].forEach((binding, i) => {
|
||||||
assert.strictEqual('prototype' in binding, false, `Test ${i} failed`);
|
assert.strictEqual('prototype' in binding, false, `Test ${i} failed`);
|
||||||
});
|
});
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasMultiLocalhost())
|
if (!common.hasMultiLocalhost())
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const TCPWrap = process.binding('tcp_wrap').TCP;
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const TCPWrap = internalBinding('tcp_wrap').TCP;
|
||||||
|
|
||||||
const echoServer = net.createServer(function(connection) {
|
const echoServer = net.createServer(function(connection) {
|
||||||
connection.end();
|
connection.end();
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const TCPWrap = process.binding('tcp_wrap').TCP;
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const TCPWrap = internalBinding('tcp_wrap').TCP;
|
||||||
|
|
||||||
const echoServer = net.createServer(function(conn) {
|
const echoServer = net.createServer(function(conn) {
|
||||||
conn.end();
|
conn.end();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
@ -5,7 +6,8 @@ const assert = require('assert');
|
|||||||
const net = require('net');
|
const net = require('net');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { getSystemErrorName } = require('util');
|
const { getSystemErrorName } = require('util');
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
|
||||||
|
|
||||||
const tmpdir = require('../common/tmpdir');
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
@ -3,8 +3,11 @@
|
|||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const {
|
||||||
const { TCPConnectWrap } = process.binding('tcp_wrap');
|
TCP,
|
||||||
|
constants: TCPConstants,
|
||||||
|
TCPConnectWrap
|
||||||
|
} = internalBinding('tcp_wrap');
|
||||||
const { ShutdownWrap } = internalBinding('stream_wrap');
|
const { ShutdownWrap } = internalBinding('stream_wrap');
|
||||||
|
|
||||||
function makeConnection() {
|
function makeConnection() {
|
||||||
|
@ -4,7 +4,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const { WriteWrap } = internalBinding('stream_wrap');
|
const { WriteWrap } = internalBinding('stream_wrap');
|
||||||
|
|
||||||
const server = new TCP(TCPConstants.SOCKET);
|
const server = new TCP(TCPConstants.SOCKET);
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
|
||||||
const { internalBinding } = require('internal/test/binding');
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const { UV_EINVAL } = internalBinding('uv');
|
const { UV_EINVAL } = internalBinding('uv');
|
||||||
|
|
||||||
const handle = new TCP(TCPConstants.SOCKET);
|
const handle = new TCP(TCPConstants.SOCKET);
|
||||||
|
@ -207,7 +207,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
|||||||
|
|
||||||
{
|
{
|
||||||
const stream_wrap = internalBinding('stream_wrap');
|
const stream_wrap = internalBinding('stream_wrap');
|
||||||
const tcp_wrap = process.binding('tcp_wrap');
|
const tcp_wrap = internalBinding('tcp_wrap');
|
||||||
const server = net.createServer(common.mustCall((socket) => {
|
const server = net.createServer(common.mustCall((socket) => {
|
||||||
server.close();
|
server.close();
|
||||||
socket.on('data', () => {
|
socket.on('data', () => {
|
||||||
@ -256,7 +256,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
|||||||
|
|
||||||
|
|
||||||
if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
|
||||||
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
|
const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap');
|
||||||
const tcp = new TCP(TCPConstants.SOCKET);
|
const tcp = new TCP(TCPConstants.SOCKET);
|
||||||
|
|
||||||
const ca = fixtures.readSync('test_ca.pem', 'ascii');
|
const ca = fixtures.readSync('test_ca.pem', 'ascii');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user