From 1173ee90963e17543cb38f7113cb34d02780f9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Thu, 15 Aug 2024 10:50:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BA=90=E4=BB=A3=E7=A0=81=E4=B8=AD=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84=201181=20=E6=9B=BF=E6=8D=A2=E4=B8=BA=2031181?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- doc/other.md | 6 +++--- packages/core/src/shell/test.js | 2 +- .../src/lib/interceptor/impl/req/requestReplace.js | 3 +++ packages/mitmproxy/src/lib/proxy/common/config.js | 2 +- test/test.js | 8 ++++---- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ea3aff2..d52c349 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ const intercepts = { #### 1)Mac系统使用时,首页的系统代理开关无法打开 出现这个问题可能是没有开启系统代理命令的执行权限 ``` -networksetup -setwebproxy 'WiFi' 127.0.0.1 1181 +networksetup -setwebproxy 'WiFi' 127.0.0.1 31181 #看是否有如下错误提示 ** Error: Command requires admin privileges. ``` diff --git a/doc/other.md b/doc/other.md index e057f02..9c5a95a 100644 --- a/doc/other.md +++ b/doc/other.md @@ -6,11 +6,11 @@ 需要先通过keytool安装证书 `keytool -import -alias dev-sidecar -keystore "jdk路径\security\cacerts" -file 用户目录\.dev-sidecar\dev-sidecar.ca.crt`默认密码为`changeit` 启动时还需要设置参数 -`-Dhttp.proxyHost=localhost -Dhttp.proxyPort=1181 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=1181` +`-Dhttp.proxyHost=localhost -Dhttp.proxyPort=31181 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=31181` Gradle还需在`用户目录/.gradle/gradle.properties`创建配置文件 ```properties systemProp.http.proxyHost=localhost -systemProp.http.proxyPort=1181 +systemProp.http.proxyPort=31181 systemProp.https.proxyHost=localhost -systemProp.https.proxyPort=1181 +systemProp.https.proxyPort=31181 ``` \ No newline at end of file diff --git a/packages/core/src/shell/test.js b/packages/core/src/shell/test.js index 6217899..47b9320 100644 --- a/packages/core/src/shell/test.js +++ b/packages/core/src/shell/test.js @@ -38,7 +38,7 @@ const request = require('request') const fs = require('fs') request({ url: 'https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', - proxy: 'http://127.0.0.1:1181', + proxy: 'http://127.0.0.1:31181', ca: fs.readFileSync('C:/Users/Administrator/.dev-sidecar/dev-sidecar.ca.crt') // eslint-disable-next-line handle-callback-err }, (err, res, body) => { diff --git a/packages/mitmproxy/src/lib/interceptor/impl/req/requestReplace.js b/packages/mitmproxy/src/lib/interceptor/impl/req/requestReplace.js index 27ad856..f5ed84c 100644 --- a/packages/mitmproxy/src/lib/interceptor/impl/req/requestReplace.js +++ b/packages/mitmproxy/src/lib/interceptor/impl/req/requestReplace.js @@ -44,6 +44,9 @@ module.exports = { } res.setHeader('DS-RequestReplace-Interceptor', actions) + + const url = `${rOptions.method} ➜ ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${req.url}` + log.info('requestReplace intercept:', url) }, is (interceptOpt) { return !!interceptOpt.requestReplace diff --git a/packages/mitmproxy/src/lib/proxy/common/config.js b/packages/mitmproxy/src/lib/proxy/common/config.js index e101424..1ba20e2 100644 --- a/packages/mitmproxy/src/lib/proxy/common/config.js +++ b/packages/mitmproxy/src/lib/proxy/common/config.js @@ -7,7 +7,7 @@ config.caKeyFileName = 'dev-sidecar.ca.key.pem' config.defaultHost = '127.0.0.1' -config.defaultPort = 1181 +config.defaultPort = 31181 config.caName = 'DevSidecar - This certificate is generated locally' diff --git a/test/test.js b/test/test.js index 9812d2f..2f6a840 100644 --- a/test/test.js +++ b/test/test.js @@ -28,13 +28,13 @@ // const https = require('https') // const fs = require('fs') // process.env.NODE_EXTRA_CA_CERTS = 'C:\\Users\\Administrator\\.dev-sidecar\\dev-sidecar.ca.crt' -// process.env.GLOBAL_AGENT_HTTP_PROXY = "http://127.0.0.1:1181" -// process.env.GLOBAL_AGENT_HTTPS_PROXY = "http://127.0.0.1:1181" +// process.env.GLOBAL_AGENT_HTTP_PROXY = "http://127.0.0.1:31181" +// process.env.GLOBAL_AGENT_HTTPS_PROXY = "http://127.0.0.1:31181" // fs.readFileSync(process.env.NODE_EXTRA_CA_CERTS) // // const options = { // agent : new https.Agent({ -// proxy: "http://127.0.0.1:1181" +// proxy: "http://127.0.0.1:31181" // }) // } // console.log('options', options) @@ -55,7 +55,7 @@ function testRequest(){ // process.env.NODE_EXTRA_CA_CERTS='C:\\Users\\Administrator\\.dev-sidecar\\dev-sidecar.ca.crt' console.log(process.env.NODE_EXTRA_CA_CERTS) const request = require("request").defaults({ - proxy: "http://127.0.0.1:1181" + proxy: "http://127.0.0.1:31181" }) request("https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js",(error, response, body)=>{ if(error){