refactor: 1

pull/180/head
xiaojunnuo@qq.com 2020-11-09 10:01:58 +08:00
parent 091cbc5336
commit 6125895ae6
1 changed files with 16 additions and 11 deletions

View File

@ -11,6 +11,7 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
} }
async _lookup (hostname) { async _lookup (hostname) {
try {
const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }]) const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }])
if (result.answers.length === 0) { if (result.answers.length === 0) {
// 说明没有获取到ip // 说明没有获取到ip
@ -24,5 +25,9 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
console.log('获取到域名地址:', hostname, JSON.stringify(ret)) console.log('获取到域名地址:', hostname, JSON.stringify(ret))
} }
return ret return ret
} catch (err) {
console.log('dns query error', hostname, err)
return []
}
} }
} }