|
|
|
@ -38,22 +38,23 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 未预设当前域名的IP列表,则从dns服务器获取
|
|
|
|
|
const start = new Date() |
|
|
|
|
try { |
|
|
|
|
const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }]) |
|
|
|
|
if (result.answers.length === 0) { |
|
|
|
|
// 说明没有获取到ip
|
|
|
|
|
log.info('该域名没有ip地址解析:', hostname) |
|
|
|
|
log.info('该域名没有ip地址解析:', hostname, ', cost:', (new Date() - start), 'ms') |
|
|
|
|
return [] |
|
|
|
|
} |
|
|
|
|
const ret = result.answers.filter(item => item.type === 'A').map(item => item.data) |
|
|
|
|
if (ret.length === 0) { |
|
|
|
|
log.info('该域名没有IPv4地址解析:', hostname) |
|
|
|
|
log.info('该域名没有IPv4地址解析:', hostname, ', cost:', (new Date() - start), 'ms') |
|
|
|
|
} else { |
|
|
|
|
log.info('获取到域名地址:', hostname, JSON.stringify(ret)) |
|
|
|
|
log.info('获取到域名地址:', hostname, JSON.stringify(ret), ', cost:', (new Date() - start), 'ms') |
|
|
|
|
} |
|
|
|
|
return ret |
|
|
|
|
} catch (e) { |
|
|
|
|
log.warn('DNS query error:', hostname, ', dns:', this.dnsServer, ', error:', e) |
|
|
|
|
log.warn('DNS query error:', hostname, ', dns:', this.dnsServer, ', cost:', (new Date() - start), 'ms, error:', e) |
|
|
|
|
return [] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|