mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
feat: Allow direct control of IP family to be returned by DNS lookup
implements #306
This commit is contained in:
parent
70ec2a45a7
commit
3c38fe48fe
4 changed files with 9 additions and 7 deletions
|
|
@ -20,10 +20,11 @@ class DnsResolver {
|
|||
/**
|
||||
* Response port will only be present if srv record was involved.
|
||||
* @param {string} host
|
||||
* @param {number} ipFamily
|
||||
* @param {string=} srvRecordPrefix
|
||||
* @returns {Promise<{address:string, port:number=}>}
|
||||
*/
|
||||
async resolve(host, srvRecordPrefix) {
|
||||
async resolve(host, ipFamily, srvRecordPrefix) {
|
||||
this.logger.debug("DNS Lookup: " + host);
|
||||
|
||||
if(this.isIp(host)) {
|
||||
|
|
@ -52,7 +53,7 @@ class DnsResolver {
|
|||
}
|
||||
return {
|
||||
port: srvPort,
|
||||
...await this.resolve(srvHost, srvRecordPrefix)
|
||||
...await this.resolve(srvHost, ipFamily, srvRecordPrefix)
|
||||
};
|
||||
}
|
||||
this.logger.debug("No SRV Record");
|
||||
|
|
@ -62,7 +63,7 @@ class DnsResolver {
|
|||
}
|
||||
|
||||
this.logger.debug("Standard Resolve: " + host);
|
||||
const dnsResult = await dnsLookupAsync(host);
|
||||
const dnsResult = await dnsLookupAsync(host, ipFamily);
|
||||
// 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.
|
||||
let address;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue