diff --git a/packages/core/src/config/index.js b/packages/core/src/config/index.js index 5a73dcf9..680f277a 100644 --- a/packages/core/src/config/index.js +++ b/packages/core/src/config/index.js @@ -20,7 +20,7 @@ module.exports = { '/.*/.*/blame/': { redirect: 'hub.fastgit.org' }, - '/.+/[^\\/]+$': { + '^/[^/]+/[^/]+$': { script: [ 'jquery', 'github' diff --git a/packages/mitmproxy/src/lib/choice/index.js b/packages/mitmproxy/src/lib/choice/index.js index f213dbe7..24d9fa6d 100644 --- a/packages/mitmproxy/src/lib/choice/index.js +++ b/packages/mitmproxy/src/lib/choice/index.js @@ -1,5 +1,6 @@ const LRU = require('lru-cache') const cacheSize = 1024 +const log = require('../../utils/util.log') class ChoiceCache { constructor () { this.cache = new LRU(cacheSize) @@ -52,7 +53,7 @@ class DynamicChoice { list.sort((a, b) => { return b.successRate - a.successRate }) - console.log('do rank', list) + log.info('do rank', JSON.stringify(list)) const backup = list.map(item => item.value) this.setBackupList(backup) diff --git a/packages/mitmproxy/src/lib/interceptor/impl/proxy.js b/packages/mitmproxy/src/lib/interceptor/impl/proxy.js index 526710ac..538e09d9 100644 --- a/packages/mitmproxy/src/lib/interceptor/impl/proxy.js +++ b/packages/mitmproxy/src/lib/interceptor/impl/proxy.js @@ -4,12 +4,16 @@ module.exports = { const { rOptions, log, RequestCounter } = context let proxyConf = interceptOpt.proxy - if (RequestCounter && interceptOpt.backup && interceptOpt.backup.length > 0) { + if (RequestCounter) { // 优选逻辑 const backup = [proxyConf] - for (const bk of interceptOpt.backup) { - backup.push(bk) + if (interceptOpt.backup) { + for (const bk of interceptOpt.backup) { + backup.push(bk) + } } + backup.push(rOptions.hostname) + const key = interceptOpt.key const count = RequestCounter.getOrCreate(key, backup) if (count.value == null) {