From ab58248d7bcb18d65acd0f83c2950f42db58749a Mon Sep 17 00:00:00 2001 From: xmk23333 Date: Thu, 15 Jan 2026 22:56:37 +0800 Subject: [PATCH] fix: use explicit arch parameter for sysproxy node selection --- scripts/prepare.mjs | 2 +- src/native/sysproxy/index.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/scripts/prepare.mjs b/scripts/prepare.mjs index 2f195f7..8753398 100644 --- a/scripts/prepare.mjs +++ b/scripts/prepare.mjs @@ -321,10 +321,10 @@ const SYSPROXY_RS_VERSION = 'v0.1.0' const SYSPROXY_RS_URL_PREFIX = `https://github.com/mihomo-party-org/sysproxy-rs-opti/releases/download/${SYSPROXY_RS_VERSION}` function getSysproxyNodeName() { + // 检测是否为 musl 系统(与 src/native/sysproxy/index.js 保持一致) const isMusl = (() => { if (platform !== 'linux') return false try { - // 通过 ldd --version 输出判断是否为 musl const output = execSync('ldd --version 2>&1 || true').toString() return output.includes('musl') } catch { diff --git a/src/native/sysproxy/index.js b/src/native/sysproxy/index.js index 55e76c5..5b10653 100644 --- a/src/native/sysproxy/index.js +++ b/src/native/sysproxy/index.js @@ -1,4 +1,4 @@ -const { existsSync, readFileSync } = require('fs') +const { existsSync } = require('fs') const { join, dirname } = require('path') const { platform, arch } = process @@ -7,17 +7,19 @@ let nativeBinding = null let loadError = null function isMusl() { - if (!process.report || typeof process.report.getReport !== 'function') { - try { - const lddPath = require('child_process').execSync('which ldd').toString().trim() - return readFileSync(lddPath, 'utf8').includes('musl') - } catch { - return true - } - } else { + // 优先使用 process.report(Node.js 12+,最可靠) + if (process.report && typeof process.report.getReport === 'function') { const { glibcVersionRuntime } = process.report.getReport().header return !glibcVersionRuntime } + // 备选:检查 ldd --version 输出 + try { + const { execSync } = require('child_process') + const output = execSync('ldd --version 2>&1 || true').toString() + return output.includes('musl') + } catch { + return false + } } function getBindingName() {