`兼容程序` 修改为 `自动兼容程序`

pull/376/head
王良 2024-10-17 14:17:27 +08:00
parent 09023f57f9
commit 6e88d434c8
4 changed files with 12 additions and 12 deletions

View File

@ -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>

View File

@ -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}`)
}
}

View File

@ -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)
}

View File

@ -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`)
}
}
})