Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b929988

Browse filesBrowse files
benjamingrjasnell
authored andcommitted
dns: use isIp consistently
Currently the DNS module imports isIP from both cares and `net` and uses both of them both throughout the code base. This PR removes the direct dependency `dns` has on `net` and uses `isIp` from c-ares all the time. Note that both functions do the same thing. PR-URL: #5804 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ccb7b45 commit b929988
Copy full SHA for b929988

File tree

Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed
Open diff view settings
Collapse file

‎lib/dns.js‎

Copy file name to clipboardExpand all lines: lib/dns.js
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const net = require('net');
43
const util = require('util');
54

65
const cares = process.binding('cares_wrap');
@@ -11,7 +10,7 @@ const GetAddrInfoReqWrap = cares.GetAddrInfoReqWrap;
1110
const GetNameInfoReqWrap = cares.GetNameInfoReqWrap;
1211
const QueryReqWrap = cares.QueryReqWrap;
1312

14-
const isIp = net.isIP;
13+
const isIP = cares.isIP;
1514
const isLegalPort = internalNet.isLegalPort;
1615

1716

@@ -148,7 +147,7 @@ exports.lookup = function lookup(hostname, options, callback) {
148147
return {};
149148
}
150149

151-
var matchedFamily = net.isIP(hostname);
150+
var matchedFamily = isIP(hostname);
152151
if (matchedFamily) {
153152
if (all) {
154153
callback(null, [{address: hostname, family: matchedFamily}]);
@@ -188,7 +187,7 @@ exports.lookupService = function(host, port, callback) {
188187
if (arguments.length !== 3)
189188
throw new Error('Invalid arguments');
190189

191-
if (cares.isIP(host) === 0)
190+
if (isIP(host) === 0)
192191
throw new TypeError('"host" argument needs to be a valid IP address');
193192

194193
if (port == null || !isLegalPort(port))
@@ -290,7 +289,7 @@ exports.setServers = function(servers) {
290289
var newSet = [];
291290

292291
servers.forEach(function(serv) {
293-
var ver = isIp(serv);
292+
var ver = isIP(serv);
294293

295294
if (ver)
296295
return newSet.push([ver, serv]);
@@ -299,13 +298,13 @@ exports.setServers = function(servers) {
299298

300299
// we have an IPv6 in brackets
301300
if (match) {
302-
ver = isIp(match[1]);
301+
ver = isIP(match[1]);
303302
if (ver)
304303
return newSet.push([ver, match[1]]);
305304
}
306305

307306
var s = serv.split(/:\d+$/)[0];
308-
ver = isIp(s);
307+
ver = isIP(s);
309308

310309
if (ver)
311310
return newSet.push([ver, s]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.