refactor: 1
parent
091cbc5336
commit
6125895ae6
|
@ -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 []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue