diff options
Diffstat (limited to 'lib/dns.js')
-rw-r--r-- | lib/dns.js | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/lib/dns.js b/lib/dns.js index 92b55f0359..979d724c3e 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -24,7 +24,7 @@ const util = require('util'); const cares = process.binding('cares_wrap'); -const { isLegalPort } = require('internal/net'); +const { isIP, isIPv4, isLegalPort } = require('internal/net'); const { customPromisifyArgs } = require('internal/util'); const errors = require('internal/errors'); const { @@ -38,7 +38,6 @@ const { GetNameInfoReqWrap, QueryReqWrap, ChannelWrap, - isIP } = cares; function errnoException(err, syscall, hostname) { @@ -66,30 +65,6 @@ function errnoException(err, syscall, hostname) { } const IANA_DNS_PORT = 53; -const digits = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0-15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48-63 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 64-79 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-95 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 96-111 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 112-127 -]; -function isIPv4(str) { - if (!digits[str.charCodeAt(0)]) return false; - if (str.length === 1) return false; - if (str.charCodeAt(1) === 46/*'.'*/) - return true; - else if (!digits[str.charCodeAt(1)]) - return false; - if (str.length === 2) return false; - if (str.charCodeAt(2) === 46/*'.'*/) - return true; - else if (!digits[str.charCodeAt(2)]) - return false; - return (str.length > 3 && str.charCodeAt(3) === 46/*'.'*/); -} function onlookup(err, addresses) { |