optimize: 是否需要代理的判断代码逻辑优化
parent
8dc5cfc37c
commit
21e46a4124
|
@ -148,14 +148,7 @@ function createOverwallMiddleware (overWallConfig) {
|
|||
return {
|
||||
sslConnectInterceptor: (req, cltSocket, head) => {
|
||||
const hostname = req.url.split(':')[0]
|
||||
const ret = matched(hostname, overWallTargetMap)
|
||||
if (ret == null) {
|
||||
return null // 返回 null,由下一个拦截器校验
|
||||
}
|
||||
if (ret === false) {
|
||||
return false // 不拦截,预留这个判断,避免以后修改 matched 方法的代码出BUG
|
||||
}
|
||||
return true // 拦截
|
||||
return matched(hostname, overWallTargetMap)
|
||||
},
|
||||
requestIntercept (context, req, res, ssl, next) {
|
||||
const { rOptions, log, RequestCounter } = context
|
||||
|
@ -164,7 +157,7 @@ function createOverwallMiddleware (overWallConfig) {
|
|||
}
|
||||
const hostname = rOptions.hostname
|
||||
const matchedResult = matched(hostname, overWallTargetMap)
|
||||
if (matchedResult == null || matchedResult === false) {
|
||||
if (matchedResult == null || matchedResult === false || matchedResult === 'false') {
|
||||
return
|
||||
}
|
||||
const cacheKey = '__over_wall_proxy__'
|
||||
|
|
|
@ -9,11 +9,11 @@ const jsonApi = require('../../../json')
|
|||
function isSslConnect (sslConnectInterceptors, req, cltSocket, head) {
|
||||
for (const intercept of sslConnectInterceptors) {
|
||||
const ret = intercept(req, cltSocket, head)
|
||||
log.debug(`拦截判断结果:${ret}, url: ${req.url}, intercept:`, intercept)
|
||||
if (ret === false || ret === true) {
|
||||
return ret
|
||||
log.debug('当前拦截器返回结果:', ret, `, url: ${req.url}, intercept:`, intercept)
|
||||
if (ret == null) {
|
||||
continue
|
||||
}
|
||||
// continue
|
||||
return !(ret === false || ret === 'false')
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -119,10 +119,10 @@ module.exports = (serverConfig) => {
|
|||
const matched = matchUtil.matchHostname(intercepts, hostname, 'matched intercepts')
|
||||
if ((!!matched) === true) {
|
||||
log.debug(`拦截器拦截:${req.url}, matched:`, matched)
|
||||
return true // 拦截
|
||||
return matched // 拦截
|
||||
}
|
||||
|
||||
return null // 未匹配到任何拦截配置,由下一个拦截器判断
|
||||
return null // 不在白名单中,也未配置在拦截功能中,跳过当前拦截器,由下一个拦截器判断
|
||||
},
|
||||
createIntercepts: (context) => {
|
||||
const rOptions = context.rOptions
|
||||
|
|
Loading…
Reference in New Issue