fix: 修复无需鉴权的 Socks5 代理无法使用的问题

This commit is contained in:
foxhui
2026-01-25 03:54:29 +08:00
Unverified
parent 5b7d1e9322
commit 02847223dc
11 changed files with 650 additions and 180 deletions
+16 -9
View File
@@ -17,6 +17,16 @@ const log = (msg) => console.log(`[postinstall] ${msg}`);
const warn = (msg) => console.warn(`[postinstall] ⚠️ ${msg}`);
const error = (msg) => console.error(`[postinstall] ❌ ${msg}`);
/**
* 补丁文件映射: 源文件名 -> 目标文件名
* 供 preflight.js 自检系统复用
*/
export const CAMOUFOX_PATCHES = {
'camoufox-js@0.8.3.locale.patched.js': 'locale.js',
'camoufox-js@0.8.3.pkgman.patched.js': 'pkgman.js',
'camoufox-js@0.8.3.utils.patched.js': 'utils.js' // SOCKS5 代理修复
};
/**
* 复制 camoufox-js 补丁文件到 node_modules
*/
@@ -33,13 +43,7 @@ function patchCamoufoxJs() {
return;
}
// 补丁文件映射: 源文件名 -> 目标文件名
const patches = {
'camoufox-js@0.8.3.locale.patched.js': 'locale.js',
'camoufox-js@0.8.3.pkgman.patched.js': 'pkgman.js'
};
for (const [srcName, destName] of Object.entries(patches)) {
for (const [srcName, destName] of Object.entries(CAMOUFOX_PATCHES)) {
const srcPath = path.join(patchDir, srcName);
const destPath = path.join(targetDir, destName);
@@ -59,5 +63,8 @@ function patchCamoufoxJs() {
log('补丁应用完成。');
}
// 执行
patchCamoufoxJs();
import { fileURLToPath as _fileURLToPath } from 'url';
const isMainModule = process.argv[1] === _fileURLToPath(import.meta.url);
if (isMainModule) {
patchCamoufoxJs();
}