optimize: 当请求匹配到了增强功能时,添加响应头 'DS-Overwall',标识请求FanQ了,并知道是匹配到配置还是PAC。

pull/356/head
王良 2 months ago
parent 24de95fa25
commit 0e8f3a99e9

@ -12,7 +12,7 @@ let pacClient = null
function matched (hostname, overWallTargetMap) {
const ret1 = matchUtil.matchHostname(overWallTargetMap, hostname, 'matched overwall')
if (ret1) {
return true
return 'overwall config'
}
if (pacClient == null) {
return false
@ -20,7 +20,7 @@ function matched (hostname, overWallTargetMap) {
const ret = pacClient.FindProxyForURL('https://' + hostname, hostname)
if (ret && ret.indexOf('PROXY ') === 0) {
log.info(`matchHostname: matched overwall: '${hostname}' -> '${ret}' in pac.txt`)
return true
return 'overwall pac'
} else {
log.debug(`matchHostname: matched overwall: Not-Matched '${hostname}' -> '${ret}' in pac.txt`)
return false
@ -153,7 +153,8 @@ function createOverwallMiddleware (overWallConfig) {
return
}
const hostname = rOptions.hostname
if (!matched(hostname, overWallTargetMap)) {
const matchedResult = matched(hostname, overWallTargetMap)
if (!matchedResult) {
return
}
const cacheKey = '__over_wall_proxy__'
@ -205,6 +206,8 @@ function createOverwallMiddleware (overWallConfig) {
log.debug('OverWall choice:', JSON.stringify(context.requestCount))
}
res.setHeader('DS-Overwall', matchedResult)
return true
}
}

Loading…
Cancel
Save