Skip to content

Commit

Permalink
bugfix: 读取内置 domestic-domain-allowlist.txt 失败的问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Oct 9, 2024
1 parent 3a310eb commit 1844895
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/shell/scripts/set-system-proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/mitmproxy/src/lib/proxy/middleware/source/pac.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions packages/mitmproxy/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1844895

Please sign in to comment.