@bifrost-proxy/bifrost 0.0.63 → 0.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +2 -25
- package/lib/index.js +2 -38
- package/lib/platform.js +112 -0
- package/package.json +11 -10
package/install.js
CHANGED
|
@@ -4,6 +4,7 @@ const path = require("path");
|
|
|
4
4
|
const zlib = require("zlib");
|
|
5
5
|
const https = require("https");
|
|
6
6
|
const child_process = require("child_process");
|
|
7
|
+
const { getPlatformKey } = require("./lib/platform.js");
|
|
7
8
|
|
|
8
9
|
const packageJSON = require(path.join(__dirname, "package.json"));
|
|
9
10
|
|
|
@@ -19,32 +20,8 @@ const PLATFORM_MAP = {
|
|
|
19
20
|
"win32-arm64": { pkg: "@bifrost-proxy/bifrost-win32-arm64", binary: "bifrost.exe" },
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
function detectLibc() {
|
|
23
|
-
if (process.platform !== "linux") return null;
|
|
24
|
-
try {
|
|
25
|
-
const lddOutput = child_process.execSync("ldd --version 2>&1 || true", {
|
|
26
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
27
|
-
encoding: "utf8",
|
|
28
|
-
});
|
|
29
|
-
if (/musl/i.test(lddOutput)) return "musl";
|
|
30
|
-
if (/GLIBC|GNU libc/i.test(lddOutput)) return "glibc";
|
|
31
|
-
} catch {}
|
|
32
|
-
try {
|
|
33
|
-
if (fs.existsSync("/lib/ld-musl-x86_64.so.1") ||
|
|
34
|
-
fs.existsSync("/lib/ld-musl-aarch64.so.1") ||
|
|
35
|
-
fs.existsSync("/lib/ld-musl-armhf.so.1")) {
|
|
36
|
-
return "musl";
|
|
37
|
-
}
|
|
38
|
-
} catch {}
|
|
39
|
-
return "glibc";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
23
|
function getPlatformInfo() {
|
|
43
|
-
|
|
44
|
-
if (process.platform === "linux") {
|
|
45
|
-
const libc = detectLibc();
|
|
46
|
-
key = `${key}-${libc}`;
|
|
47
|
-
}
|
|
24
|
+
const key = getPlatformKey({ arch: os.arch() });
|
|
48
25
|
const info = PLATFORM_MAP[key];
|
|
49
26
|
if (!info) {
|
|
50
27
|
throw new Error(
|
package/lib/index.js
CHANGED
|
@@ -1,46 +1,10 @@
|
|
|
1
1
|
const { platform, arch } = process;
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const PLATFORM_MAP = {
|
|
7
|
-
"linux-x64-glibc": "@bifrost-proxy/bifrost-linux-x64",
|
|
8
|
-
"linux-x64-musl": "@bifrost-proxy/bifrost-linux-x64-musl",
|
|
9
|
-
"linux-arm64-glibc": "@bifrost-proxy/bifrost-linux-arm64",
|
|
10
|
-
"linux-arm64-musl": "@bifrost-proxy/bifrost-linux-arm64-musl",
|
|
11
|
-
"linux-arm-glibc": "@bifrost-proxy/bifrost-linux-arm",
|
|
12
|
-
"darwin-x64": "@bifrost-proxy/bifrost-darwin-x64",
|
|
13
|
-
"darwin-arm64": "@bifrost-proxy/bifrost-darwin-arm64",
|
|
14
|
-
"win32-x64": "@bifrost-proxy/bifrost-win32-x64",
|
|
15
|
-
"win32-arm64": "@bifrost-proxy/bifrost-win32-arm64",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function detectLibc() {
|
|
19
|
-
if (platform !== "linux") return null;
|
|
20
|
-
try {
|
|
21
|
-
const lddOutput = child_process.execSync("ldd --version 2>&1 || true", {
|
|
22
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
23
|
-
encoding: "utf8",
|
|
24
|
-
});
|
|
25
|
-
if (/musl/i.test(lddOutput)) return "musl";
|
|
26
|
-
if (/GLIBC|GNU libc/i.test(lddOutput)) return "glibc";
|
|
27
|
-
} catch {}
|
|
28
|
-
try {
|
|
29
|
-
if (fs.existsSync("/lib/ld-musl-x86_64.so.1") ||
|
|
30
|
-
fs.existsSync("/lib/ld-musl-aarch64.so.1") ||
|
|
31
|
-
fs.existsSync("/lib/ld-musl-armhf.so.1")) {
|
|
32
|
-
return "musl";
|
|
33
|
-
}
|
|
34
|
-
} catch {}
|
|
35
|
-
return "glibc";
|
|
36
|
-
}
|
|
4
|
+
const { PLATFORM_MAP, getPlatformKey } = require("./platform.js");
|
|
37
5
|
|
|
38
6
|
function getBinaryPath() {
|
|
39
|
-
|
|
40
|
-
if (platform === "linux") {
|
|
41
|
-
const libc = detectLibc();
|
|
42
|
-
key = `${key}-${libc}`;
|
|
43
|
-
}
|
|
7
|
+
const key = getPlatformKey({ platform, arch });
|
|
44
8
|
const packageName = PLATFORM_MAP[key];
|
|
45
9
|
|
|
46
10
|
if (!packageName) {
|
package/lib/platform.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const child_process = require("child_process");
|
|
3
|
+
|
|
4
|
+
const MIN_GLIBC_VERSION = "2.39";
|
|
5
|
+
|
|
6
|
+
const PLATFORM_MAP = {
|
|
7
|
+
"linux-x64-glibc": "@bifrost-proxy/bifrost-linux-x64",
|
|
8
|
+
"linux-x64-musl": "@bifrost-proxy/bifrost-linux-x64-musl",
|
|
9
|
+
"linux-arm64-glibc": "@bifrost-proxy/bifrost-linux-arm64",
|
|
10
|
+
"linux-arm64-musl": "@bifrost-proxy/bifrost-linux-arm64-musl",
|
|
11
|
+
"linux-arm-glibc": "@bifrost-proxy/bifrost-linux-arm",
|
|
12
|
+
"darwin-x64": "@bifrost-proxy/bifrost-darwin-x64",
|
|
13
|
+
"darwin-arm64": "@bifrost-proxy/bifrost-darwin-arm64",
|
|
14
|
+
"win32-x64": "@bifrost-proxy/bifrost-win32-x64",
|
|
15
|
+
"win32-arm64": "@bifrost-proxy/bifrost-win32-arm64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function parseVersion(version) {
|
|
19
|
+
return String(version)
|
|
20
|
+
.split(".")
|
|
21
|
+
.map((part) => Number.parseInt(part, 10))
|
|
22
|
+
.filter((part) => Number.isFinite(part));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function versionLt(left, right) {
|
|
26
|
+
const a = parseVersion(left);
|
|
27
|
+
const b = parseVersion(right);
|
|
28
|
+
const length = Math.max(a.length, b.length);
|
|
29
|
+
for (let i = 0; i < length; i++) {
|
|
30
|
+
const ai = a[i] || 0;
|
|
31
|
+
const bi = b[i] || 0;
|
|
32
|
+
if (ai < bi) return true;
|
|
33
|
+
if (ai > bi) return false;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parseGlibcVersion(lddOutput) {
|
|
39
|
+
const text = String(lddOutput || "");
|
|
40
|
+
if (!/GLIBC|GNU libc/i.test(text)) return null;
|
|
41
|
+
const match = text.match(/[0-9]+\.[0-9]+/);
|
|
42
|
+
return match ? match[0] : null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function hasMuslLoader(existsSync = fs.existsSync) {
|
|
46
|
+
try {
|
|
47
|
+
return (
|
|
48
|
+
existsSync("/lib/ld-musl-x86_64.so.1") ||
|
|
49
|
+
existsSync("/lib/ld-musl-aarch64.so.1") ||
|
|
50
|
+
existsSync("/lib/ld-musl-armhf.so.1")
|
|
51
|
+
);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function detectLinuxLibc(options = {}) {
|
|
58
|
+
const execSync = options.execSync || child_process.execSync;
|
|
59
|
+
const existsSync = options.existsSync || fs.existsSync;
|
|
60
|
+
|
|
61
|
+
let lddOutput = "";
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(options, "lddOutput")) {
|
|
63
|
+
lddOutput = options.lddOutput;
|
|
64
|
+
} else {
|
|
65
|
+
try {
|
|
66
|
+
lddOutput = execSync("ldd --version 2>&1 || true", {
|
|
67
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
68
|
+
encoding: "utf8",
|
|
69
|
+
});
|
|
70
|
+
} catch {}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (/musl/i.test(lddOutput)) return "musl";
|
|
74
|
+
|
|
75
|
+
const glibcVersion = parseGlibcVersion(lddOutput);
|
|
76
|
+
if (glibcVersion) {
|
|
77
|
+
return versionLt(glibcVersion, MIN_GLIBC_VERSION) ? "musl" : "glibc";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (hasMuslLoader(existsSync)) return "musl";
|
|
81
|
+
|
|
82
|
+
return "musl";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getPlatformKey(options = {}) {
|
|
86
|
+
const platform = options.platform || process.platform;
|
|
87
|
+
const arch = options.arch || process.arch;
|
|
88
|
+
|
|
89
|
+
let key = `${platform}-${arch}`;
|
|
90
|
+
if (platform === "linux") {
|
|
91
|
+
if (arch === "arm") {
|
|
92
|
+
return `${key}-glibc`;
|
|
93
|
+
}
|
|
94
|
+
key = `${key}-${detectLinuxLibc(options)}`;
|
|
95
|
+
}
|
|
96
|
+
return key;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getPackageName(options = {}) {
|
|
100
|
+
const key = getPlatformKey(options);
|
|
101
|
+
return PLATFORM_MAP[key] || null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = {
|
|
105
|
+
MIN_GLIBC_VERSION,
|
|
106
|
+
PLATFORM_MAP,
|
|
107
|
+
detectLinuxLibc,
|
|
108
|
+
getPackageName,
|
|
109
|
+
getPlatformKey,
|
|
110
|
+
parseGlibcVersion,
|
|
111
|
+
versionLt,
|
|
112
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bifrost-proxy/bifrost",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "High-performance HTTP/HTTPS/SOCKS5 proxy server written in Rust",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,18 +35,19 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"bin/bifrost",
|
|
37
37
|
"lib/index.js",
|
|
38
|
+
"lib/platform.js",
|
|
38
39
|
"install.js",
|
|
39
40
|
"README.md"
|
|
40
41
|
],
|
|
41
42
|
"optionalDependencies": {
|
|
42
|
-
"@bifrost-proxy/bifrost-linux-x64": "0.0.
|
|
43
|
-
"@bifrost-proxy/bifrost-linux-arm64": "0.0.
|
|
44
|
-
"@bifrost-proxy/bifrost-linux-arm": "0.0.
|
|
45
|
-
"@bifrost-proxy/bifrost-linux-x64-musl": "0.0.
|
|
46
|
-
"@bifrost-proxy/bifrost-linux-arm64-musl": "0.0.
|
|
47
|
-
"@bifrost-proxy/bifrost-darwin-x64": "0.0.
|
|
48
|
-
"@bifrost-proxy/bifrost-darwin-arm64": "0.0.
|
|
49
|
-
"@bifrost-proxy/bifrost-win32-x64": "0.0.
|
|
50
|
-
"@bifrost-proxy/bifrost-win32-arm64": "0.0.
|
|
43
|
+
"@bifrost-proxy/bifrost-linux-x64": "0.0.64",
|
|
44
|
+
"@bifrost-proxy/bifrost-linux-arm64": "0.0.64",
|
|
45
|
+
"@bifrost-proxy/bifrost-linux-arm": "0.0.64",
|
|
46
|
+
"@bifrost-proxy/bifrost-linux-x64-musl": "0.0.64",
|
|
47
|
+
"@bifrost-proxy/bifrost-linux-arm64-musl": "0.0.64",
|
|
48
|
+
"@bifrost-proxy/bifrost-darwin-x64": "0.0.64",
|
|
49
|
+
"@bifrost-proxy/bifrost-darwin-arm64": "0.0.64",
|
|
50
|
+
"@bifrost-proxy/bifrost-win32-x64": "0.0.64",
|
|
51
|
+
"@bifrost-proxy/bifrost-win32-arm64": "0.0.64"
|
|
51
52
|
}
|
|
52
53
|
}
|