feat: SNI默认使用的DNS,可在 `DNS服务管理` 中配置。
parent
60386edc07
commit
7f86c455b0
|
@ -393,6 +393,7 @@ const defaultConfig = {
|
|||
type: 'https',
|
||||
server: 'https://doh.360.cn/dns-query',
|
||||
cacheSize: 1000,
|
||||
forSNI: true,
|
||||
},
|
||||
rubyfish: {
|
||||
type: 'https',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const matchUtil = require('../../utils/util.match')
|
||||
const log = require('../../utils/util.log.server')
|
||||
const DNSOverPreSetIpList = require('./preset.js')
|
||||
const DNSOverHTTPS = require('./https.js')
|
||||
const DNSOverTLS = require('./tls.js')
|
||||
|
@ -72,10 +73,19 @@ module.exports = {
|
|||
dnsMap[provider] = new DNSOverUDP(provider, conf.cacheSize, preSetIpList, server, port)
|
||||
}
|
||||
}
|
||||
|
||||
if (conf.forSNI || conf.forSni) {
|
||||
dnsMap.ForSNI = dnsMap[provider]
|
||||
}
|
||||
}
|
||||
|
||||
// 创建预设IP的DNS
|
||||
dnsMap.PreSet = new DNSOverPreSetIpList(preSetIpList)
|
||||
if (dnsMap.ForSNI == null) {
|
||||
dnsMap.ForSNI = dnsMap.PreSet
|
||||
}
|
||||
|
||||
log.info(`设置SNI默认使用的DNS为 '${dnsMap.ForSNI.dnsName}'(注:当某个域名配置了SNI但未配置DNS时,将默认使用该DNS)`)
|
||||
|
||||
return dnsMap
|
||||
},
|
||||
|
|
|
@ -116,9 +116,11 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
|
|||
if (dnsConfig && dnsConfig.dnsMap) {
|
||||
let dns = DnsUtil.hasDnsLookup(dnsConfig, rOptions.hostname)
|
||||
if (!dns && rOptions.servername) {
|
||||
dns = dnsConfig.dnsMap.quad9
|
||||
dns = dnsConfig.dnsMap.ForSNI
|
||||
if (dns) {
|
||||
log.info(`域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.servername}, 必须使用dns,现默认使用 'quad9' DNS.`)
|
||||
log.info(`域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.servername}, 必须使用dns,现默认使用 '${dns.dnsName}' DNS.`)
|
||||
} else {
|
||||
log.warn(`域名 ${rOptions.hostname} 在dns中未配置,但使用了 sni: ${rOptions.servername},且DNS服务管理中,也未指定SNI默认使用的DNS。`)
|
||||
}
|
||||
}
|
||||
if (dns) {
|
||||
|
|
Loading…
Reference in New Issue