docs: 小修改
parent
d6c8e85f2f
commit
41cb44967d
|
@ -20,7 +20,7 @@ module.exports = {
|
||||||
'/.*/.*/blame/': {
|
'/.*/.*/blame/': {
|
||||||
redirect: 'hub.fastgit.org'
|
redirect: 'hub.fastgit.org'
|
||||||
},
|
},
|
||||||
'/.+/[^\\/]+$': {
|
'^/[^/]+/[^/]+$': {
|
||||||
script: [
|
script: [
|
||||||
'jquery',
|
'jquery',
|
||||||
'github'
|
'github'
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const LRU = require('lru-cache')
|
const LRU = require('lru-cache')
|
||||||
const cacheSize = 1024
|
const cacheSize = 1024
|
||||||
|
const log = require('../../utils/util.log')
|
||||||
class ChoiceCache {
|
class ChoiceCache {
|
||||||
constructor () {
|
constructor () {
|
||||||
this.cache = new LRU(cacheSize)
|
this.cache = new LRU(cacheSize)
|
||||||
|
@ -52,7 +53,7 @@ class DynamicChoice {
|
||||||
list.sort((a, b) => {
|
list.sort((a, b) => {
|
||||||
return b.successRate - a.successRate
|
return b.successRate - a.successRate
|
||||||
})
|
})
|
||||||
console.log('do rank', list)
|
log.info('do rank', JSON.stringify(list))
|
||||||
const backup = list.map(item => item.value)
|
const backup = list.map(item => item.value)
|
||||||
|
|
||||||
this.setBackupList(backup)
|
this.setBackupList(backup)
|
||||||
|
|
|
@ -4,12 +4,16 @@ module.exports = {
|
||||||
const { rOptions, log, RequestCounter } = context
|
const { rOptions, log, RequestCounter } = context
|
||||||
|
|
||||||
let proxyConf = interceptOpt.proxy
|
let proxyConf = interceptOpt.proxy
|
||||||
if (RequestCounter && interceptOpt.backup && interceptOpt.backup.length > 0) {
|
if (RequestCounter) {
|
||||||
// 优选逻辑
|
// 优选逻辑
|
||||||
const backup = [proxyConf]
|
const backup = [proxyConf]
|
||||||
for (const bk of interceptOpt.backup) {
|
if (interceptOpt.backup) {
|
||||||
backup.push(bk)
|
for (const bk of interceptOpt.backup) {
|
||||||
|
backup.push(bk)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
backup.push(rOptions.hostname)
|
||||||
|
|
||||||
const key = interceptOpt.key
|
const key = interceptOpt.key
|
||||||
const count = RequestCounter.getOrCreate(key, backup)
|
const count = RequestCounter.getOrCreate(key, backup)
|
||||||
if (count.value == null) {
|
if (count.value == null) {
|
||||||
|
|
Loading…
Reference in New Issue