fix substore proxy

This commit is contained in:
pompurin404 2024-11-19 15:03:57 +08:00
parent f004921ca0
commit b411a8fb51
No known key found for this signature in database

View File

@ -103,22 +103,27 @@ export async function startSubStoreBackendServer(): Promise<void> {
icon.toDataURL() icon.toDataURL()
const stdout = createWriteStream(substoreLogPath(), { flags: 'a' }) const stdout = createWriteStream(substoreLogPath(), { flags: 'a' })
const stderr = createWriteStream(substoreLogPath(), { flags: 'a' }) const stderr = createWriteStream(substoreLogPath(), { flags: 'a' })
const env = {
SUB_STORE_BACKEND_API_PORT: subStorePort.toString(),
SUB_STORE_BACKEND_API_HOST: subStoreHost,
SUB_STORE_DATA_BASE_PATH: subStoreDir(),
SUB_STORE_BACKEND_CUSTOM_ICON: icon.toDataURL(),
SUB_STORE_BACKEND_CUSTOM_NAME: 'Mihomo Party',
SUB_STORE_BACKEND_SYNC_CRON: subStoreBackendSyncCron,
SUB_STORE_BACKEND_DOWNLOAD_CRON: subStoreBackendDownloadCron,
SUB_STORE_BACKEND_UPLOAD_CRON: subStoreBackendUploadCron,
SUB_STORE_MMDB_COUNTRY_PATH: path.join(mihomoWorkDir(), 'country.mmdb'),
SUB_STORE_MMDB_ASN_PATH: path.join(mihomoWorkDir(), 'ASN.mmdb')
}
subStoreBackendWorker = new Worker(path.join(resourcesFilesDir(), 'sub-store.bundle.js'), { subStoreBackendWorker = new Worker(path.join(resourcesFilesDir(), 'sub-store.bundle.js'), {
env: { env: useProxyInSubStore
SUB_STORE_BACKEND_API_PORT: subStorePort.toString(), ? {
SUB_STORE_BACKEND_API_HOST: subStoreHost, ...env,
SUB_STORE_DATA_BASE_PATH: subStoreDir(), HTTP_PROXY: `http://127.0.0.1:${port}`,
SUB_STORE_BACKEND_CUSTOM_ICON: icon.toDataURL(), HTTPS_PROXY: `http://127.0.0.1:${port}`,
SUB_STORE_BACKEND_CUSTOM_NAME: 'Mihomo Party', ALL_PROXY: `http://127.0.0.1:${port}`
SUB_STORE_BACKEND_SYNC_CRON: subStoreBackendSyncCron, }
SUB_STORE_BACKEND_DOWNLOAD_CRON: subStoreBackendDownloadCron, : env
SUB_STORE_BACKEND_UPLOAD_CRON: subStoreBackendUploadCron,
SUB_STORE_MMDB_COUNTRY_PATH: path.join(mihomoWorkDir(), 'country.mmdb'),
SUB_STORE_MMDB_ASN_PATH: path.join(mihomoWorkDir(), 'ASN.mmdb'),
HTTP_PROXY: useProxyInSubStore ? `http://127.0.0.1:${port}` : undefined,
HTTPS_PROXY: useProxyInSubStore ? `http://127.0.0.1:${port}` : undefined,
ALL_PROXY: useProxyInSubStore ? `http://127.0.0.1:${port}` : undefined
}
}) })
subStoreBackendWorker.stdout.pipe(stdout) subStoreBackendWorker.stdout.pipe(stdout)
subStoreBackendWorker.stderr.pipe(stderr) subStoreBackendWorker.stderr.pipe(stderr)