mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Replace of promisify for dns with dns.promises
This commit is contained in:
parent
6b454dd4d2
commit
5af13e283e
1 changed files with 3 additions and 7 deletions
|
|
@ -1,9 +1,5 @@
|
||||||
import * as dns from 'node:dns'
|
import dns from 'node:dns'
|
||||||
import punycode from 'punycode/punycode.js'
|
import punycode from 'punycode/punycode.js'
|
||||||
import { promisify } from 'node:util'
|
|
||||||
|
|
||||||
const dnsLookupAsync = promisify(dns.lookup)
|
|
||||||
const dnsResolveAsync = promisify(dns.resolve)
|
|
||||||
|
|
||||||
export default class DnsResolver {
|
export default class DnsResolver {
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,7 +38,7 @@ export default class DnsResolver {
|
||||||
this.logger.debug('SRV Resolve: ' + srvRecordPrefix + '.' + host)
|
this.logger.debug('SRV Resolve: ' + srvRecordPrefix + '.' + host)
|
||||||
let records
|
let records
|
||||||
try {
|
try {
|
||||||
records = await dnsResolveAsync(srvRecordPrefix + '.' + host, 'SRV')
|
records = await dns.promises.resolve(srvRecordPrefix + '.' + host, 'SRV')
|
||||||
if (records.length >= 1) {
|
if (records.length >= 1) {
|
||||||
this.logger.debug('Found SRV Records: ', records)
|
this.logger.debug('Found SRV Records: ', records)
|
||||||
const record = records[0]
|
const record = records[0]
|
||||||
|
|
@ -63,7 +59,7 @@ export default class DnsResolver {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug('Standard Resolve: ' + host)
|
this.logger.debug('Standard Resolve: ' + host)
|
||||||
const dnsResult = await dnsLookupAsync(host, ipFamily)
|
const dnsResult = await dns.promises.lookup(host, ipFamily)
|
||||||
// For some reason, this sometimes returns a string address rather than an object.
|
// For some reason, this sometimes returns a string address rather than an object.
|
||||||
// I haven't been able to reproduce, but it's been reported on the issue tracker.
|
// I haven't been able to reproduce, but it's been reported on the issue tracker.
|
||||||
let address
|
let address
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue