@node9/proxy 1.10.1 → 1.10.2
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/dist/cli.js +44 -9
- package/dist/cli.mjs +44 -9
- package/dist/index.js +30 -5
- package/dist/index.mjs +30 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2457,19 +2457,44 @@ function getInternalToken() {
|
|
|
2457
2457
|
function isDaemonRunning() {
|
|
2458
2458
|
const pidFile = import_path10.default.join(import_os8.default.homedir(), ".node9", "daemon.pid");
|
|
2459
2459
|
if (import_fs9.default.existsSync(pidFile)) {
|
|
2460
|
+
let pid;
|
|
2461
|
+
let port;
|
|
2460
2462
|
try {
|
|
2461
|
-
const
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
return true;
|
|
2463
|
+
const data = JSON.parse(import_fs9.default.readFileSync(pidFile, "utf-8"));
|
|
2464
|
+
pid = data.pid;
|
|
2465
|
+
port = data.port;
|
|
2465
2466
|
} catch {
|
|
2466
2467
|
return false;
|
|
2467
2468
|
}
|
|
2469
|
+
if (port !== DAEMON_PORT) {
|
|
2470
|
+
return false;
|
|
2471
|
+
}
|
|
2472
|
+
const MAX_PID = 4194304;
|
|
2473
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || pid > MAX_PID) {
|
|
2474
|
+
return false;
|
|
2475
|
+
}
|
|
2476
|
+
try {
|
|
2477
|
+
process.kill(pid, 0);
|
|
2478
|
+
} catch (err2) {
|
|
2479
|
+
if (err2 instanceof Error && "code" in err2 && err2.code === "ESRCH") {
|
|
2480
|
+
try {
|
|
2481
|
+
import_fs9.default.unlinkSync(pidFile);
|
|
2482
|
+
} catch {
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
return false;
|
|
2486
|
+
}
|
|
2487
|
+
const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2488
|
+
encoding: "utf8",
|
|
2489
|
+
timeout: 300
|
|
2490
|
+
});
|
|
2491
|
+
if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
|
|
2492
|
+
return false;
|
|
2468
2493
|
}
|
|
2469
2494
|
try {
|
|
2470
2495
|
const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2471
2496
|
encoding: "utf8",
|
|
2472
|
-
timeout:
|
|
2497
|
+
timeout: 300
|
|
2473
2498
|
});
|
|
2474
2499
|
return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
|
|
2475
2500
|
} catch {
|
|
@@ -9334,10 +9359,10 @@ RAW: ${raw}
|
|
|
9334
9359
|
if (typeof scriptPath !== "string" || !import_path22.default.isAbsolute(scriptPath))
|
|
9335
9360
|
throw new Error("node9: argv[1] is not an absolute path");
|
|
9336
9361
|
const resolvedScript = import_fs20.default.realpathSync(scriptPath);
|
|
9337
|
-
const
|
|
9338
|
-
if (resolvedScript !==
|
|
9362
|
+
const packageDist = import_fs20.default.realpathSync(import_path22.default.resolve(__dirname, "../.."));
|
|
9363
|
+
if (!resolvedScript.startsWith(packageDist + import_path22.default.sep) && resolvedScript !== packageDist)
|
|
9339
9364
|
throw new Error(
|
|
9340
|
-
|
|
9365
|
+
`node9: daemon spawn aborted \u2014 argv[1] (${resolvedScript}) is outside package dist (${packageDist})`
|
|
9341
9366
|
);
|
|
9342
9367
|
const safeEnv = { ...process.env };
|
|
9343
9368
|
for (const key of [
|
|
@@ -9356,7 +9381,17 @@ RAW: ${raw}
|
|
|
9356
9381
|
env: { ...safeEnv, NODE9_AUTO_STARTED: "1", NODE9_BROWSER_OPENED: "1" }
|
|
9357
9382
|
});
|
|
9358
9383
|
d.unref();
|
|
9359
|
-
} catch {
|
|
9384
|
+
} catch (spawnErr) {
|
|
9385
|
+
const logPath = import_path22.default.join(import_os16.default.homedir(), ".node9", "hook-debug.log");
|
|
9386
|
+
const msg = spawnErr instanceof Error ? spawnErr.message : String(spawnErr);
|
|
9387
|
+
try {
|
|
9388
|
+
import_fs20.default.appendFileSync(
|
|
9389
|
+
logPath,
|
|
9390
|
+
`[${(/* @__PURE__ */ new Date()).toISOString()}] daemon-autostart-failed: ${msg}
|
|
9391
|
+
`
|
|
9392
|
+
);
|
|
9393
|
+
} catch {
|
|
9394
|
+
}
|
|
9360
9395
|
}
|
|
9361
9396
|
}
|
|
9362
9397
|
if (process.env.NODE9_DEBUG === "1" || config.settings.enableHookLogDebug) {
|
package/dist/cli.mjs
CHANGED
|
@@ -2440,19 +2440,44 @@ function getInternalToken() {
|
|
|
2440
2440
|
function isDaemonRunning() {
|
|
2441
2441
|
const pidFile = path10.join(os8.homedir(), ".node9", "daemon.pid");
|
|
2442
2442
|
if (fs9.existsSync(pidFile)) {
|
|
2443
|
+
let pid;
|
|
2444
|
+
let port;
|
|
2443
2445
|
try {
|
|
2444
|
-
const
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
return true;
|
|
2446
|
+
const data = JSON.parse(fs9.readFileSync(pidFile, "utf-8"));
|
|
2447
|
+
pid = data.pid;
|
|
2448
|
+
port = data.port;
|
|
2448
2449
|
} catch {
|
|
2449
2450
|
return false;
|
|
2450
2451
|
}
|
|
2452
|
+
if (port !== DAEMON_PORT) {
|
|
2453
|
+
return false;
|
|
2454
|
+
}
|
|
2455
|
+
const MAX_PID = 4194304;
|
|
2456
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || pid > MAX_PID) {
|
|
2457
|
+
return false;
|
|
2458
|
+
}
|
|
2459
|
+
try {
|
|
2460
|
+
process.kill(pid, 0);
|
|
2461
|
+
} catch (err2) {
|
|
2462
|
+
if (err2 instanceof Error && "code" in err2 && err2.code === "ESRCH") {
|
|
2463
|
+
try {
|
|
2464
|
+
fs9.unlinkSync(pidFile);
|
|
2465
|
+
} catch {
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
return false;
|
|
2469
|
+
}
|
|
2470
|
+
const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2471
|
+
encoding: "utf8",
|
|
2472
|
+
timeout: 300
|
|
2473
|
+
});
|
|
2474
|
+
if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
|
|
2475
|
+
return false;
|
|
2451
2476
|
}
|
|
2452
2477
|
try {
|
|
2453
2478
|
const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2454
2479
|
encoding: "utf8",
|
|
2455
|
-
timeout:
|
|
2480
|
+
timeout: 300
|
|
2456
2481
|
});
|
|
2457
2482
|
return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
|
|
2458
2483
|
} catch {
|
|
@@ -9309,10 +9334,10 @@ RAW: ${raw}
|
|
|
9309
9334
|
if (typeof scriptPath !== "string" || !path22.isAbsolute(scriptPath))
|
|
9310
9335
|
throw new Error("node9: argv[1] is not an absolute path");
|
|
9311
9336
|
const resolvedScript = fs20.realpathSync(scriptPath);
|
|
9312
|
-
const
|
|
9313
|
-
if (resolvedScript !==
|
|
9337
|
+
const packageDist = fs20.realpathSync(path22.resolve(__dirname, "../.."));
|
|
9338
|
+
if (!resolvedScript.startsWith(packageDist + path22.sep) && resolvedScript !== packageDist)
|
|
9314
9339
|
throw new Error(
|
|
9315
|
-
|
|
9340
|
+
`node9: daemon spawn aborted \u2014 argv[1] (${resolvedScript}) is outside package dist (${packageDist})`
|
|
9316
9341
|
);
|
|
9317
9342
|
const safeEnv = { ...process.env };
|
|
9318
9343
|
for (const key of [
|
|
@@ -9331,7 +9356,17 @@ RAW: ${raw}
|
|
|
9331
9356
|
env: { ...safeEnv, NODE9_AUTO_STARTED: "1", NODE9_BROWSER_OPENED: "1" }
|
|
9332
9357
|
});
|
|
9333
9358
|
d.unref();
|
|
9334
|
-
} catch {
|
|
9359
|
+
} catch (spawnErr) {
|
|
9360
|
+
const logPath = path22.join(os16.homedir(), ".node9", "hook-debug.log");
|
|
9361
|
+
const msg = spawnErr instanceof Error ? spawnErr.message : String(spawnErr);
|
|
9362
|
+
try {
|
|
9363
|
+
fs20.appendFileSync(
|
|
9364
|
+
logPath,
|
|
9365
|
+
`[${(/* @__PURE__ */ new Date()).toISOString()}] daemon-autostart-failed: ${msg}
|
|
9366
|
+
`
|
|
9367
|
+
);
|
|
9368
|
+
} catch {
|
|
9369
|
+
}
|
|
9335
9370
|
}
|
|
9336
9371
|
}
|
|
9337
9372
|
if (process.env.NODE9_DEBUG === "1" || config.settings.enableHookLogDebug) {
|
package/dist/index.js
CHANGED
|
@@ -1990,19 +1990,44 @@ function getInternalToken() {
|
|
|
1990
1990
|
function isDaemonRunning() {
|
|
1991
1991
|
const pidFile = import_path10.default.join(import_os7.default.homedir(), ".node9", "daemon.pid");
|
|
1992
1992
|
if (import_fs8.default.existsSync(pidFile)) {
|
|
1993
|
+
let pid;
|
|
1994
|
+
let port;
|
|
1993
1995
|
try {
|
|
1994
|
-
const
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
return true;
|
|
1996
|
+
const data = JSON.parse(import_fs8.default.readFileSync(pidFile, "utf-8"));
|
|
1997
|
+
pid = data.pid;
|
|
1998
|
+
port = data.port;
|
|
1998
1999
|
} catch {
|
|
1999
2000
|
return false;
|
|
2000
2001
|
}
|
|
2002
|
+
if (port !== DAEMON_PORT) {
|
|
2003
|
+
return false;
|
|
2004
|
+
}
|
|
2005
|
+
const MAX_PID = 4194304;
|
|
2006
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || pid > MAX_PID) {
|
|
2007
|
+
return false;
|
|
2008
|
+
}
|
|
2009
|
+
try {
|
|
2010
|
+
process.kill(pid, 0);
|
|
2011
|
+
} catch (err) {
|
|
2012
|
+
if (err instanceof Error && "code" in err && err.code === "ESRCH") {
|
|
2013
|
+
try {
|
|
2014
|
+
import_fs8.default.unlinkSync(pidFile);
|
|
2015
|
+
} catch {
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2021
|
+
encoding: "utf8",
|
|
2022
|
+
timeout: 300
|
|
2023
|
+
});
|
|
2024
|
+
if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
|
|
2025
|
+
return false;
|
|
2001
2026
|
}
|
|
2002
2027
|
try {
|
|
2003
2028
|
const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
2004
2029
|
encoding: "utf8",
|
|
2005
|
-
timeout:
|
|
2030
|
+
timeout: 300
|
|
2006
2031
|
});
|
|
2007
2032
|
return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
|
|
2008
2033
|
} catch {
|
package/dist/index.mjs
CHANGED
|
@@ -1960,19 +1960,44 @@ function getInternalToken() {
|
|
|
1960
1960
|
function isDaemonRunning() {
|
|
1961
1961
|
const pidFile = path10.join(os7.homedir(), ".node9", "daemon.pid");
|
|
1962
1962
|
if (fs8.existsSync(pidFile)) {
|
|
1963
|
+
let pid;
|
|
1964
|
+
let port;
|
|
1963
1965
|
try {
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
return true;
|
|
1966
|
+
const data = JSON.parse(fs8.readFileSync(pidFile, "utf-8"));
|
|
1967
|
+
pid = data.pid;
|
|
1968
|
+
port = data.port;
|
|
1968
1969
|
} catch {
|
|
1969
1970
|
return false;
|
|
1970
1971
|
}
|
|
1972
|
+
if (port !== DAEMON_PORT) {
|
|
1973
|
+
return false;
|
|
1974
|
+
}
|
|
1975
|
+
const MAX_PID = 4194304;
|
|
1976
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0 || pid > MAX_PID) {
|
|
1977
|
+
return false;
|
|
1978
|
+
}
|
|
1979
|
+
try {
|
|
1980
|
+
process.kill(pid, 0);
|
|
1981
|
+
} catch (err) {
|
|
1982
|
+
if (err instanceof Error && "code" in err && err.code === "ESRCH") {
|
|
1983
|
+
try {
|
|
1984
|
+
fs8.unlinkSync(pidFile);
|
|
1985
|
+
} catch {
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
1991
|
+
encoding: "utf8",
|
|
1992
|
+
timeout: 300
|
|
1993
|
+
});
|
|
1994
|
+
if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
|
|
1995
|
+
return false;
|
|
1971
1996
|
}
|
|
1972
1997
|
try {
|
|
1973
1998
|
const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
|
|
1974
1999
|
encoding: "utf8",
|
|
1975
|
-
timeout:
|
|
2000
|
+
timeout: 300
|
|
1976
2001
|
});
|
|
1977
2002
|
return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
|
|
1978
2003
|
} catch {
|