fix: 白名单会被ow拦截的bug
parent
a1598e57c6
commit
38f6892660
|
@ -13,7 +13,6 @@
|
|||
* 设置可执行权限 `sudo chmod +X DevSidecar-x.x.x.AppImage`
|
||||
* 双击运行
|
||||
|
||||
|
||||
## 证书安装
|
||||
默认模式和增强模式需要系统信任CA证书。
|
||||
由于linux上火狐和chrome都不走系统证书,所以除了安装系统证书之外,还需要给浏览器安装证书
|
||||
|
|
|
@ -14,6 +14,10 @@ module.exports = {
|
|||
mode: 'default',
|
||||
autoStart: {
|
||||
enabled: false
|
||||
},
|
||||
remoteConfig: {
|
||||
enabled: true,
|
||||
url: 'https://gitee.com/docmirror/dev-sidecar/raw/master/packages/gui/extra/config_remote.json5'
|
||||
}
|
||||
},
|
||||
server: {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
server: {
|
||||
intercepts: {
|
||||
'github.githubassets.com': {
|
||||
'.*': {
|
||||
proxy: 'assets.fastgit.org',
|
||||
sni11: 'baidu.com'
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
|
@ -12,6 +12,14 @@
|
|||
开机自启
|
||||
</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="远程配置" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-checkbox v-model="config.app.remoteConfig.enabled" @change="onRemoteConfigEnabledChange">
|
||||
启用远程配置
|
||||
</a-checkbox>
|
||||
</a-form-item>
|
||||
<a-form-item label="远程配置地址" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-input v-model="config.app.remoteConfig.url"></a-input>
|
||||
</a-form-item>
|
||||
</div>
|
||||
<template slot="footer">
|
||||
<div class="footer-bar">
|
||||
|
@ -42,6 +50,9 @@ export default {
|
|||
onAutoStartChange () {
|
||||
this.$api.autoStart.enabled(this.config.app.autoStart.enabled)
|
||||
this.saveConfig()
|
||||
},
|
||||
onRemoteConfigEnabledChange () {
|
||||
this.saveConfig()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ const sniExtract = require('../tls/sniUtil.js')
|
|||
function isSslConnect (sslConnectInterceptors, req, cltSocket, head) {
|
||||
for (const intercept of sslConnectInterceptors) {
|
||||
const ret = intercept(req, cltSocket, head)
|
||||
if (ret) {
|
||||
if (ret === false) {
|
||||
return false
|
||||
}
|
||||
if (ret === true) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +46,7 @@ module.exports = function createConnectHandler (sslConnectInterceptor, middlewar
|
|||
log.error('getServerPromise', e)
|
||||
})
|
||||
} else {
|
||||
log.info('不拦截请求:', hostname)
|
||||
connect(req, cltSocket, head, hostname, srvUrl.port, dnsConfig, sniRegexpMap)
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +57,7 @@ function connect (req, cltSocket, head, hostname, port, dnsConfig, sniRegexpMap)
|
|||
// log.info('connect:', hostname, port)
|
||||
const start = new Date().getTime()
|
||||
let isDnsIntercept = null
|
||||
const replaceSni = matchUtil.matchHostname(sniRegexpMap, hostname)
|
||||
// const replaceSni = matchUtil.matchHostname(sniRegexpMap, hostname)
|
||||
try {
|
||||
const options = {
|
||||
port,
|
||||
|
|
|
@ -128,6 +128,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
|
|||
}
|
||||
}
|
||||
|
||||
// log.info('开始请求:', process.env.NODE_TLS_REJECT_UNAUTHORIZED, rOptions.rejectUnauthorized, rOptions.agent)
|
||||
proxyReq = (rOptions.protocol === 'https:' ? https : http).request(rOptions, (proxyRes) => {
|
||||
const end = new Date().getTime()
|
||||
const cost = end - start
|
||||
|
|
|
@ -41,10 +41,14 @@ module.exports = (config) => {
|
|||
const inWhiteList = matchUtil.matchHostname(whiteList, hostname) != null
|
||||
if (inWhiteList) {
|
||||
log.info('白名单域名,不拦截', hostname)
|
||||
return false
|
||||
return false // 所有都不拦截
|
||||
}
|
||||
// 配置了拦截的域名,将会被代理
|
||||
return !!matchUtil.matchHostname(intercepts, hostname)
|
||||
const matched = !!matchUtil.matchHostname(intercepts, hostname)
|
||||
if (matched === true) {
|
||||
return matched // 拦截
|
||||
}
|
||||
return null // 由下一个拦截器判断
|
||||
},
|
||||
createIntercepts: (context) => {
|
||||
const rOptions = context.rOptions
|
||||
|
|
Loading…
Reference in New Issue