`兼容程序` 修改为 `自动兼容程序`
parent
09023f57f9
commit
6e88d434c8
|
@ -106,10 +106,10 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane tab="兼容程序" key="5">
|
||||
<a-tab-pane tab="自动兼容程序" key="5">
|
||||
<div style="height:100%;display:flex;flex-direction:column">
|
||||
<div>
|
||||
说明:<code>兼容程序</code>会自动根据错误信息进行兼容性调整,并将兼容设置保存在 <code>~/.dev-sidecar/automaticCompatibleConfig.json</code> 文件中。但并不是所有的兼容设置都是正确的,所以需要通过以下配置来覆盖错误的兼容设置。
|
||||
说明:<code>自动兼容程序</code>会自动根据错误信息进行兼容性调整,并将兼容设置保存在 <code>~/.dev-sidecar/automaticCompatibleConfig.json</code> 文件中。但并不是所有的兼容设置都是正确的,所以需要通过以下配置来覆盖错误的兼容设置。
|
||||
</div>
|
||||
<vue-json-editor style="flex-grow:1;min-height:300px;margin-top:10px;" ref="editor" v-model="config.server.compatible" mode="code"
|
||||
:show-btns="false" :expandedOnStart="true"></vue-json-editor>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* 兼容程序自适应生成配置
|
||||
* 自动兼容程序自适应生成配置
|
||||
* 此脚本会针对各种兼容性问题,为对应域名生成相应的兼容性配置,并将自适应配置写入到 `~/.dev-sidecar/automaticCompatibleConfig.json` 文件中。
|
||||
* 当然,也有可能会生成错误的配置,导致无法兼容,这时候可以通过 `config.server.compatible` 配置项,来覆盖这里生成的配置,达到主动适配的效果。
|
||||
*
|
||||
|
@ -110,7 +110,7 @@ module.exports = {
|
|||
// 配置保存到文件
|
||||
if (autoSave) _saveConfigToFile()
|
||||
|
||||
log.info(`【兼容程序】${hostname}:${port}: 设置 connect.ssl = ${ssl}`)
|
||||
log.info(`【自动兼容程序】${hostname}:${port}: 设置 connect.ssl = ${ssl}`)
|
||||
},
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -140,6 +140,6 @@ module.exports = {
|
|||
// 配置保存到文件
|
||||
if (autoSave) _saveConfigToFile()
|
||||
|
||||
log.info(`【兼容程序】${rOptions.hostname}:${rOptions.port}: 设置 request.rejectUnauthorized = ${rejectUnauthorized}`)
|
||||
log.info(`【自动兼容程序】${rOptions.hostname}:${rOptions.port}: 设置 request.rejectUnauthorized = ${rejectUnauthorized}`)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,12 +132,12 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
|
|||
// log.debug('agent.options:', rOptions.agent.options)
|
||||
res.setHeader('DS-Proxy-Request', rOptions.hostname)
|
||||
|
||||
// 兼容程序:2
|
||||
// 自动兼容程序:2
|
||||
if (rOptions.agent) {
|
||||
const compatibleConfig = compatible.getRequestCompatibleConfig(rOptions, rOptions.compatibleConfig)
|
||||
if (compatibleConfig && compatibleConfig.rejectUnauthorized != null && rOptions.agent.options.rejectUnauthorized !== compatibleConfig.rejectUnauthorized) {
|
||||
if (compatibleConfig.rejectUnauthorized === false && rOptions.agent.unVerifySslAgent) {
|
||||
log.info(`【兼容程序】${rOptions.hostname}:${rOptions.port}: 设置 'rOptions.agent.options.rejectUnauthorized = ${compatibleConfig.rejectUnauthorized}'`)
|
||||
log.info(`【自动兼容程序】${rOptions.hostname}:${rOptions.port}: 设置 'rOptions.agent.options.rejectUnauthorized = ${compatibleConfig.rejectUnauthorized}'`)
|
||||
rOptions.agent = rOptions.agent.unVerifySslAgent
|
||||
res.setHeader('DS-Compatible', 'unVerifySsl')
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ module.exports = function createRequestHandler (createIntercepts, middlewares, e
|
|||
countSlow(isDnsIntercept, '代理请求错误: ' + e.message)
|
||||
reject(e)
|
||||
|
||||
// 兼容程序:2
|
||||
// 自动兼容程序:2
|
||||
if (e.code === 'DEPTH_ZERO_SELF_SIGNED_CERT') {
|
||||
compatible.setRequestRejectUnauthorized(rOptions, false)
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ module.exports = class FakeServersCenter {
|
|||
if (port === 443 || port === 80) {
|
||||
ssl = port === 443
|
||||
} else if (ssl) {
|
||||
// 兼容程序:1
|
||||
// 自动兼容程序:1
|
||||
const compatibleConfig = compatible.getConnectCompatibleConfig(hostname, port, manualCompatibleConfig)
|
||||
if (compatibleConfig && compatibleConfig.ssl != null) {
|
||||
ssl = compatibleConfig.ssl
|
||||
|
@ -154,14 +154,14 @@ module.exports = class FakeServersCenter {
|
|||
// log.error(`【fakeServer clientError - ${hostname}:${port}】\r\n----- error -----\r\n`, err, '\r\n----- socket -----\r\n', socket)
|
||||
log.error(`【fakeServer clientError - ${hostname}:${port}】\r\n`, err)
|
||||
|
||||
// 兼容程序:1
|
||||
// 自动兼容程序:1
|
||||
if (port !== 443 && port !== 80) {
|
||||
if (ssl === true && err.code.indexOf('ERR_SSL_') === 0) {
|
||||
compatible.setConnectSsl(hostname, port, false)
|
||||
log.error(`兼容程序:SSL异常,现设置为禁用ssl: ${hostname}:${port}, ssl = false`)
|
||||
log.error(`自动兼容程序:SSL异常,现设置为禁用ssl: ${hostname}:${port}, ssl = false`)
|
||||
} else if (ssl === false && err.code === 'HPE_INVALID_METHOD') {
|
||||
compatible.setConnectSsl(hostname, port, true)
|
||||
log.error(`兼容程序:${err.code},现设置为启用ssl: ${hostname}:${port}, ssl = true`)
|
||||
log.error(`自动兼容程序:${err.code},现设置为启用ssl: ${hostname}:${port}, ssl = true`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue