diff --git a/lib/DnsResolver.js b/lib/DnsResolver.js index 8cadd8f..e7238d2 100644 --- a/lib/DnsResolver.js +++ b/lib/DnsResolver.js @@ -1,6 +1,6 @@ import dns from 'node:dns' import { isIP } from 'node:net' -import punycode from 'punycode/punycode.js' +import { domainToASCII } from 'node:url' export default class DnsResolver { /** @@ -30,7 +30,11 @@ export default class DnsResolver { return { address: host } } - const asciiForm = punycode.toASCII(host) + const asciiForm = domainToASCII(host) + if (!asciiForm) { + throw new Error('Invalid domain') + } + if (asciiForm !== host) { this.logger.debug('Encoded punycode: ' + host + ' -> ' + asciiForm) host = asciiForm diff --git a/package-lock.json b/package-lock.json index e5a0bfd..5945826 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,6 @@ "iconv-lite": "0.6.3", "long": "5.2.3", "minimist": "1.2.8", - "punycode": "2.3.1", "seek-bzip": "2.0.0", "varint": "6.0.0" }, @@ -2839,6 +2838,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, "engines": { "node": ">=6" } @@ -5440,7 +5440,8 @@ "punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==" + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true }, "queue-microtask": { "version": "1.2.3", diff --git a/package.json b/package.json index 5755101..9a88fa0 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,6 @@ "iconv-lite": "0.6.3", "long": "5.2.3", "minimist": "1.2.8", - "punycode": "2.3.1", "seek-bzip": "2.0.0", "varint": "6.0.0" },