From 18448953185a0eba74042df8fd5ba14cb3158b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 9 Oct 2024 17:17:36 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E8=AF=BB=E5=8F=96=E5=86=85=E7=BD=AE?= =?UTF-8?q?=20`domestic-domain-allowlist.txt`=20=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/shell/scripts/set-system-proxy/index.js | 5 +++-- ...na-domain-allowlist.txt => domestic-domain-allowlist.txt} | 0 packages/mitmproxy/src/lib/proxy/middleware/source/pac.js | 1 + packages/mitmproxy/src/options.js | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) rename packages/gui/extra/proxy/{china-domain-allowlist.txt => domestic-domain-allowlist.txt} (100%) diff --git a/packages/core/src/shell/scripts/set-system-proxy/index.js b/packages/core/src/shell/scripts/set-system-proxy/index.js index 1e92870..18df972 100644 --- a/packages/core/src/shell/scripts/set-system-proxy/index.js +++ b/packages/core/src/shell/scripts/set-system-proxy/index.js @@ -166,7 +166,8 @@ function getDomesticDomainAllowList () { log.info('读取已下载的 domestic-domain-allowlist.txt 文件:', fileAbsolutePath) } else { // 如果临时文件不存在,则使用内置文件 - fileAbsolutePath = path.join(__dirname, '../../gui/', config.get().proxy.domesticDomainAllowListFilePath) + log.info('__dirname:', __dirname) + fileAbsolutePath = path.join(__dirname, '../', config.get().proxy.domesticDomainAllowListFilePath) log.info('读取内置的 domestic-domain-allowlist.txt 文件:', fileAbsolutePath) } } else { @@ -176,7 +177,7 @@ function getDomesticDomainAllowList () { try { return fs.readFileSync(fileAbsolutePath).toString() } catch (e) { - log.error('读取 domestic-domain-allowlist.txt 文件失败:', fileAbsolutePath) + log.error(`读取 domestic-domain-allowlist.txt 文件失败: ${fileAbsolutePath}, error:`, e) return null } } diff --git a/packages/gui/extra/proxy/china-domain-allowlist.txt b/packages/gui/extra/proxy/domestic-domain-allowlist.txt similarity index 100% rename from packages/gui/extra/proxy/china-domain-allowlist.txt rename to packages/gui/extra/proxy/domestic-domain-allowlist.txt diff --git a/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js b/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js index 5c0e00c..e7b86c0 100644 --- a/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js +++ b/packages/mitmproxy/src/lib/proxy/middleware/source/pac.js @@ -8,6 +8,7 @@ function createPacClient (pacFilePath) { function readFile (location) { try { log.info('pac root dir:', path.resolve('./')) + log.info('pac location:', location) const filePath = path.resolve(location) log.info('read pac path:', filePath) return fs.readFileSync(location).toString() diff --git a/packages/mitmproxy/src/options.js b/packages/mitmproxy/src/options.js index f7db3c8..89e76ed 100644 --- a/packages/mitmproxy/src/options.js +++ b/packages/mitmproxy/src/options.js @@ -69,7 +69,9 @@ module.exports = (serverConfig) => { } if (!pacConfig.pacFileAbsolutePath) { + log.info('setting.rootDir:', setting.rootDir) pacConfig.pacFileAbsolutePath = path.join(setting.rootDir, pacConfig.pacFilePath) + log.info('读取内置的 pac.txt 文件:', pacConfig.pacFileAbsolutePath) if (pacConfig.autoUpdate) { log.warn('远程 pac.txt 文件下载失败或还在下载中,现使用内置 pac.txt 文件:', pacConfig.pacFileAbsolutePath) }