optimize: 优化DNS配置解析

release-2.0.0.2
王良 2025-03-05 21:28:27 +08:00
parent 93af0c9c70
commit 1e68ae5a8a
12 changed files with 93 additions and 76 deletions

View File

@ -33,8 +33,9 @@ class IpCache extends DynamicChoice {
} }
module.exports = class BaseDNS { module.exports = class BaseDNS {
constructor (dnsName, cacheSize, preSetIpList) { constructor (dnsName, dnsType, cacheSize, preSetIpList) {
this.dnsName = dnsName this.dnsName = dnsName
this.dnsType = dnsType
this.preSetIpList = preSetIpList this.preSetIpList = preSetIpList
this.cache = new LRUCache({ this.cache = new LRUCache({
maxSize: (cacheSize > 0 ? cacheSize : defaultCacheSize), maxSize: (cacheSize > 0 ? cacheSize : defaultCacheSize),
@ -73,11 +74,11 @@ module.exports = class BaseDNS {
ipList.push(hostname) // 把原域名加入到统计里去 ipList.push(hostname) // 把原域名加入到统计里去
ipCache.setBackupList(ipList) ipCache.setBackupList(ipList)
log.info(`[DNS '${this.dnsName}']: ${hostname}${ipCache.value} (${new Date() - t} ms), ipList: ${JSON.stringify(ipList)}, ipCache:`, JSON.stringify(ipCache)) log.info(`[DNS-over-${this.dnsType} '${this.dnsName}'] ${hostname}${ipCache.value} (${new Date() - t} ms), ipList: ${JSON.stringify(ipList)}, ipCache:`, JSON.stringify(ipCache))
return ipCache.value return ipCache.value
} catch (error) { } catch (error) {
log.error(`[DNS '${this.dnsName}'] cannot resolve hostname ${hostname}, error:`, error) log.error(`[DNS-over-${this.dnsType} '${this.dnsName}'] cannot resolve hostname ${hostname}, error:`, error)
return hostname return hostname
} }
} }
@ -94,6 +95,7 @@ module.exports = class BaseDNS {
if (hostnamePreSetIpList.length > 0) { if (hostnamePreSetIpList.length > 0) {
hostnamePreSetIpList.isPreSet = true hostnamePreSetIpList.isPreSet = true
log.info(`[DNS-over-${this.dnsType} '${this.dnsName}'] 获取到该域名的预设IP列表 ${hostname} - ${JSON.stringify(hostnamePreSetIpList)}`)
return hostnamePreSetIpList return hostnamePreSetIpList
} }
} }
@ -108,18 +110,18 @@ module.exports = class BaseDNS {
const cost = Date.now() - start const cost = Date.now() - start
if (response == null || response.answers == null || response.answers.length == null || response.answers.length === 0) { if (response == null || response.answers == null || response.answers.length == null || response.answers.length === 0) {
// 说明没有获取到ip // 说明没有获取到ip
log.warn(`DNS '${this.dnsName}' 没有该域名的IP地址: ${hostname}, cost: ${cost} ms, response:`, response) log.warn(`[DNS-over-${this.dnsType} '${this.dnsName}'] 没有该域名的IP地址: ${hostname}, cost: ${cost} ms, response:`, response)
return [] return []
} }
const ret = response.answers.filter(item => item.type === 'A').map(item => item.data) const ret = response.answers.filter(item => item.type === 'A').map(item => item.data)
if (ret.length === 0) { if (ret.length === 0) {
log.info(`DNS '${this.dnsName}' 没有该域名的IPv4地址: ${hostname}, cost: ${cost} ms`) log.info(`[DNS-over-${this.dnsType} '${this.dnsName}'] 没有该域名的IPv4地址: ${hostname}, cost: ${cost} ms`)
} else { } else {
log.info(`DNS '${this.dnsName}' 获取到该域名的IPv4地址 ${hostname} - ${JSON.stringify(ret)}, cost: ${cost} ms`) log.info(`[DNS-over-${this.dnsType} '${this.dnsName}'] 获取到该域名的IPv4地址 ${hostname} - ${JSON.stringify(ret)}, cost: ${cost} ms`)
} }
return ret return ret
} catch (e) { } catch (e) {
log.error(`DNS query error: ${hostname}, dns: ${this.dnsName}${this.dnsServer ? (`, dnsServer: ${this.dnsServer}`) : ''}, cost: ${Date.now() - start} ms, error:`, e) log.error(`[DNS-over-${this.dnsType} '${this.dnsName}'] DNS query error, hostname: ${hostname}${this.dnsServer ? `, dnsServer: ${this.dnsServer}` : ''}, cost: ${Date.now() - start} ms, error:`, e)
return [] return []
} }
} }

View File

@ -6,7 +6,7 @@ const dohQueryAsync = promisify(doh.query)
module.exports = class DNSOverHTTPS extends BaseDNS { module.exports = class DNSOverHTTPS extends BaseDNS {
constructor (dnsName, cacheSize, preSetIpList, dnsServer) { constructor (dnsName, cacheSize, preSetIpList, dnsServer) {
super(dnsName, cacheSize, preSetIpList) super(dnsName, 'HTTPS', cacheSize, preSetIpList)
this.dnsServer = dnsServer this.dnsServer = dnsServer
} }

View File

@ -13,6 +13,7 @@ module.exports = {
for (const provider in dnsProviders) { for (const provider in dnsProviders) {
const conf = dnsProviders[provider] const conf = dnsProviders[provider]
// 获取DNS服务器
let server = conf.server || conf.host let server = conf.server || conf.host
if (server != null) { if (server != null) {
server = server.replace(/\s+/, '') server = server.replace(/\s+/, '')
@ -22,44 +23,55 @@ module.exports = {
} }
// 获取DNS类型 // 获取DNS类型
if (conf.type == null) { let type = conf.type
if (type == null) {
if (server.startsWith('https://') || server.startsWith('http://')) { if (server.startsWith('https://') || server.startsWith('http://')) {
conf.type = 'https' type = 'https'
} else if (server.startsWith('tls://')) { } else if (server.startsWith('tls://')) {
conf.type = 'tls' type = 'tls'
} else if (server.startsWith('tcp://')) { } else if (server.startsWith('tcp://')) {
conf.type = 'tcp' type = 'tcp'
} else if (server.includes('://') && !server.startsWith('udp://')) { } else if (server.includes('://') && !server.startsWith('udp://')) {
throw new Error(`Unknown type DNS: ${server}, provider: ${provider}`) throw new Error(`Unknown type DNS: ${server}, provider: ${provider}`)
} else { } else {
conf.type = 'udp' type = 'udp'
} }
} else { } else {
conf.type = conf.type.toLowerCase() type = type.replace(/\s+/, '').toLowerCase()
} }
if (conf.type === 'https') { // 创建DNS对象
if (type === 'https' || type === 'doh' || type === 'dns-over-https') {
if (!server.includes('/')) {
server = `https://${server}/dns-query`
}
// 基于 https
dnsMap[provider] = new DNSOverHTTPS(provider, conf.cacheSize, preSetIpList, server) dnsMap[provider] = new DNSOverHTTPS(provider, conf.cacheSize, preSetIpList, server)
} else if (conf.type === 'tls') { } else {
if (server.startsWith('tls://')) { // 获取DNS端口
server = server.substring(6) let port = conf.port
}
dnsMap[provider] = new DNSOverTLS(provider, conf.cacheSize, preSetIpList, server, conf.port, conf.servername)
} else if (conf.type === 'tcp') {
if (server.startsWith('tcp://')) {
server = server.substring(6)
}
dnsMap[provider] = new DNSOverTCP(provider, conf.cacheSize, preSetIpList, server, conf.port)
} else { // udp
if (server.startsWith('udp://')) {
server = server.substring(6)
}
dnsMap[provider] = new DNSOverUDP(provider, conf.cacheSize, preSetIpList, server, conf.port)
}
// 设置DNS名称到name属性中 // 处理带协议的DNS服务地址
dnsMap[provider].name = provider if (server.includes('://')) {
dnsMap[provider].type = conf.type server = server.split('://')[1]
}
// 处理带端口的DNS服务地址
if (port == null && server.includes(':')) {
[server, port] = server.split(':')
}
if (type === 'tls' || type === 'dot' || type === 'dns-over-tls') {
// 基于 tls
dnsMap[provider] = new DNSOverTLS(provider, conf.cacheSize, preSetIpList, server, port, conf.servername)
} else if (type === 'tcp' || type === 'dns-over-tcp') {
// 基于 tcp
dnsMap[provider] = new DNSOverTCP(provider, conf.cacheSize, preSetIpList, server, port)
} else {
// 基于 udp
dnsMap[provider] = new DNSOverUDP(provider, conf.cacheSize, preSetIpList, server, port)
}
}
} }
// 创建预设IP的DNS // 创建预设IP的DNS

View File

@ -1,4 +0,0 @@
module.exports = {
lookup () {
},
}

View File

@ -2,9 +2,7 @@ const BaseDNS = require('./base')
module.exports = class DNSOverPreSetIpList extends BaseDNS { module.exports = class DNSOverPreSetIpList extends BaseDNS {
constructor (preSetIpList) { constructor (preSetIpList) {
super('PreSet', null, preSetIpList) super('PreSet', 'PreSet', null, preSetIpList)
this.name = 'PreSet'
this.type = 'PreSet'
} }
async _lookup (_hostname) { async _lookup (_hostname) {

View File

@ -8,7 +8,7 @@ const defaultPort = 53 // UDP类型的DNS服务默认端口号
module.exports = class DNSOverTCP extends BaseDNS { module.exports = class DNSOverTCP extends BaseDNS {
constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort) { constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort) {
super(dnsName, cacheSize, preSetIpList) super(dnsName, 'TCP', cacheSize, preSetIpList)
this.dnsServer = dnsServer this.dnsServer = dnsServer
this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort
} }

View File

@ -5,7 +5,7 @@ const defaultPort = 853
module.exports = class DNSOverTLS extends BaseDNS { module.exports = class DNSOverTLS extends BaseDNS {
constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort, dnsServerName) { constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort, dnsServerName) {
super(dnsName, cacheSize, preSetIpList) super(dnsName, 'TLS', cacheSize, preSetIpList)
this.dnsServer = dnsServer this.dnsServer = dnsServer
this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort
this.dnsServerName = dnsServerName this.dnsServerName = dnsServerName

View File

@ -9,7 +9,7 @@ const defaultPort = 53 // UDP类型的DNS服务默认端口号
module.exports = class DNSOverUDP extends BaseDNS { module.exports = class DNSOverUDP extends BaseDNS {
constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort) { constructor (dnsName, cacheSize, preSetIpList, dnsServer, dnsServerPort) {
super(dnsName, cacheSize, preSetIpList) super(dnsName, 'UDP', cacheSize, preSetIpList)
this.dnsServer = dnsServer this.dnsServer = dnsServer
this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort this.dnsServerPort = Number.parseInt(dnsServerPort) || defaultPort
} }

View File

@ -143,7 +143,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) { if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) {
const { dns, ip, hostname } = isDnsIntercept const { dns, ip, hostname } = isDnsIntercept
dns.count(hostname, ip, true) dns.count(hostname, ip, true)
log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${errorMsg}, dns: ${dns.name}`) log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${errorMsg}, dns: ${dns.dnsName}`)
} }
}) })
proxySocket.on('error', (e) => { proxySocket.on('error', (e) => {
@ -157,7 +157,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig = null, isDire
if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) { if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) {
const { dns, ip, hostname } = isDnsIntercept const { dns, ip, hostname } = isDnsIntercept
dns.count(hostname, ip, true) dns.count(hostname, ip, true)
log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${errorMsg}, dns: ${dns.name}`) log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${errorMsg}, dns: ${dns.dnsName}`)
} }
}) })

View File

@ -84,7 +84,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) { if (isDnsIntercept && isDnsIntercept.dns && isDnsIntercept.ip !== isDnsIntercept.hostname) {
const { dns, ip, hostname } = isDnsIntercept const { dns, ip, hostname } = isDnsIntercept
dns.count(hostname, ip, true) dns.count(hostname, ip, true)
log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${reason}, dns: ${dns.name}`) log.error(`记录ip失败次数用于优选ip hostname: ${hostname}, ip: ${ip}, reason: ${reason}, dns: ${dns.dnsName}`)
} }
const counter = context.requestCount const counter = context.requestCount
if (counter != null) { if (counter != null) {
@ -123,8 +123,8 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
} }
if (dns) { if (dns) {
rOptions.lookup = dnsLookup.createLookupFunc(res, dns, 'request url', url, isDnsIntercept) rOptions.lookup = dnsLookup.createLookupFunc(res, dns, 'request url', url, isDnsIntercept)
log.debug(`域名 ${rOptions.hostname} DNS: ${dns.name}`) log.debug(`域名 ${rOptions.hostname} DNS: ${dns.dnsName}`)
res.setHeader('DS-DNS', dns.name) res.setHeader('DS-DNS', dns.dnsName)
} else { } else {
log.info(`域名 ${rOptions.hostname} 在DNS中未配置`) log.info(`域名 ${rOptions.hostname} 在DNS中未配置`)
} }

View File

@ -43,15 +43,15 @@ module.exports = {
} }
} }
if (isTestFailedIp === false) { if (isTestFailedIp === false) {
log.info(`----- ${action}: ${hostname}, use ip from dns '${dns.name}': ${ip}${target} -----`) log.info(`----- ${action}: ${hostname}, use ip from dns '${dns.dnsName}': ${ip}${target} -----`)
if (res) { if (res) {
res.setHeader('DS-DNS-Lookup', `DNS: ${ip} ${dns.name === '预设IP' ? 'PreSet' : dns.name}`) res.setHeader('DS-DNS-Lookup', `DNS: ${ip} ${dns.dnsName === '预设IP' ? 'PreSet' : dns.dnsName}`)
} }
callback(null, ip, 4) callback(null, ip, 4)
return return
} else { } else {
// 使用默认dns // 使用默认dns
log.info(`----- ${action}: ${hostname}, use hostname by default DNS: ${hostname}, skip test failed ip from dns '${dns.name}: ${ip}'${target}, options:`, options) log.info(`----- ${action}: ${hostname}, use hostname by default DNS: ${hostname}, skip test failed ip from dns '${dns.dnsName}: ${ip}'${target}, options:`, options)
} }
} else { } else {
// 使用默认dns // 使用默认dns

View File

@ -1,7 +1,13 @@
import assert from 'node:assert' import assert from 'node:assert'
import dns from '../src/lib/dns/index.js' import dns from '../src/lib/dns/index.js'
import matchUtil from '../src/utils/util.match.js'
const presetIp = '100.100.100.100' const presetIp = '100.100.100.100'
const preSetIpList = matchUtil.domainMapRegexply({
'xxx.com': [
presetIp
]
})
const dnsProviders = dns.initDNS({ const dnsProviders = dns.initDNS({
// https // https
@ -19,6 +25,11 @@ const dnsProviders = dns.initDNS({
server: 'https://dns.alidns.com/dns-query', server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000, cacheSize: 1000,
}, },
aliyun2: {
type: 'https',
server: 'dns.alidns.com', // 会自动补上 `https://` 和 `/dns-query`
cacheSize: 1000,
},
safe360: { safe360: {
server: 'https://doh.360.cn/dns-query', server: 'https://doh.360.cn/dns-query',
cacheSize: 1000, cacheSize: 1000,
@ -45,8 +56,7 @@ const dnsProviders = dns.initDNS({
cacheSize: 1000, cacheSize: 1000,
}, },
aliyunTLS: { aliyunTLS: {
type: 'tls', server: 'tls://223.5.5.5:853',
server: '223.5.5.5',
cacheSize: 1000, cacheSize: 1000,
}, },
aliyunTLS2: { aliyunTLS2: {
@ -62,6 +72,7 @@ const dnsProviders = dns.initDNS({
googleTCP: { googleTCP: {
type: 'tcp', type: 'tcp',
server: '8.8.8.8', server: '8.8.8.8',
port: 53,
cacheSize: 1000, cacheSize: 1000,
}, },
aliyunTCP: { aliyunTCP: {
@ -79,13 +90,7 @@ const dnsProviders = dns.initDNS({
server: 'udp://223.5.5.5', server: 'udp://223.5.5.5',
cacheSize: 1000, cacheSize: 1000,
}, },
}, { }, preSetIpList)
origin: {
'xxx.com': [
presetIp
]
}
})
const presetHostname = 'xxx.com' const presetHostname = 'xxx.com'
@ -111,27 +116,31 @@ ip = await dnsProviders.cloudflare.lookup(presetHostname)
assert.strictEqual(ip, presetIp) // test preset assert.strictEqual(ip, presetIp) // test preset
console.log('\n\n') console.log('\n\n')
assert.strictEqual(dnsProviders.cloudflare.type, 'https') assert.strictEqual(dnsProviders.cloudflare.dnsType, 'HTTPS')
// ip = await dnsProviders.cloudflare.lookup(hostname1) // ip = await dnsProviders.cloudflare.lookup(hostname1)
// console.log('===> test cloudflare:', ip, '\n\n') // console.log('===> test cloudflare:', ip, '\n\n')
assert.strictEqual(dnsProviders.quad9.type, 'https') assert.strictEqual(dnsProviders.quad9.dnsType, 'HTTPS')
// ip = await dnsProviders.quad9.lookup(hostname1) // ip = await dnsProviders.quad9.lookup(hostname1)
// console.log('===> test quad9:', ip, '\n\n') // console.log('===> test quad9:', ip, '\n\n')
assert.strictEqual(dnsProviders.aliyun.type, 'https') assert.strictEqual(dnsProviders.aliyun.dnsType, 'HTTPS')
// ip = await dnsProviders.aliyun.lookup(hostname1) // ip = await dnsProviders.aliyun.lookup(hostname1)
// console.log('===> test aliyun:', ip, '\n\n') // console.log('===> test aliyun:', ip, '\n\n')
assert.strictEqual(dnsProviders.safe360.type, 'https') assert.strictEqual(dnsProviders.aliyun2.dnsType, 'HTTPS')
// ip = await dnsProviders.aliyun2.lookup(hostname1)
// console.log('===> test aliyun2:', ip, '\n\n')
assert.strictEqual(dnsProviders.safe360.dnsType, 'HTTPS')
// ip = await dnsProviders.safe360.lookup(hostname1) // ip = await dnsProviders.safe360.lookup(hostname1)
// console.log('===> test safe360:', ip, '\n\n') // console.log('===> test safe360:', ip, '\n\n')
assert.strictEqual(dnsProviders.rubyfish.type, 'https') assert.strictEqual(dnsProviders.rubyfish.dnsType, 'HTTPS')
// ip = await dnsProviders.rubyfish.lookup(hostname1) // ip = await dnsProviders.rubyfish.lookup(hostname1)
// console.log('===> test rubyfish:', ip, '\n\n') // console.log('===> test rubyfish:', ip, '\n\n')
assert.strictEqual(dnsProviders.py233.type, 'https') assert.strictEqual(dnsProviders.py233.dnsType, 'HTTPS')
// ip = await dnsProviders.py233.lookup(hostname1) // ip = await dnsProviders.py233.lookup(hostname1)
// console.log('===> test py233:', ip, '\n\n') // console.log('===> test py233:', ip, '\n\n')
@ -141,23 +150,23 @@ ip = await dnsProviders.cloudflareTLS.lookup(presetHostname)
assert.strictEqual(ip, presetIp) // test preset assert.strictEqual(ip, presetIp) // test preset
console.log('\n\n') console.log('\n\n')
assert.strictEqual(dnsProviders.cloudflareTLS.type, 'tls') assert.strictEqual(dnsProviders.cloudflareTLS.dnsType, 'TLS')
// ip = await dnsProviders.cloudflareTLS.lookup(hostname1) // ip = await dnsProviders.cloudflareTLS.lookup(hostname1)
// console.log('===> test cloudflareTLS:', ip, '\n\n') // console.log('===> test cloudflareTLS:', ip, '\n\n')
assert.strictEqual(dnsProviders.quad9TLS.type, 'tls') assert.strictEqual(dnsProviders.quad9TLS.dnsType, 'TLS')
// ip = await dnsProviders.quad9TLS.lookup(hostname1) // ip = await dnsProviders.quad9TLS.lookup(hostname1)
// console.log('===> test quad9TLS:', ip, '\n\n') // console.log('===> test quad9TLS:', ip, '\n\n')
assert.strictEqual(dnsProviders.aliyunTLS.type, 'tls') assert.strictEqual(dnsProviders.aliyunTLS.dnsType, 'TLS')
// ip = await dnsProviders.aliyunTLS.lookup(hostname1) // ip = await dnsProviders.aliyunTLS.lookup(hostname1)
// console.log('===> test aliyunTLS:', ip, '\n\n') // console.log('===> test aliyunTLS:', ip, '\n\n')
assert.strictEqual(dnsProviders.aliyunTLS2.type, 'tls') assert.strictEqual(dnsProviders.aliyunTLS2.dnsType, 'TLS')
// ip = await dnsProviders.aliyunTLS2.lookup(hostname1) // ip = await dnsProviders.aliyunTLS2.lookup(hostname1)
// console.log('===> test aliyunTLS2:', ip, '\n\n') // console.log('===> test aliyunTLS2:', ip, '\n\n')
assert.strictEqual(dnsProviders.safe360TLS.type, 'tls') assert.strictEqual(dnsProviders.safe360TLS.dnsType, 'TLS')
// ip = await dnsProviders.safe360TLS.lookup(hostname1) // ip = await dnsProviders.safe360TLS.lookup(hostname1)
// console.log('===> test safe360TLS:', ip, '\n\n') // console.log('===> test safe360TLS:', ip, '\n\n')
@ -167,11 +176,11 @@ ip = await dnsProviders.googleTCP.lookup(presetHostname)
assert.strictEqual(ip, presetIp) // test preset assert.strictEqual(ip, presetIp) // test preset
console.log('\n\n') console.log('\n\n')
assert.strictEqual(dnsProviders.googleTCP.type, 'tcp') assert.strictEqual(dnsProviders.googleTCP.dnsType, 'TCP')
// ip = await dnsProviders.googleTCP.lookup(hostname1) // ip = await dnsProviders.googleTCP.lookup(hostname1)
// console.log('===> test googleTCP:', ip, '\n\n') // console.log('===> test googleTCP:', ip, '\n\n')
assert.strictEqual(dnsProviders.aliyunTCP.type, 'tcp') assert.strictEqual(dnsProviders.aliyunTCP.dnsType, 'TCP')
// ip = await dnsProviders.aliyunTCP.lookup(hostname1) // ip = await dnsProviders.aliyunTCP.lookup(hostname1)
// console.log('===> test aliyunTCP:', ip, '\n\n') // console.log('===> test aliyunTCP:', ip, '\n\n')
@ -181,10 +190,10 @@ ip = await dnsProviders.googleUDP.lookup(presetHostname)
assert.strictEqual(ip, presetIp) // test preset assert.strictEqual(ip, presetIp) // test preset
console.log('\n\n') console.log('\n\n')
assert.strictEqual(dnsProviders.googleUDP.type, 'udp') assert.strictEqual(dnsProviders.googleUDP.dnsType, 'UDP')
// ip = await dnsProviders.googleUDP.lookup(hostname1) // ip = await dnsProviders.googleUDP.lookup(hostname1)
// console.log('===> test googleUDP:', ip, '\n\n') // console.log('===> test googleUDP:', ip, '\n\n')
assert.strictEqual(dnsProviders.aliyunUDP.type, 'udp') assert.strictEqual(dnsProviders.aliyunUDP.dnsType, 'UDP')
// ip = await dnsProviders.aliyunUDP.lookup(hostname1) // ip = await dnsProviders.aliyunUDP.lookup(hostname1)
// console.log('===> test aliyunUDP:', ip, '\n\n') // console.log('===> test aliyunUDP:', ip, '\n\n')