Browse Source

refactor: 1

pull/192/head
xiaojunnuo 3 years ago
parent
commit
e42cfe2f3c
  1. 3
      packages/gui/src/view/pages/setting.vue
  2. 1
      packages/mitmproxy/src/lib/interceptor/impl/proxy.js
  3. 9
      packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js

3
packages/gui/src/view/pages/setting.vue

@ -16,6 +16,9 @@
<a-checkbox v-model="config.app.remoteConfig.enabled" @change="onRemoteConfigEnabledChange"> <a-checkbox v-model="config.app.remoteConfig.enabled" @change="onRemoteConfigEnabledChange">
启用远程配置 启用远程配置
</a-checkbox> </a-checkbox>
<div>
为提升用户体验
</div>
</a-form-item> </a-form-item>
<a-form-item label="远程配置地址" :label-col="labelCol" :wrapper-col="wrapperCol"> <a-form-item label="远程配置地址" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-input v-model="config.app.remoteConfig.url"></a-input> <a-input v-model="config.app.remoteConfig.url"></a-input>

1
packages/mitmproxy/src/lib/interceptor/impl/proxy.js

@ -63,6 +63,7 @@ module.exports = {
if (interceptOpt.sni != null) { if (interceptOpt.sni != null) {
rOptions.servername = interceptOpt.sni rOptions.servername = interceptOpt.sni
rOptions.agent.options.rejectUnauthorized = false
} }
return true return true
}, },

9
packages/mitmproxy/src/lib/proxy/mitmproxy/createRequestHandler.js

@ -16,6 +16,10 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
let proxyReq let proxyReq
const rOptions = commonUtil.getOptionsFormRequest(req, ssl, externalProxy) const rOptions = commonUtil.getOptionsFormRequest(req, ssl, externalProxy)
if (setting && setting.NODE_TLS_REJECT_UNAUTHORIZED) {
rOptions.agent.options.rejectUnauthorized = true
}
if (rOptions.headers.connection === 'close') { if (rOptions.headers.connection === 'close') {
req.socket.setKeepAlive(false) req.socket.setKeepAlive(false)
} else if (rOptions.customSocketId != null) { // for NTLM } else if (rOptions.customSocketId != null) { // for NTLM
@ -128,11 +132,6 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
} }
} }
// log.info('开始请求:', process.env.NODE_TLS_REJECT_UNAUTHORIZED, rOptions.rejectUnauthorized, rOptions.agent)
if (setting && setting.NODE_TLS_REJECT_UNAUTHORIZED) {
rOptions.agent.options.rejectUnauthorized = true
}
proxyReq = (rOptions.protocol === 'https:' ? https : http).request(rOptions, (proxyRes) => { proxyReq = (rOptions.protocol === 'https:' ? https : http).request(rOptions, (proxyRes) => {
const end = new Date().getTime() const end = new Date().getTime()
const cost = end - start const cost = end - start

Loading…
Cancel
Save