Browse Source

bugfix: 读取内置 `domestic-domain-allowlist.txt` 失败的问题修复

pull/375/head
王良 1 month ago
parent
commit
1844895318
  1. 5
      packages/core/src/shell/scripts/set-system-proxy/index.js
  2. 0
      packages/gui/extra/proxy/domestic-domain-allowlist.txt
  3. 1
      packages/mitmproxy/src/lib/proxy/middleware/source/pac.js
  4. 2
      packages/mitmproxy/src/options.js

5
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
}
}

0
packages/gui/extra/proxy/china-domain-allowlist.txt → packages/gui/extra/proxy/domestic-domain-allowlist.txt

1
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()

2
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)
}

Loading…
Cancel
Save