pinggy 0.6.3 → 0.6.5
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/ARCHITECTURE.md +76 -47
- package/CLAUDE.md +13 -8
- package/README.md +20 -11
- package/dist/{TunnelManager-NGSUBZYI.js → TunnelManager-DXNXIH5W.js} +3 -3
- package/dist/{TunnelTui-UCG2YSLX.js → TunnelTui-K7KESRTQ.js} +3 -3
- package/dist/{chunk-GESMZQHI.js → chunk-3PTLHLFL.js} +33 -10
- package/dist/{chunk-QNUVQ6KD.js → chunk-EMCDDH3B.js} +2 -2
- package/dist/{chunk-MV56U3E6.js → chunk-IRKMUV37.js} +2 -2
- package/dist/{chunk-TG6LBCPG.js → chunk-K5QHR5KU.js} +1129 -340
- package/dist/{chunk-AFMTIELL.js → chunk-N5WE4DYD.js} +8 -0
- package/dist/{chunk-Y435RMHQ.js → chunk-QZJGTQZC.js} +2 -2
- package/dist/{chunk-PD7HXVQ3.js → chunk-X6TZN5CT.js} +18 -1
- package/dist/{configStore-RR5ZU4E3.js → configStore-DXC6WMYO.js} +3 -3
- package/dist/{daemonChild-E73NFWKE.js → daemonChild-HZ27YJKQ.js} +7 -11
- package/dist/daemonConfig-MCAKZHY2.js +17 -0
- package/dist/index.cjs +1258 -365
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +6 -6
- package/dist/{main-M6MACH7D.js → main-TDQB5ZB4.js} +7 -7
- package/dist/workers/file_serve_worker.js +1 -1
- package/package.json +14 -3
- package/scripts/install/install.ps1 +51 -8
- package/scripts/install/install.sh +67 -7
- package/dist/daemonConfig-QVXQ47XH.js +0 -9
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
TunnelAlreadyRunningError,
|
|
3
3
|
TunnelManager,
|
|
4
4
|
TunnelRebuildInProgressError
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EMCDDH3B.js";
|
|
6
6
|
import "./chunk-UB26QJ4T.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-IRKMUV37.js";
|
|
8
|
+
import "./chunk-N5WE4DYD.js";
|
|
9
9
|
export {
|
|
10
10
|
TunnelAlreadyRunningError,
|
|
11
11
|
TunnelManager,
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
} from "./chunk-XZ64ZAGO.js";
|
|
4
4
|
import {
|
|
5
5
|
TunnelManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EMCDDH3B.js";
|
|
7
7
|
import "./chunk-UB26QJ4T.js";
|
|
8
8
|
import {
|
|
9
9
|
logger
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-IRKMUV37.js";
|
|
11
|
+
import "./chunk-N5WE4DYD.js";
|
|
12
12
|
|
|
13
13
|
// src/tui/blessed/TunnelTui.ts
|
|
14
14
|
import blessed3 from "blessed";
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
newStats,
|
|
23
23
|
newStatus,
|
|
24
24
|
printer_default
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-EMCDDH3B.js";
|
|
26
26
|
import {
|
|
27
27
|
logger
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-IRKMUV37.js";
|
|
29
29
|
import {
|
|
30
30
|
getDaemonInfoPath,
|
|
31
31
|
getDaemonLogPath
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-N5WE4DYD.js";
|
|
33
33
|
|
|
34
34
|
// src/remote_management/remote_schema.ts
|
|
35
35
|
import { HaProxyVersion, TunnelType } from "@pinggy/pinggy";
|
|
@@ -1507,21 +1507,27 @@ import { spawn } from "child_process";
|
|
|
1507
1507
|
var inProcessHandle = null;
|
|
1508
1508
|
var DAEMON_SPAWN_TIMEOUT_MS = 8e3;
|
|
1509
1509
|
var DAEMON_POLL_INTERVAL_MS = 200;
|
|
1510
|
+
var BOOT_TIME_TOLERANCE_MILLIS = 6e4;
|
|
1510
1511
|
function isProcessAlive(pid) {
|
|
1511
1512
|
try {
|
|
1512
1513
|
process.kill(pid, 0);
|
|
1513
1514
|
return true;
|
|
1514
|
-
} catch {
|
|
1515
|
-
return
|
|
1515
|
+
} catch (err) {
|
|
1516
|
+
return err.code === "EPERM";
|
|
1516
1517
|
}
|
|
1517
1518
|
}
|
|
1519
|
+
function startedBeforeBoot(startedAt) {
|
|
1520
|
+
const startedAtMillis = Date.parse(startedAt);
|
|
1521
|
+
const bootMillis = Date.now() - os.uptime() * 1e3;
|
|
1522
|
+
return Number.isNaN(startedAtMillis) || startedAtMillis < bootMillis - BOOT_TIME_TOLERANCE_MILLIS;
|
|
1523
|
+
}
|
|
1518
1524
|
function getDaemonInfo() {
|
|
1519
1525
|
const infoPath = getDaemonInfoPath();
|
|
1520
1526
|
if (!fs.existsSync(infoPath)) return null;
|
|
1521
1527
|
try {
|
|
1522
1528
|
const data = JSON.parse(fs.readFileSync(infoPath, "utf-8"));
|
|
1523
1529
|
if (!data.pid || !data.port) return null;
|
|
1524
|
-
if (!isProcessAlive(data.pid)) {
|
|
1530
|
+
if (startedBeforeBoot(data.startedAt) || !isProcessAlive(data.pid)) {
|
|
1525
1531
|
logger.info("Stale daemon.json found, cleaning up", { stalePid: data.pid });
|
|
1526
1532
|
try {
|
|
1527
1533
|
fs.unlinkSync(infoPath);
|
|
@@ -1581,7 +1587,7 @@ async function startDaemon() {
|
|
|
1581
1587
|
exitCode = code;
|
|
1582
1588
|
});
|
|
1583
1589
|
child.unref();
|
|
1584
|
-
const info = await pollForDaemonInfo(DAEMON_SPAWN_TIMEOUT_MS, () => exited);
|
|
1590
|
+
const info = await pollForDaemonInfo(DAEMON_SPAWN_TIMEOUT_MS, () => exited && exitCode !== 0);
|
|
1585
1591
|
if (!info) {
|
|
1586
1592
|
const logPath = getDaemonLogPath();
|
|
1587
1593
|
if (exited) {
|
|
@@ -1601,7 +1607,7 @@ async function ensureDaemonRunning() {
|
|
|
1601
1607
|
return existing;
|
|
1602
1608
|
}
|
|
1603
1609
|
if (process.versions.electron) {
|
|
1604
|
-
const { runDaemonChild } = await import("./daemonChild-
|
|
1610
|
+
const { runDaemonChild } = await import("./daemonChild-HZ27YJKQ.js");
|
|
1605
1611
|
const handle = await runDaemonChild({
|
|
1606
1612
|
installSignalHandlers: false,
|
|
1607
1613
|
exitOnFailure: false,
|
|
@@ -2094,7 +2100,22 @@ var TunnelClient = class _TunnelClient {
|
|
|
2094
2100
|
this.health = new DaemonHealth(() => this.ipc, this.stream);
|
|
2095
2101
|
}
|
|
2096
2102
|
async ensureDaemon() {
|
|
2097
|
-
|
|
2103
|
+
this.bindDaemon(await ensureDaemonRunning());
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* Connects to the daemon that runs now, and never starts one. For commands that only read state.
|
|
2107
|
+
* Throws when that daemon speaks another IPC version, as ensureDaemon() does.
|
|
2108
|
+
*
|
|
2109
|
+
* @returns false when no daemon runs
|
|
2110
|
+
*/
|
|
2111
|
+
connectIfRunning() {
|
|
2112
|
+
const info = getDaemonInfo();
|
|
2113
|
+
if (!info) return false;
|
|
2114
|
+
if (!isIpcCompatible(info)) throw new Error(ipcMismatchMessage(info));
|
|
2115
|
+
this.bindDaemon(info);
|
|
2116
|
+
return true;
|
|
2117
|
+
}
|
|
2118
|
+
bindDaemon(info) {
|
|
2098
2119
|
this.ipc = new IPCClient(info.port, this.origin);
|
|
2099
2120
|
this.health.bindPid(info.pid);
|
|
2100
2121
|
this.health.reset();
|
|
@@ -2216,7 +2237,7 @@ var TunnelClient = class _TunnelClient {
|
|
|
2216
2237
|
this.assertClient();
|
|
2217
2238
|
await this.ipc.restartTunnel(tunnelId);
|
|
2218
2239
|
}
|
|
2219
|
-
// Device agent (`pinggy device connect
|
|
2240
|
+
// Device agent (`pinggy device connect`). The daemon reads the token and the server from
|
|
2220
2241
|
// device.json, so none of these takes either.
|
|
2221
2242
|
async getDeviceAgentStatus() {
|
|
2222
2243
|
this.assertClient();
|
|
@@ -2374,6 +2395,8 @@ export {
|
|
|
2374
2395
|
closeRemoteManagement,
|
|
2375
2396
|
startRemoteManagement,
|
|
2376
2397
|
getRemoteManagementState,
|
|
2398
|
+
isProcessAlive,
|
|
2399
|
+
startedBeforeBoot,
|
|
2377
2400
|
getDaemonInfo,
|
|
2378
2401
|
isDaemonRunning,
|
|
2379
2402
|
daemonIpcVersion,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
getLogLevel,
|
|
6
6
|
logger
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IRKMUV37.js";
|
|
8
8
|
import {
|
|
9
9
|
getTunnelLogPath
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-N5WE4DYD.js";
|
|
11
11
|
|
|
12
12
|
// src/tunnel_manager/TunnelManager.ts
|
|
13
13
|
import { TunnelInstance, LogLevel as SdkLogLevel } from "@pinggy/pinggy";
|
|
@@ -14,9 +14,9 @@ function setLogLevel(level) {
|
|
|
14
14
|
if (_sdkLogFilePath) {
|
|
15
15
|
enableLoggingByLogLevelInSdk(level, _sdkLogFilePath);
|
|
16
16
|
}
|
|
17
|
-
import("./daemonConfig-
|
|
17
|
+
import("./daemonConfig-MCAKZHY2.js").then(({ writeDaemonConfig }) => writeDaemonConfig({ logLevel: level })).catch(() => {
|
|
18
18
|
});
|
|
19
|
-
import("./TunnelManager-
|
|
19
|
+
import("./TunnelManager-DXNXIH5W.js").then(({ TunnelManager }) => TunnelManager.getInstance().applyLogLevelToActiveTunnels(level)).catch(() => {
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
var _logger = null;
|