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

pull/375/head
王良 2024-10-09 17:17:36 +08:00
parent 3a310eb8e1
commit 1844895318
4 changed files with 6 additions and 2 deletions

View File

@ -166,7 +166,8 @@ function getDomesticDomainAllowList () {
log.info('读取已下载的 domestic-domain-allowlist.txt 文件:', fileAbsolutePath) log.info('读取已下载的 domestic-domain-allowlist.txt 文件:', fileAbsolutePath)
} else { } 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) log.info('读取内置的 domestic-domain-allowlist.txt 文件:', fileAbsolutePath)
} }
} else { } else {
@ -176,7 +177,7 @@ function getDomesticDomainAllowList () {
try { try {
return fs.readFileSync(fileAbsolutePath).toString() return fs.readFileSync(fileAbsolutePath).toString()
} catch (e) { } catch (e) {
log.error('读取 domestic-domain-allowlist.txt 文件失败:', fileAbsolutePath) log.error(`读取 domestic-domain-allowlist.txt 文件失败: ${fileAbsolutePath}, error:`, e)
return null return null
} }
} }

View File

@ -8,6 +8,7 @@ function createPacClient (pacFilePath) {
function readFile (location) { function readFile (location) {
try { try {
log.info('pac root dir:', path.resolve('./')) log.info('pac root dir:', path.resolve('./'))
log.info('pac location:', location)
const filePath = path.resolve(location) const filePath = path.resolve(location)
log.info('read pac path:', filePath) log.info('read pac path:', filePath)
return fs.readFileSync(location).toString() return fs.readFileSync(location).toString()

View File

@ -69,7 +69,9 @@ module.exports = (serverConfig) => {
} }
if (!pacConfig.pacFileAbsolutePath) { if (!pacConfig.pacFileAbsolutePath) {
log.info('setting.rootDir:', setting.rootDir)
pacConfig.pacFileAbsolutePath = path.join(setting.rootDir, pacConfig.pacFilePath) pacConfig.pacFileAbsolutePath = path.join(setting.rootDir, pacConfig.pacFilePath)
log.info('读取内置的 pac.txt 文件:', pacConfig.pacFileAbsolutePath)
if (pacConfig.autoUpdate) { if (pacConfig.autoUpdate) {
log.warn('远程 pac.txt 文件下载失败或还在下载中,现使用内置 pac.txt 文件:', pacConfig.pacFileAbsolutePath) log.warn('远程 pac.txt 文件下载失败或还在下载中,现使用内置 pac.txt 文件:', pacConfig.pacFileAbsolutePath)
} }