dns: make process.binding('cares_wrap') internal

PR-URL: https://github.com/nodejs/node/pull/22474
Refs: https://github.com/nodejs/node/issues/22160
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
cjihrig 2018-08-23 09:28:41 -04:00
parent 60465700ed
commit 8b0c482647
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
11 changed files with 20 additions and 12 deletions

View File

@ -21,7 +21,8 @@
'use strict';
const cares = process.binding('cares_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const cares = internalBinding('cares_wrap');
const { isIP, isIPv4, isLegalPort } = require('internal/net');
const { customPromisifyArgs } = require('internal/util');
const errors = require('internal/errors');

View File

@ -348,6 +348,7 @@
// internalBinding.
const internalBindingWhitelist =
new SafeSet([
'cares_wrap',
'fs_event_wrap',
'uv',
'pipe_wrap',

View File

@ -6,6 +6,7 @@ const {
} = require('internal/dns/utils');
const { codes, dnsException } = require('internal/errors');
const { isIP, isIPv4, isLegalPort } = require('internal/net');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
getaddrinfo,
getnameinfo,
@ -13,7 +14,7 @@ const {
GetAddrInfoReqWrap,
GetNameInfoReqWrap,
QueryReqWrap
} = process.binding('cares_wrap');
} = internalBinding('cares_wrap');
const {
ERR_INVALID_ARG_TYPE,
ERR_INVALID_OPT_VALUE,

View File

@ -1,12 +1,13 @@
'use strict';
const errors = require('internal/errors');
const { isIP } = require('internal/net');
const { internalBinding } = require('internal/bootstrap/loaders');
const {
ChannelWrap,
strerror,
AI_ADDRCONFIG,
AI_V4MAPPED
} = process.binding('cares_wrap');
} = internalBinding('cares_wrap');
const IANA_DNS_PORT = 53;
const IPv6RE = /^\[([^[\]]*)\]/;
const addrSplitRE = /(^.+?)(?::(\d+))?$/;

View File

@ -1,7 +1,8 @@
'use strict';
const Buffer = require('buffer').Buffer;
const { isIPv6 } = process.binding('cares_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const { isIPv6 } = internalBinding('cares_wrap');
const { writeBuffer } = process.binding('fs');
const errors = require('internal/errors');

View File

@ -35,7 +35,7 @@ const { Buffer } = require('buffer');
const EventEmitter = require('events');
const { URL } = require('internal/url');
const DuplexPair = require('internal/streams/duplexpair');
const { canonicalizeIP } = process.binding('cares_wrap');
const { canonicalizeIP } = internalBinding('cares_wrap');
const _tls_common = require('_tls_common');
const _tls_wrap = require('_tls_wrap');

View File

@ -2238,4 +2238,4 @@ void Initialize(Local<Object> target,
} // namespace cares_wrap
} // namespace node
NODE_BUILTIN_MODULE_CONTEXT_AWARE(cares_wrap, node::cares_wrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(cares_wrap, node::cares_wrap::Initialize)

View File

@ -1,3 +1,4 @@
// Flags: --expose-internals
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
@ -22,6 +23,7 @@
'use strict';
const common = require('../common');
const { addresses } = require('../common/internet');
const { internalBinding } = require('internal/test/binding');
const assert = require('assert');
const dns = require('dns');
const net = require('net');
@ -674,7 +676,7 @@ let getaddrinfoCallbackCalled = false;
console.log(`looking up ${addresses.INET4_HOST}..`);
const cares = process.binding('cares_wrap');
const cares = internalBinding('cares_wrap');
const req = new cares.GetAddrInfoReqWrap();
cares.getaddrinfo(req, addresses.INET4_HOST, 4,
/* hints */ 0, /* verbatim */ true);

View File

@ -3,12 +3,11 @@
const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const { internalBinding } = require('internal/test/binding');
const cares = internalBinding('cares_wrap');
const dns = require('dns');
const dnsPromises = dns.promises;
const { internalBinding } = require('internal/test/binding');
// Stub `getaddrinfo` to *always* error.
cares.getaddrinfo = () => internalBinding('uv').UV_ENOENT;

View File

@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';
require('../common');
@ -6,7 +7,8 @@ require('../common');
// of a TLS certificate
const assert = require('assert');
const { canonicalizeIP } = process.binding('cares_wrap');
const { internalBinding } = require('internal/test/binding');
const { canonicalizeIP } = internalBinding('cares_wrap');
assert.strictEqual(canonicalizeIP('127.0.0.1'), '127.0.0.1');
assert.strictEqual(canonicalizeIP('10.1.0.1'), '10.1.0.1');

View File

@ -69,7 +69,7 @@ function testInitialized(req, ctor_name) {
{
const cares = process.binding('cares_wrap');
const cares = internalBinding('cares_wrap');
const dns = require('dns');
testUninitialized(new cares.GetAddrInfoReqWrap(), 'GetAddrInfoReqWrap');