optimize: usa重命名为cloudflare后,向下兼容原来的usa配置。

pull/321/head
王良 5 months ago
parent d1555d3238
commit 01e395c20b

@ -218,9 +218,9 @@ const intercepts = {
```js
dns: {
mapping: {
'api.github.com': 'usa', // "解决push的时候需要输入密码的问题",
'gist.github.com': 'usa' // 解决gist无法访问的问题
'*.githubusercontent.com': 'usa' // 解决github头像经常下载不到的问题
'api.github.com': 'cloudflare', // "解决push的时候需要输入密码的问题",
'gist.github.com': 'cloudflare' // 解决gist无法访问的问题
'*.githubusercontent.com': 'cloudflare' // 解决github头像经常下载不到的问题
}
}
```

@ -1,3 +1,4 @@
<!--
<template>
<a-drawer
:title="title"
@ -33,7 +34,7 @@
</a-col>
<a-col :span="5">
<a-select :disabled="item.value === false" v-model="item.value">
<a-select-option value="usa">USA DNS</a-select-option>
<a-select-option value="cloudflare">CloudFlare DNS</a-select-option>
<a-select-option value="aliyun">Aliyun DNS</a-select-option>
</a-select>
</a-col>
@ -246,3 +247,4 @@ export default {
margin-bottom: 10px;
}
</style>
-->

@ -7,7 +7,6 @@
</template>
<div style="height: 100%" class="json-wrapper">
<a-tabs
default-active-key="1"
tab-position="left"
@ -194,7 +193,7 @@
<a-icon v-if="item.alive.length>0" type="check"/>
<a-icon v-else type="info-circle"/>
</a>
<a-tag style="margin:2px;" v-for="(element,index) of item.backupList"
<a-tag style="margin:2px;" v-for="(element,index) of item.backupList" :title="element.dns"
:color="element.time?'green':'red'" :key='index'>{{ element.host }}
{{ element.time }}{{ element.time ? 'ms' : '' }}
</a-tag>
@ -230,8 +229,8 @@ export default {
key: 'server',
dnsMappings: [],
speedTestList: [],
whiteList: [],
sniList: []
whiteList: []
// sniList: []
}
},
created () {
@ -270,7 +269,7 @@ export default {
ready () {
this.initDnsMapping()
this.initWhiteList()
this.initSniList()
// this.initSniList()
if (this.config.server.dns.speedTest.dnsProviders) {
this.speedDns = this.config.server.dns.speedTest.dnsProviders
}
@ -278,7 +277,7 @@ export default {
async applyBefore () {
this.submitDnsMapping()
this.submitWhiteList()
this.submitSniList()
// this.submitSniList()
},
async applyAfter () {
if (this.status.server.enabled) {
@ -343,34 +342,34 @@ export default {
this.whiteList.unshift({ key: '', value: true })
},
// sniList
initSniList () {
this.sniList = []
for (const key in this.config.server.sniList) {
const value = this.config.server.sniList[key]
this.sniList.push({
key, value
})
}
},
submitSniList () {
const sniList = {}
for (const item of this.sniList) {
if (item.key) {
sniList[item.key] = item.value
}
}
this.config.server.sniList = sniList
},
deleteSniList (item, index) {
this.sniList.splice(index, 1)
},
restoreDefSniList (item, index) {
},
addSniList () {
this.sniList.unshift({ key: '', value: true })
},
// // sniList
// initSniList () {
// this.sniList = []
// for (const key in this.config.server.sniList) {
// const value = this.config.server.sniList[key]
// this.sniList.push({
// key, value
// })
// }
// },
// submitSniList () {
// const sniList = {}
// for (const item of this.sniList) {
// if (item.key) {
// sniList[item.key] = item.value
// }
// }
// this.config.server.sniList = sniList
// },
// deleteSniList (item, index) {
// this.sniList.splice(index, 1)
// },
// restoreDefSniList (item, index) {
//
// },
// addSniList () {
// this.sniList.unshift({ key: '', value: true })
// },
async openLog () {
const dir = await this.$api.info.getConfigDir()

@ -54,6 +54,7 @@ module.exports = class DNSOverHTTPS extends BaseDNS {
return ['54.156.140.159', '52.44.227.212', '44.221.37.199']
}
// 未预设当前域名的IP列表则从dns服务器获取
try {
const result = await dohQueryAsync({ url: this.dnsServer }, [{ type: 'A', name: hostname }])
if (result.answers.length === 0) {

@ -17,7 +17,13 @@ module.exports = {
return dnsMap
},
hasDnsLookup (dnsConfig, hostname) {
const providerName = matchUtil.matchHostname(dnsConfig.mapping, hostname, 'get dns providerName')
let providerName = matchUtil.matchHostname(dnsConfig.mapping, hostname, 'get dns providerName')
// usa已重命名为cloudflare以下为向下兼容处理
if (providerName === 'usa') {
providerName = 'cloudflare'
}
if (providerName) {
return dnsConfig.providers[providerName]
}

@ -8,7 +8,7 @@ const dnsMap = dns.initDNS({
// server: 'ipaddress',
// cacheSize: 1000
// },
usa: {
cloudflare: {
type: 'https',
server: 'https://1.1.1.1/dns-query',
cacheSize: 1000

@ -6,7 +6,7 @@ const dnsProviders = dns.initDNS({
server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000
},
usa: {
cloudflare: {
type: 'https',
server: 'https://1.1.1.1/dns-query',
cacheSize: 1000
@ -54,24 +54,24 @@ const dnsProviders = dns.initDNS({
const hostname0 = 'github.com'
// console.log('first')
// dnsProviders.usa.lookup(hostname0)
// dnsProviders.cloudflare.lookup(hostname0)
console.log('test')
dnsProviders.py233.lookup(hostname0)
// dnsProviders.usa.lookup(hostname0)
// dnsProviders.cloudflare.lookup(hostname0)
// dnsProviders.ipaddress.lookup(hostname0)
// dnsProviders.ipaddress.lookup(hostname0)
// const hostname = 'api.github.com'
// dnsProviders.usa.lookup(hostname)
// dnsProviders.cloudflare.lookup(hostname)
// const hostname1 = 'api.github.com'
// dnsProviders.usa.lookup(hostname1)
// dnsProviders.cloudflare.lookup(hostname1)
//
// const hostname2 = 'hk.docmirror.cn'
// dnsProviders.usa.lookup(hostname2)
// dnsProviders.cloudflare.lookup(hostname2)
// const hostname3 = 'github.docmirror.cn'
// dnsProviders.usa.lookup(hostname3)
// dnsProviders.cloudflare.lookup(hostname3)
// const hostname4 = 'gh.docmirror.top'
// dnsProviders.usa.lookup(hostname4)
// dnsProviders.cloudflare.lookup(hostname4)
// const hostname5 = 'gh2.docmirror.top'
// dnsProviders.usa.lookup(hostname5)
// dnsProviders.cloudflare.lookup(hostname5)

Loading…
Cancel
Save