refactor: speed test 优化

pull/67/head
xiaojunnuo 2021-03-26 00:21:48 +08:00
parent 8cd5708529
commit e2caf406fd
4 changed files with 11 additions and 8 deletions

View File

@ -152,11 +152,11 @@ module.exports = {
server: 'https://dns.alidns.com/dns-query', server: 'https://dns.alidns.com/dns-query',
cacheSize: 1000 cacheSize: 1000
}, },
ipaddress: { // ipaddress: {
type: 'ipaddress', // type: 'ipaddress',
server: 'ipaddress', // server: 'ipaddress',
cacheSize: 1000 // cacheSize: 1000
}, // },
usa: { usa: {
type: 'https', type: 'https',
server: 'https://1.1.1.1/dns-query', server: 'https://1.1.1.1/dns-query',
@ -192,7 +192,7 @@ module.exports = {
'*.githubusercontent.com': 'usa', '*.githubusercontent.com': 'usa',
'*.githubassets.com': 'usa', '*.githubassets.com': 'usa',
// "解决push的时候需要输入密码的问题", // "解决push的时候需要输入密码的问题",
'github.com': 'usa', 'github.com': 'quad9',
'*github.com': 'usa', '*github.com': 'usa',
'*.vuepress.vuejs.org': 'usa', '*.vuepress.vuejs.org': 'usa',
'gh.docmirror.top': 'usa' 'gh.docmirror.top': 'usa'

View File

@ -25,6 +25,7 @@
<img v-if="!startup.loading && status.server.enabled" width="50" src="/logo/logo-fff.svg"> <img v-if="!startup.loading && status.server.enabled" width="50" src="/logo/logo-fff.svg">
</a-button> </a-button>
<div style="margin-top: 10px">{{ status.server.enabled ? '已开启' : '已关闭' }}</div> <div style="margin-top: 10px">{{ status.server.enabled ? '已开启' : '已关闭' }}</div>
</div> </div>
</div> </div>
<div :span="12"> <div :span="12">

View File

@ -80,7 +80,9 @@ class SpeedTester {
} }
async test () { async test () {
this.backupList = await this.getIpListFromDns(this.dnsMap) const newList = await this.getIpListFromDns(this.dnsMap)
const newBackupList = [...newList, ...this.backupList]
this.backupList = _.unionBy(newBackupList, 'host')
log.info('[speed]', this.hostname, ' ips:', this.backupList) log.info('[speed]', this.hostname, ' ips:', this.backupList)
await this.testBackups() await this.testBackups()
if (config.notify) { if (config.notify) {

View File

@ -16,7 +16,7 @@ function initSpeedTest ({ enabled, hostnameList, dnsMap }) {
SpeedTestPool[hostname] = new SpeedTester({ hostname }) SpeedTestPool[hostname] = new SpeedTester({ hostname })
}) })
log.info('[speed] dnsMap', dnsMap) log.info('[speed] enabled')
} }
function getAllSpeedTester () { function getAllSpeedTester () {