refactor: sysproxy集成
parent
f830b0f457
commit
a5add8f396
|
@ -49,11 +49,11 @@ module.exports = {
|
|||
desc: 'clone加速复制链接脚本'
|
||||
},
|
||||
'/.*': {
|
||||
proxy: 'github.com',
|
||||
proxy: 'gh.docmirror.top/_proxy',
|
||||
backup: [
|
||||
'gh.docmirror.top/_proxy'
|
||||
'github.com'
|
||||
],
|
||||
desc: '如果出现dev-sidecar报错,可能是备用加速地址dns被污染了,需要将本条配置删除'
|
||||
desc: '如果出现dev-sidecar报错,可能是加速地址dns被污染了,需要将本条配置删除'
|
||||
}
|
||||
},
|
||||
'api.github.com': {
|
||||
|
|
|
@ -36,7 +36,7 @@ const _lanIP = [
|
|||
async function _winUnsetProxy (exec) {
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
if (true) {
|
||||
const proxyPath = path.resolve(__dirname, './extra/sysproxy.exe')
|
||||
const proxyPath = getProxyExePath()
|
||||
await execFile(proxyPath, ['off'])
|
||||
return
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ async function _winUnsetProxy (exec) {
|
|||
|
||||
function getProxyExePath () {
|
||||
const proxyPath = process.env.DS_SYSPROXY_PATH
|
||||
log.info('proxyPath', proxyPath)
|
||||
if (proxyPath) {
|
||||
return proxyPath
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ const config = require('../config/index')
|
|||
function getDefaultConfigBasePath () {
|
||||
return config.server.setting.userBasePath
|
||||
}
|
||||
const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info'
|
||||
log4js.configure({
|
||||
appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/core.log' } },
|
||||
categories: { default: { appenders: ['file', 'std'], level: 'info' } }
|
||||
categories: { default: { appenders: ['file', 'std'], level: level } }
|
||||
})
|
||||
const logger = log4js.getLogger('server')
|
||||
module.exports = logger
|
||||
|
|
|
@ -6,6 +6,7 @@ import JSON5 from 'json5'
|
|||
import path from 'path'
|
||||
const pk = require('../../package.json')
|
||||
const mitmproxyPath = path.join(__dirname, 'mitmproxy.js')
|
||||
process.env.DS_SYSPROXY_PATH = path.join(__dirname, '../extra/sysproxy.exe')
|
||||
const log = require('../utils/util.log')
|
||||
const getDefaultConfigBasePath = function () {
|
||||
return DevSidecar.api.config.get().server.setting.userBasePath
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
// eslint-disable-next-line no-unused-vars
|
||||
const server = require('@docmirror/mitmproxy')
|
||||
const configPath = process.argv[2]
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const configJson = fs.readFileSync(configPath)
|
||||
const config = JSON.parse(configJson)
|
||||
|
||||
let scriptDir = '../extra/scripts/'
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
scriptDir = '../extra/scripts/'
|
||||
}
|
||||
config.setting.script.defaultDir = path.join(__dirname, scriptDir)
|
||||
|
||||
server.start(config)
|
||||
|
|
|
@ -3,9 +3,10 @@ const DevSidecar = require('@docmirror/dev-sidecar')
|
|||
const getDefaultConfigBasePath = function () {
|
||||
return DevSidecar.api.config.get().server.setting.userBasePath
|
||||
}
|
||||
const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info'
|
||||
log4js.configure({
|
||||
appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: getDefaultConfigBasePath() + '/logs/gui.log' } },
|
||||
categories: { default: { appenders: ['file', 'std'], level: 'info' } }
|
||||
categories: { default: { appenders: ['file', 'std'], level: level } }
|
||||
})
|
||||
const logger = log4js.getLogger('server')
|
||||
module.exports = logger
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
<div>开启此项之后,被代理应用关闭SSL校验也问题不大了</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="根证书:" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-input addon-before="Cert" addon-after="选择" v-model="config.server.setting.rootCaFile.certPath" ></a-input>
|
||||
<a-input addon-before="Key" addon-after="选择" v-model="config.server.setting.rootCaFile.keyPath" ></a-input>
|
||||
<a-input addon-before="Cert" v-model="config.server.setting.rootCaFile.certPath" ></a-input>
|
||||
<a-input addon-before="Key" v-model="config.server.setting.rootCaFile.keyPath" ></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="启用脚本" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-tooltip title="关闭后,github的clone加速链接复制也将关闭">
|
||||
|
@ -148,7 +148,7 @@ export default {
|
|||
},
|
||||
async openLog () {
|
||||
const dir = await this.$api.info.getConfigDir()
|
||||
this.$api.ipc.openPath(dir + '/logs/server.log')
|
||||
this.$api.ipc.openPath(dir + '/logs/')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class DynamicChoice {
|
|||
if (this.count[item]) {
|
||||
continue
|
||||
}
|
||||
this.count[item] = { value: item, total: defaultTotal, error: 0, keepErrorCount: 0, successRate: 1 }
|
||||
this.count[item] = { value: item, total: defaultTotal, error: 0, keepErrorCount: 0, successRate: 0.5 }
|
||||
defaultTotal--
|
||||
}
|
||||
this.value = backupList.shift()
|
||||
|
|
|
@ -49,7 +49,10 @@ module.exports = {
|
|||
rOptions.port = rOptions.protocol === 'https:' ? 443 : 80
|
||||
}
|
||||
log.info('proxy:', rOptions.hostname, proxyTarget)
|
||||
log.debug('proxy choice:', JSON.stringify(context.requestCount))
|
||||
if (context.requestCount) {
|
||||
log.debug('proxy choice:', JSON.stringify(context.requestCount))
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
is (interceptOpt) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
const log4js = require('log4js')
|
||||
const proxyConfig = require('../lib/proxy/common/config')
|
||||
const level = process.env.NODE_ENV === 'development' ? 'debug' : 'info'
|
||||
log4js.configure({
|
||||
appenders: { std: { type: 'stdout', level: 'debug' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename: proxyConfig.getDefaultCABasePath() + '/logs/server.log' } },
|
||||
categories: { default: { appenders: ['file', 'std'], level: 'info' } }
|
||||
categories: { default: { appenders: ['file', 'std'], level: level } }
|
||||
})
|
||||
const logger = log4js.getLogger('server')
|
||||
module.exports = logger
|
||||
|
|
Loading…
Reference in New Issue