panrouter 5.0.2 → 5.0.3
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/package.json +1 -1
- package/pool-worker.mjs +6 -5
package/package.json
CHANGED
package/pool-worker.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 启动 server.mjs → 拉起 cloudflared 匿名隧道 → 心跳上报主控中心。
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
9
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
10
10
|
import https from "node:https";
|
|
11
11
|
import http from "node:http";
|
|
12
12
|
import os from "node:os";
|
|
@@ -47,16 +47,17 @@ function findCloudflared() {
|
|
|
47
47
|
const candidates = ["cloudflared", "cloudflared.exe"];
|
|
48
48
|
for (const name of candidates) {
|
|
49
49
|
try {
|
|
50
|
-
const r =
|
|
50
|
+
const r = spawnSync(name, ["--version"], { stdio: "pipe", timeout: 3000 });
|
|
51
51
|
if (r.status === 0) return name;
|
|
52
52
|
} catch { /* try next */ }
|
|
53
53
|
}
|
|
54
|
-
//
|
|
55
|
-
const
|
|
54
|
+
// 常见安装路径兜底
|
|
55
|
+
const fallbackPaths = [
|
|
56
56
|
path.join(process.env.USERPROFILE || "", "AppData", "Local", "cloudflared", "cloudflared.exe"),
|
|
57
57
|
path.join(process.env.LOCALAPPDATA || "", "cloudflared", "cloudflared.exe"),
|
|
58
|
+
"/data/data/com.termux/files/usr/bin/cloudflared",
|
|
58
59
|
];
|
|
59
|
-
for (const p of
|
|
60
|
+
for (const p of fallbackPaths) {
|
|
60
61
|
if (fs.existsSync(p)) return p;
|
|
61
62
|
}
|
|
62
63
|
return null;
|