From 0e8f3a99e9053f41b86c39d4046d118041bce5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Fri, 13 Sep 2024 23:22:31 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E5=BD=93=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E5=88=B0=E4=BA=86=E5=A2=9E=E5=BC=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=97=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E5=A4=B4=20'DS-Overwall'=EF=BC=8C=E6=A0=87=E8=AF=86=E8=AF=B7?= =?UTF-8?q?=E6=B1=82FanQ=E4=BA=86=EF=BC=8C=E5=B9=B6=E7=9F=A5=E9=81=93?= =?UTF-8?q?=E6=98=AF=E5=8C=B9=E9=85=8D=E5=88=B0=E9=85=8D=E7=BD=AE=E8=BF=98?= =?UTF-8?q?=E6=98=AFPAC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/mitmproxy/src/lib/proxy/middleware/overwall.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/mitmproxy/src/lib/proxy/middleware/overwall.js b/packages/mitmproxy/src/lib/proxy/middleware/overwall.js index 0fb1d37..ac89efb 100644 --- a/packages/mitmproxy/src/lib/proxy/middleware/overwall.js +++ b/packages/mitmproxy/src/lib/proxy/middleware/overwall.js @@ -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 } }