pinggy 0.6.4 → 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 +37 -22
- package/CLAUDE.md +8 -5
- package/README.md +5 -5
- package/dist/{TunnelManager-NGSUBZYI.js → TunnelManager-DXNXIH5W.js} +3 -3
- package/dist/{TunnelTui-UCG2YSLX.js → TunnelTui-K7KESRTQ.js} +3 -3
- package/dist/{chunk-CIOYQU7F.js → chunk-3PTLHLFL.js} +32 -9
- package/dist/{chunk-QNUVQ6KD.js → chunk-EMCDDH3B.js} +2 -2
- package/dist/{chunk-MV56U3E6.js → chunk-IRKMUV37.js} +2 -2
- package/dist/{chunk-UVJYL2ZN.js → chunk-K5QHR5KU.js} +648 -238
- 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-WHS676G4.js → daemonChild-HZ27YJKQ.js} +7 -11
- package/dist/daemonConfig-MCAKZHY2.js +17 -0
- package/dist/index.cjs +768 -253
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -6
- package/dist/{main-JRVKAIHH.js → main-TDQB5ZB4.js} +7 -7
- package/dist/workers/file_serve_worker.js +1 -1
- package/package.json +1 -1
- package/scripts/install/install.ps1 +46 -4
- package/scripts/install/install.sh +65 -6
- package/dist/daemonConfig-QVXQ47XH.js +0 -9
package/ARCHITECTURE.md
CHANGED
|
@@ -39,7 +39,9 @@ Logs live under `getPinggyLogDir()`:
|
|
|
39
39
|
```
|
|
40
40
|
<configDir>/
|
|
41
41
|
├── daemon.json Daemon discovery: {pid, port, startedAt}
|
|
42
|
-
├── daemon
|
|
42
|
+
├── daemon.lock Held by the running daemon: {pid, started_at}
|
|
43
|
+
├── daemon-config.json Persisted settings: log level, and the background device agent to start
|
|
44
|
+
├── daemon-state.json Active tunnels, for crash recovery
|
|
43
45
|
├── device.json Device agent identity + token, mode 0600
|
|
44
46
|
└── tunnels/
|
|
45
47
|
└── <name>_<configId>.json Saved tunnel configs (from `pinggy config save`)
|
|
@@ -54,7 +56,7 @@ Helpers live in `src/utils/configDir.ts`: `getDaemonInfoPath`, `getDaemonLogPath
|
|
|
54
56
|
|
|
55
57
|
## 3. Daemon discovery and spawn
|
|
56
58
|
|
|
57
|
-
Every CLI invocation that touches a tunnel asks one question first: is there a live daemon to talk to? `getDaemonInfo()` answers it by reading `daemon.json` and validating the recorded PID with `process.kill(pid, 0)`. Signal 0 never delivers anything; it just throws when the target process is gone, which is exactly the liveness probe we need. A missing file, malformed JSON,
|
|
59
|
+
Every CLI invocation that touches a tunnel asks one question first: is there a live daemon to talk to? `getDaemonInfo()` answers it by reading `daemon.json` and validating the recorded PID with `process.kill(pid, 0)`. Signal 0 never delivers anything; it just throws when the target process is gone, which is exactly the liveness probe we need. A missing file, malformed JSON, a dead PID, or a `startedAt` before the last boot all collapse to the same result: return `null`. After a reboot, another process can have the old daemon's PID, so the boot check runs first. Only commands that start a tunnel (`pinggy start`, legacy `pinggy -l 3000`) then call `ensureDaemonRunning()` to spawn a fresh child. `ps`, `stop`, `restart`, `attach`, `logs` and `log` call `TunnelClient.connectIfRunning()` instead, which never spawns: a new daemon would start every auto-start tunnel. With no daemon, `ps` prints "No active tunnels. The daemon is not running.", `stop` prints "Nothing to stop.", and `restart` and `attach` name the `pinggy start` command when a saved config matches. `logs` and `log path` read the log files directly (`src/daemon/logPaths.ts`), and `log level` reads or writes `daemon-config.json`, which the next daemon starts with.
|
|
58
60
|
|
|
59
61
|
The spawn path is deliberately one-way. The CLI fires off a detached child with the `--_daemon-child` flag and then polls `daemon.json` until the child writes it. The poll budget is 8 seconds at 200ms intervals; a timeout almost always means the SDK failed to load inside the child, in which case the stderr captured from the spawned process is surfaced in the thrown error. Atomic writes of `daemon.json` (write to `.tmp`, then `fs.renameSync`) keep concurrent readers from ever seeing a half-written file.
|
|
60
62
|
|
|
@@ -92,7 +94,9 @@ The spawn path is deliberately one-way. The CLI fires off a detached child with
|
|
|
92
94
|
|
|
93
95
|
Implementation: `src/daemon/daemonManager.ts`.
|
|
94
96
|
|
|
95
|
-
The
|
|
97
|
+
The `daemon.json` check only stops the CLI from spawning a child. 2 CLIs started at the same moment can both find no `daemon.json` and both spawn one, and systemd and launchd run `--_daemon-child` with no check at all. So the daemon itself takes `daemon.lock` (`src/daemon/lifecycle/daemonLock.ts`) before it opens its IPC port. The file is created with the `wx` flag, so only 1 process creates it. A daemon that finds a live holder exits 0, or throws when the app hosts it in-process. Exit code 0 keeps systemd's `Restart=on-failure` from starting it again. The spawning CLI keeps polling after a child exits 0, and gets the winner's `daemon.json`. A lock is stale when its PID is dead (`process.kill(pid, 0)` throws `ESRCH`), when its `started_at` is before the last boot (the PID may name another process now), or when it is unreadable and older than 10s (a crash between create and write). The next daemon deletes a stale lock and creates its own. 2 daemons that find the same stale lock at the same moment can both take it. `EPERM` counts as alive: the service task runs without admin rights, and gets `EPERM` for a daemon started from an Administrator shell. Treating that as dead started a 2nd daemon on Windows. The daemon deletes `daemon.lock` and `daemon.json` on exit only when they hold its own PID.
|
|
98
|
+
|
|
99
|
+
The CLI keeps its `daemon.json` check. It reads the port from that file anyway, and it skips a process start when a daemon already runs.
|
|
96
100
|
|
|
97
101
|
## 4. Daemon child startup sequence
|
|
98
102
|
|
|
@@ -103,6 +107,7 @@ The race between two CLIs invoked at the same moment is bounded but not eliminat
|
|
|
103
107
|
```
|
|
104
108
|
1. ensurePinggyConfigDir(), ensurePinggyLogDir()
|
|
105
109
|
2. Configure winston logger → file: daemon.log, stdout: false
|
|
110
|
+
2a. acquireDaemonLock(): another live daemon holds daemon.lock → exit 0
|
|
106
111
|
3. Create TunnelManager singleton
|
|
107
112
|
4. Create IPCServer (HTTP + WS, port not yet bound)
|
|
108
113
|
5. Create SessionTracker, wire onSessionDisconnect
|
|
@@ -111,6 +116,7 @@ The race between two CLIs invoked at the same moment is bounded but not eliminat
|
|
|
111
116
|
8. Write daemon.json atomically (write to .tmp, rename)
|
|
112
117
|
9. restoreCrashedTunnels() — replay detached tunnels from daemon-state.json
|
|
113
118
|
10. Start auto-start tunnels (getAutoStartConfigs())
|
|
119
|
+
10a. startSavedDeviceAgent(): the background device agent saved in daemon-config.json
|
|
114
120
|
11. Log "Daemon ready"
|
|
115
121
|
|
|
116
122
|
|
|
@@ -257,18 +263,19 @@ Key invariants:
|
|
|
257
263
|
```ts
|
|
258
264
|
interface DaemonState {
|
|
259
265
|
tunnels: DaemonStateTunnel[]; // {tunnelId, configId, name, origin, config, mode, startedAt}
|
|
260
|
-
deviceAgent?: { startedAt: string; startedBy: TunnelOrigin }; // slice 17, absent when none runs
|
|
261
266
|
lastUpdated: string;
|
|
262
267
|
}
|
|
263
268
|
```
|
|
264
269
|
|
|
265
270
|
Two lifecycle paths:
|
|
266
271
|
|
|
267
|
-
- **Clean shutdown** (`/shutdown` or signal): `clearDaemonState()` deletes the file. Next daemon start sees nothing to recover.
|
|
268
|
-
- **Crash** (SIGKILL, OOM, panic): the file remains. Next daemon start calls `restoreCrashedTunnels()`, which restarts each `mode === "detached"` tunnel using the persisted config and stable `tunnelId` (so log files stay continuous). Foreground tunnels are not restored: there is no CLI to attach.
|
|
272
|
+
- **Clean shutdown** (`/shutdown` or signal): `clearDaemonState()` deletes the file. Next daemon start sees nothing to recover.
|
|
273
|
+
- **Crash** (SIGKILL, OOM, panic): the file remains. Next daemon start calls `restoreCrashedTunnels()`, which restarts each `mode === "detached"` tunnel using the persisted config and stable `tunnelId` (so log files stay continuous). Foreground tunnels are not restored: there is no CLI to attach.
|
|
269
274
|
|
|
270
275
|
Auto-start tunnels are independent of crash recovery. They come from saved configs marked `autoStart: true` (`getAutoStartConfigs()`), not from the state file.
|
|
271
276
|
|
|
277
|
+
The background device agent is not in this file either. `deviceAgent` (`{startedAt, startedBy}`) in `daemon-config.json` survives a clean shutdown, so every daemon start runs the agent: after a crash, a `pinggy daemon stop`, or a reboot with `pinggy daemon service-install`. See section 17.
|
|
278
|
+
|
|
272
279
|
## 9. Tunnel lifecycle end-to-end
|
|
273
280
|
|
|
274
281
|
Foreground start (`pinggy start <name>`):
|
|
@@ -346,7 +353,7 @@ src/
|
|
|
346
353
|
│ ├── buildAndStartTunnel.ts Legacy single-tunnel path
|
|
347
354
|
│ ├── buildConfig.ts CLI flags + positionals → FinalConfig
|
|
348
355
|
│ ├── configStore.ts Persisted saved-config CRUD
|
|
349
|
-
│ ├── daemonCommands.ts `pinggy daemon start|stop|status|install
|
|
356
|
+
│ ├── daemonCommands.ts `pinggy daemon start|stop|status|service-install|...`
|
|
350
357
|
│ ├── attachCommand.ts `pinggy attach`
|
|
351
358
|
│ ├── psCommand.ts `pinggy ps`
|
|
352
359
|
│ ├── stopCommand.ts `pinggy stop`
|
|
@@ -466,13 +473,13 @@ Same code path as user-typed subcommands: the daemon does not know or care that
|
|
|
466
473
|
|
|
467
474
|
## 16. Service installation
|
|
468
475
|
|
|
469
|
-
`pinggy daemon install
|
|
476
|
+
`pinggy daemon service-install` writes a platform-specific service file and enables it. `pinggy daemon service-uninstall` stops the daemon and removes it. Code: `src/daemon/lifecycle/serviceInstaller.ts`.
|
|
470
477
|
|
|
471
|
-
- Linux: systemd user unit at `~/.config/systemd/user/pinggy.service`. `Type=simple`, runs `<binary> --_daemon-child` directly (no fork). `systemctl --user enable
|
|
478
|
+
- Linux: systemd user unit at `~/.config/systemd/user/pinggy.service`. `Type=simple`, runs `<binary> --_daemon-child` directly (no fork). `systemctl --user enable`, then `start`.
|
|
472
479
|
- macOS: launchd `LaunchAgent` at `~/Library/LaunchAgents/io.pinggy.agent.plist`. `launchctl load`.
|
|
473
|
-
- Windows: Task Scheduler
|
|
480
|
+
- Windows: Task Scheduler task `PinggyDaemon`, created with `schtasks /Create` and no admin rights. A logon trigger for the current user runs `<binary> daemon start`. `daemon start` spawns `--_daemon-child` detached with `windowsHide`, then exits. The task does not run `--_daemon-child` directly: `pinggy.exe` is a console program, so Task Scheduler opens a console window for it, and closing that window kills the daemon. The `daemon start` window shows for about 1s. The task ends once the daemon is up, so uninstall stops the daemon over IPC. It deletes the task first, so a failed delete leaves the daemon running. With no task, it stops nothing. A task created from an Administrator terminal keeps admin-only permissions, so a normal terminal cannot replace or delete it. When `schtasks` fails, the task exists, and `whoami /groups` shows no High or System integrity SID, pinggy tells the user to run the command from an Administrator terminal. It checks the SID, not the "Access is denied" text, because `schtasks` prints that text in the Windows language.
|
|
474
481
|
|
|
475
|
-
The
|
|
482
|
+
The service stores the full path of the binary (`process.execPath`). If the user moves or deletes that file, the service fails at login with no message. So `service-install` runs only from the path the install scripts write: `%LOCALAPPDATA%\Pinggy\bin\pinggy.exe` on Windows, `~/.pinggy/bin/pinggy` on Linux and macOS (`installerBinaryPath()`). The scripts update the binary in place, so the stored path stays valid. From any other path, and from an npm install, it prints the install script command and exits 1. The message names no paths. `PINGGY_SERVICE_ANY_LOCATION=1` skips the path check, for development and CI. It does not allow npm installs. `service-uninstall` runs from any path. On Linux and macOS, `service-install` starts the service at once, and the service runs `--_daemon-child`. When a daemon already runs, for example after `pinggy device login`, the service's daemon finds `daemon.lock` held and exits 0, so 1 daemon and 1 device agent stay. On Windows the task runs `daemon start`, which finds the running daemon and exits. Changing the install directory in either script means changing `installerBinaryPath()` in the same commit.
|
|
476
483
|
|
|
477
484
|
A system service gives restart-on-failure and start-at-login. The plain daemon mode does not.
|
|
478
485
|
|
|
@@ -482,7 +489,7 @@ The one long-lived surface that is not a tunnel. `pinggy device connect` enrols
|
|
|
482
489
|
|
|
483
490
|
**Email sign-in (slice 12).** `pinggy device login` gets the device token without the dashboard: it asks for an email, `POST /backend/api/v1/device-agent/login/start` emails a 6-digit code, and the code prompt races a `poll` every few seconds under 1 `AbortController`. A right code (and the TOTP, with MFA on) answers the token once. Since slice 13 the email also carries an Approve link: the CLI prints the `match_code` its page shows as `Device Code: <code>`, then `We have sent a 6-digit code to <email>.` and `Enter the code below or click the approve button in the email.` A poll collects a link's approval, and a typed code answered `pending` stops the prompt so the poll can. The CLI writes `device.json`, prints the device's browser link and its QR code (`createQrCodes`, shared with the TUI): a one-time sign-in link after a typed code, the plain device page after the emailed link. Then it runs the same agent. Code in `src/devices/login/`: `deviceLogin.ts` (the command; every dependency injected, so `src/_tests_/deviceLogin.test.ts` runs it with no dashboard or terminal), `loginApi.ts` (`fetch`, `buildDashboardHttpUrl`, the public client token), `login_schema.ts` (zod), `prompts.ts` (`readline/promises`, 1 interface per question, closed on answer or abort; every question starts with a cyan `→`, and the sign-in result with a green one, through `picocolors`; `askHidden` reads the authenticator code without showing it, since the code still works after it is typed and the open link asks for one). A stdin that is not a TTY stops at once and points at `connect --token`. The token is never printed.
|
|
484
491
|
|
|
485
|
-
**Install scripts (slice 14).** `scripts/install/install.sh` (macOS, Linux, POSIX `sh`) and `scripts/install/install.ps1` (Windows PowerShell 5.1 and 7) install or update the binary, put `pinggy` on PATH with no sudo, then
|
|
492
|
+
**Install scripts (slice 14).** `scripts/install/install.sh` (macOS, Linux, POSIX `sh`) and `scripts/install/install.ps1` (Windows PowerShell 5.1 and 7) install or update the binary, put `pinggy` on PATH with no sudo, then ask "Connect this device to Pinggy? [Y/n]". Enter or `y` runs `pinggy device login -b` by full path. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. An answer starting with `n` prints the login command and exits 0, so the CLI is installed with no device. With no terminal, the scripts ask nothing and print the command. `install.sh` writes `~/.pinggy/bin/pinggy` and links `~/.local/bin/pinggy` to it, adding 1 marked block to the shell's rc file when `~/.local/bin` is not on PATH. `install.ps1` writes `%LOCALAPPDATA%\Pinggy\bin\pinggy.exe` and adds that directory to the user PATH. Both read 3 things this repo owns: the release asset names, the `Pinggy CLI version: <x.y.z>` line, and the `--manage` and `-b` flags of `device login` and `connect`. A change to any of them changes both scripts in the same commit. `.github/workflows/website-cli-download-links-pr.yml` copies both, read at the release tag, to the website's `static/`, so pinggy.io serves `/install.sh` and `/install.ps1`. After `device login` or `connect` exits 0, both scripts ask "Start pinggy automatically when this computer starts? [Y/n]" and run `pinggy daemon service-install`. The question says "starts" for users. The service actually starts pinggy after the user signs in, not at boot. They skip the question when the service exists and runs the installed binary: `install.sh` looks for that binary's path in the launchd plist or the systemd unit file, `install.ps1` compares the command of the `PinggyDaemon` task (`Get-ScheduledTask`) with it. A service that runs any other binary gets the question, and `service-install` replaces it. `install.sh` also skips it on Linux with no systemd user manager. With no terminal, they print the `service-install` command. They remove `DEVICE_AGENT_TOKEN` before the question. Renaming the task, the plist or the unit file changes both scripts in the same commit. Lint with `shellcheck -s sh` and `PSScriptAnalyzer`. The step order is in `install-script-plan.md` under the backend's `docs/pinggy-devices/`.
|
|
486
493
|
|
|
487
494
|
**The token command (slice 16).** The dashboard shows `curl -fsSL https://pinggy.io/install.sh | DEVICE_AGENT_TOKEN=<token> sh`, and `$env:DEVICE_AGENT_TOKEN='<token>'; irm https://pinggy.io/install.ps1 | iex` on Windows. With the variable set, both scripts update an older binary without asking, then run `pinggy device connect -b` by full path, with `--manage` when `PINGGY_MANAGE` is set. The token reaches the CLI in its environment, never on a command line, where `ps` would show it. `install.sh` gives `connect` `/dev/null` as stdin, since it reads no key. `install.ps1` removes the variable in a `finally`, because `iex` runs in the user's own window. `handleDevice()` reads `DEVICE_AGENT_TOKEN` and deletes it from `process.env` before any verb runs, so no shell, daemon or other child inherits it (`takeEnvironmentToken()` in `deviceCommand.ts`). `connect` then picks the token from `--token`, else the variable, else `device.json`, and the server from `--manage`, else `dashboard.pinggy.io` for a token from the variable, else the server in `device.json` (`resolveConnectTarget()`). An empty variable counts as unset.
|
|
488
495
|
|
|
@@ -494,7 +501,7 @@ The design lives in the `pinggy_backend` repo under `docs/pinggy-devices/`: `cli
|
|
|
494
501
|
|
|
495
502
|
### Background mode (slice 17)
|
|
496
503
|
|
|
497
|
-
`pinggy device connect` and `pinggy device login` hand the agent to the daemon, as `pinggy start -b` hands it a tunnel, and exit once the device connects. This is the default. `--foreground` (`cliOptions.foreground`, hidden) keeps the agent in the CLI process. `-b` (`cliOptions.b`) still parses and changes nothing. `-b` with `--foreground` exits 1 before anything runs. Whoever hosts the daemon hosts the agent: the CLI's detached child, `pinggy daemon install
|
|
504
|
+
`pinggy device connect` and `pinggy device login` hand the agent to the daemon, as `pinggy start -b` hands it a tunnel, and exit once the device connects. This is the default. `--foreground` (`cliOptions.foreground`, hidden) keeps the agent in the CLI process. `-b` (`cliOptions.b`) still parses and changes nothing. `-b` with `--foreground` exits 1 before anything runs. Whoever hosts the daemon hosts the agent: the CLI's detached child, `pinggy daemon service-install`, or the Pinggy app, whose in-process daemon runs the same `runDaemonChild()`. The app reaches it through `TunnelClient.getDeviceAgentStatus()`, `startDeviceAgent()` and `stopDeviceAgent()`.
|
|
498
505
|
|
|
499
506
|
**The token never goes over IPC.** `device.json` is the hand-off: the CLI writes it, the daemon reads it. The 3 `/device` routes (section 5) read no request field. A target that differs from `device.json` (another token, or another server) is checked first in the CLI with `startDeviceAgent(..., { verifyOnly: true })`: 1 attempt, ended at `welcome`, which writes `device.json` as the foreground agent does. A token the dashboard refuses never reaches the file or the daemon.
|
|
500
507
|
|
|
@@ -509,7 +516,11 @@ The design lives in the `pinggy_backend` repo under `docs/pinggy-devices/`: `cli
|
|
|
509
516
|
|
|
510
517
|
`login` signs in as the foreground does, then runs steps 3 to 6 in place of `runAgent`. After a new sign-in, `runAgent` gets `signInShown`, and step 6 leaves out the email and the device link, which the sign-in already printed. `device stop` calls `POST /device/stop`. `device status` adds a `Background` line from `GET /device`. `device remove` stops a running background agent before it deletes `device.json`. A `--foreground` `connect` or `login` refuses while `GET /device` reports a run: 2 agents on 1 credential refuse each other with `already_connected`.
|
|
511
518
|
|
|
512
|
-
|
|
519
|
+
**The foreground record** (`src/devices/foregroundAgent.ts`). The daemon cannot see an agent started with `--foreground`, so `runDeviceAgent()` writes `device-agent.json` (`{pid, started_at}`) beside `device.json` while it runs, and deletes it on exit if it still names its own PID. The agent checks once a second that the file exists. `device remove` (`src/devices/removeDevice.ts`) first prints the device id, the background agent's state and the foreground record's PID, and asks "Remove this device from this machine? [y/N]". Only `y` or `yes` goes on. `-f`, the existing `cliOptions.force`, skips the question. With no TTY and no `-f`, it exits 1 and changes nothing. Then it deletes the file, waits up to 10 s for the PID to exit, and deletes `device.json`. An agent still running after that fails the remove with exit 1 and leaves `device.json` in place. No signal goes to the PID: a record left by a crash can name an unrelated process. `readForegroundAgent()` deletes a record whose PID is dead or whose `started_at` is before the last boot. `connect` and `login` refuse while a live record names another process, both in the default background start and with `--foreground`. The background start writes no record: the daemon's `GET /device` already reports it. `device status` adds a `Foreground` line.
|
|
520
|
+
|
|
521
|
+
**`DeviceAgentHost`** (`src/daemon/deviceAgentHost.ts`) holds at most 1 run, built in `runDaemonChild()` once the IPC port is known. `start(origin)` reads `device.json`: none answers `DEVICE_NOT_ENROLLED`, a run on the same token and server is left alone, and a run on another is stopped before the new one starts. Start and stop run 1 at a time through 1 promise chain. A run that ends on its own (401, revoked, deleted, replaced) keeps why in `lastError`. The host saves the run in `daemon-config.json` through `saveDeviceAgent()`, and forgets it through `forgetDeviceAgent()` on a terminal outcome. A stop keeps it saved: `device stop` ends the current run only. `close()` on shutdown records nothing, so the run stays saved.
|
|
522
|
+
|
|
523
|
+
**Start with the daemon.** After the auto-start tunnels, `startSavedDeviceAgent()` in `runDaemonChild()` starts the saved agent with its `startedBy`. This runs on every daemon start, the way auto-start tunnels do, so the Pinggy app's in-process daemon starts it too. It skips the start while `device-agent.json` names a live foreground agent: 2 agents on 1 credential refuse each other with `already_connected`. The record stays for the next start. With no `device.json`, the start fails with `DEVICE_NOT_ENROLLED` and the record is deleted. Only `pinggy device remove` deletes the record from the CLI, before it deletes `device.json`. `pinggy device status` prints `Autostart on` while the record exists. A `--foreground` agent never writes it.
|
|
513
524
|
|
|
514
525
|
The daemon's run differs from the foreground one in 3 dependencies, passed through `DeviceAgentOptions`:
|
|
515
526
|
|
|
@@ -520,10 +531,12 @@ The daemon's run differs from the foreground one in 3 dependencies, passed throu
|
|
|
520
531
|
| Event | The background agent |
|
|
521
532
|
| --- | --- |
|
|
522
533
|
| The CLI that ran `connect` exits, or its terminal closes | Keeps running. The daemon is detached |
|
|
523
|
-
| Daemon crash |
|
|
524
|
-
| `pinggy daemon stop`, or the Pinggy app quits | Stops. The socket closes with 1000 and every shell ends |
|
|
525
|
-
| Reboot |
|
|
526
|
-
|
|
|
534
|
+
| Daemon crash | Starts again with the next daemon |
|
|
535
|
+
| `pinggy daemon stop`, or the Pinggy app quits | Stops. The socket closes with 1000 and every shell ends. Starts again with the next daemon |
|
|
536
|
+
| Reboot | Starts again when the daemon starts, at sign-in with `pinggy daemon service-install` |
|
|
537
|
+
| `pinggy device stop` | Stops. Starts again with the next daemon |
|
|
538
|
+
| `pinggy device remove` | Stops, and the daemon never starts it again |
|
|
539
|
+
| A terminal outcome | Stops, with `lastError`, and stays stopped until the next `connect` or `login` |
|
|
527
540
|
|
|
528
541
|
**Inside the Pinggy app** `node-pty` resolves inside `app.asar`, where `spawn-helper` is not on real disk, and a spawn without its helper kills the process. `resolveNodePtyRoot()` copies the package out of an `.asar` archive the way it does out of a `pkg` snapshot, and `loadNodePty()` offers a terminal only when `hasExecutableSpawnHelper()` holds.
|
|
529
542
|
|
|
@@ -747,7 +760,7 @@ Retry sleeps an exponential backoff with full jitter: 1 s doubling to a 60 s cap
|
|
|
747
760
|
|
|
748
761
|
**Written 0600, then chmodded again on every rewrite**, because `writeFileSync` applies `mode` only when it creates the file. This diverges from `configStore.ts`, which writes tunnel tokens at 0644 under a normal umask. Do not copy that pattern into anything new.
|
|
749
762
|
|
|
750
|
-
`pinggy device remove` deletes this file and
|
|
763
|
+
`pinggy device remove` deletes this file and `device-agent.json`, after it stops a background agent and a `--foreground` agent in another terminal. Revoking the device server-side is a dashboard action, because a machine that has lost its credential cannot authenticate the delete.
|
|
751
764
|
|
|
752
765
|
### Composition with other subcommands
|
|
753
766
|
|
|
@@ -760,6 +773,7 @@ Retry sleeps an exponential backoff with full jitter: 1 s doubling to a 60 s cap
|
|
|
760
773
|
| `device connect -l 3000 -b --all --remote-management KEY` | Runs the agent in the daemon, the default, and ignores the other 3. Only `values.token`, `values.manage`, `values.b` and `values.foreground` are read. No tunnel and no remote management | `handleDevice` reads 4 fields off `values` |
|
|
761
774
|
| `device connect -b --foreground` | `-b and --foreground contradict each other`, exit 1. Nothing runs | `handleDevice`, before the verb switch |
|
|
762
775
|
| `device connect --foreground`, `device login --foreground` while the daemon runs an agent | Refused, exit 1: "This machine already runs as device <id> in the background. Stop it first: pinggy device stop" | `foregroundRefusal()` in `backgroundAgent.ts` |
|
|
776
|
+
| `device connect`, `device login`, with or without `--foreground`, while another terminal runs a `--foreground` agent | Refused, exit 1: "This machine already runs as a device in another terminal (PID <pid>). Press Ctrl+C in that terminal first." | `foregroundAgentRefusal()` in `foregroundAgent.ts` |
|
|
763
777
|
| `device stop` with no background agent | "No device agent is running in the background.", exit 0. Never starts a daemon | `stopAgentInBackground()` |
|
|
764
778
|
| `device connect --typo` | `Fatal Error: Unknown option '--typo'`, exit 1, before dispatch | `main()` parses the full argv with `parseArgs` in strict mode, then calls `isSubcommand` |
|
|
765
779
|
| `device connect --help` | Ignores `--help` and connects. Only `device` and `device --help` reach `printDeviceHelp()` | The verb switch tests `--help` in its `default` arm only |
|
|
@@ -782,9 +796,9 @@ With `--foreground` the agent shares no state with the daemon or with tunnels, w
|
|
|
782
796
|
- Ctrl+C on the agent touches no tunnel. There is no `SessionTracker` entry, no grace timer, and no origin tag.
|
|
783
797
|
- The agent logs through `CLIPrinter` and the CLI logger, not the daemon log. Nothing about it reaches `daemon.log` or the per-tunnel logs.
|
|
784
798
|
|
|
785
|
-
Without `--foreground` the daemon owns the agent: `ensureDaemonRunning()` may start a daemon, `pinggy daemon stop` stops the agent too and says so, the agent logs to `daemon.log`, and `daemon-
|
|
799
|
+
Without `--foreground` the daemon owns the agent: `ensureDaemonRunning()` may start a daemon, `pinggy daemon stop` stops the agent too and says so, the agent logs to `daemon.log`, and `daemon-config.json` saves it, so the next daemon start runs it again. It still has no `SessionTracker` entry and no origin tag of its own.
|
|
786
800
|
|
|
787
|
-
1 identity per config dir, last write wins: a run keeps what `device.json` holds while the token matches, sets the server, and rewrites the file on every `welcome`.
|
|
801
|
+
1 identity per config dir, last write wins: a run keeps what `device.json` holds while the token matches, sets the server, and rewrites the file on every `welcome`. `device remove` stops a foreground agent through its record first, so the file stays deleted. 2 agents sharing 1 credential lose the race by design: the dashboard refuses the second with `already_connected`, and it retries on the backoff until the first socket drops. The daemon's run rewrites the file only while it holds its own token (`writeIdentityWhileOwned()`).
|
|
788
802
|
|
|
789
803
|
### Not built yet
|
|
790
804
|
|
|
@@ -891,7 +905,8 @@ No em-dashes. Short phrases. Present tense. See `CLAUDE.md` § "English Style" b
|
|
|
891
905
|
└──────────────────────────────────┘
|
|
892
906
|
│ next pinggy command
|
|
893
907
|
▼
|
|
894
|
-
getDaemonInfo() returns null (PID dead
|
|
908
|
+
getDaemonInfo() returns null (PID dead, or ──▶ unlinks daemon.json
|
|
909
|
+
started before the last boot)
|
|
895
910
|
│
|
|
896
911
|
▼
|
|
897
912
|
startDaemon() spawns new child
|
package/CLAUDE.md
CHANGED
|
@@ -44,15 +44,18 @@ CLI code calls `TunnelClient` (`src/daemon/tunnelClient.ts`), the public facade
|
|
|
44
44
|
|
|
45
45
|
### Daemon discovery and lifecycle
|
|
46
46
|
|
|
47
|
-
`getDaemonInfo()` in `src/daemon/daemonManager.ts` reads `daemon.json`, validates the PID with `process.kill(pid, 0)`, deletes the file if stale, and returns `null` if no live daemon is found. `startDaemon()` spawns a detached daemon child and polls `daemon.json` for up to 8s.
|
|
47
|
+
`getDaemonInfo()` in `src/daemon/daemonManager.ts` reads `daemon.json`, validates the PID with `process.kill(pid, 0)`, deletes the file if stale (dead PID, or `startedAt` before the last boot), and returns `null` if no live daemon is found. `startDaemon()` spawns a detached daemon child and polls `daemon.json` for up to 8s.
|
|
48
48
|
|
|
49
49
|
Single daemon per user. State lives under `~/.config/pinggy/` on Linux/macOS or `%APPDATA%/pinggy/` on Windows (helper: `src/utils/configDir.ts`):
|
|
50
50
|
|
|
51
51
|
- `daemon.json`: `{pid, port, startedAt, host, ipcVersion}`. `ipcVersion` is `IPC_VERSION` from `src/daemon/ipc/ipcRoutes.ts`. `ensureDaemonRunning()` refuses a live daemon whose version differs and tells the user to run `pinggy daemon stop`. Bump `IPC_VERSION` on any incompatible IPC or WebSocket change.
|
|
52
|
-
- `daemon
|
|
52
|
+
- `daemon.lock`: `{pid, started_at}` of the running daemon (`src/daemon/lifecycle/daemonLock.ts`). Each daemon takes it before it opens its IPC port, and a daemon that finds a live holder exits 0. systemd and launchd run `--_daemon-child` directly, and 2 CLIs can spawn at once, so the CLI's `daemon.json` check alone does not keep 1 daemon.
|
|
53
|
+
- `daemon-state.json`: detached tunnel configs, for crash recovery (`src/daemon/lifecycle/stateStore.ts`). Deleted on clean shutdown; replayed on next start.
|
|
54
|
+
- `daemon-config.json`: settings that survive a clean shutdown (`src/daemon/lifecycle/daemonConfig.ts`): the log level, and `deviceAgent`, set while the background device agent should run. Every daemon start runs that agent. `pinggy device remove` deletes it. `pinggy device stop` keeps it, so the agent starts again with the next daemon.
|
|
53
55
|
- `daemon.log`: SDK + daemon logs. CLI logs stay separate.
|
|
54
56
|
- `tunnels/<name>_<configId>.json`: saved tunnel configs from `pinggy config save`.
|
|
55
57
|
- `device.json`: device agent id and token from `pinggy device connect` (`src/devices/deviceIdentity.ts`). Written 0600, unlike the tunnel configs beside it.
|
|
58
|
+
- `device-agent.json`: `{pid, started_at}` of a device agent started with `--foreground`, while it runs (`src/devices/foregroundAgent.ts`). `pinggy device remove` deletes it, and the agent stops within 1 s. No credential.
|
|
56
59
|
|
|
57
60
|
### Foreground vs detached tunnels
|
|
58
61
|
|
|
@@ -75,7 +78,7 @@ It owns no tunnel. Since slice 09 it reads the daemon's `GET /tunnels` through `
|
|
|
75
78
|
|
|
76
79
|
1 invocation runs 1 subcommand: `isSubcommand()` reads `rawArgs[0]` only, so `pinggy device connect start my-tunnel` runs the agent and drops the rest, and tunnel flags on a `device` line parse and are ignored, except `-b` and `--foreground`.
|
|
77
80
|
|
|
78
|
-
Since slice 14, `scripts/install/install.sh` and `install.ps1` install or update the binary, put it on PATH, and run `pinggy device login -b`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. Since slice 16, `DEVICE_AGENT_TOKEN` on either script updates without asking and runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit.
|
|
81
|
+
Since slice 14, `scripts/install/install.sh` and `install.ps1` install or update the binary, put it on PATH, then ask "Connect this device to Pinggy? [Y/n]" and run `pinggy device login -b` unless the answer starts with `n`. `-b` is the default, and the scripts pass it so an older binary the user kept also runs the agent in its daemon. pinggy.io serves copies that `website-cli-download-links-pr.yml` writes at each release tag. Renaming a release asset, changing the `Pinggy CLI version:` line, or changing `device login`'s `--manage` or `-b` flag means changing both scripts in the same commit. Since slice 16, `DEVICE_AGENT_TOKEN` on either script updates without asking and runs `pinggy device connect -b` instead, with the token in the environment, never on a command line. `handleDevice()` deletes the variable from `process.env` before any verb runs, so no shell or daemon the agent starts inherits it. Renaming the variable or `connect`'s `--manage` or `-b` flag also changes both scripts in the same commit. `pinggy daemon service-install` runs only from the path the scripts install to (`installerBinaryPath()` in `src/daemon/lifecycle/serviceInstaller.ts`), so changing either script's install directory changes that function in the same commit. Once the device connects, both scripts offer `pinggy daemon service-install` unless the service exists. They look for the task name, plist or unit file that `serviceInstaller.ts` writes, and the installed binary's path in it, so renaming any of them changes both scripts in the same commit.
|
|
79
82
|
|
|
80
83
|
Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome table, the `device.json` rules, and the full composition table. The design docs are in the `pinggy_backend` repo under `docs/pinggy-devices/`; read `cli.md` and `api-websocket.md` there before changing anything in `src/devices/`.
|
|
81
84
|
|
|
@@ -90,8 +93,8 @@ Section 17 of `ARCHITECTURE.md` has the protocol, the retry and terminal outcome
|
|
|
90
93
|
| `pinggy stop <name\|id>` | Stop running tunnel(s) by name or ID prefix |
|
|
91
94
|
| `pinggy ps` | Table of running tunnels (ID, name, status, local, URL) |
|
|
92
95
|
| `pinggy attach <name\|id>` | Re-attach TUI to a running tunnel |
|
|
93
|
-
| `pinggy daemon start \| stop \| status \| install
|
|
94
|
-
| `pinggy device login \| connect [--foreground] \| stop \| status \| remove` | Sign this machine in by email, or enrol it with a token, as a Pinggy device; the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; show the enrolment and the background agent; forget the credential |
|
|
96
|
+
| `pinggy daemon start \| stop \| status \| service-install \| service-uninstall` (alias `d`) | Daemon lifecycle and system-service installation |
|
|
97
|
+
| `pinggy device login \| connect [--foreground] \| stop \| status \| remove [-f]` | Sign this machine in by email, or enrol it with a token, as a Pinggy device; the agent runs in the daemon, or in this terminal with `--foreground`, and `stop` stops the daemon's; show the enrolment and the background agent; show the device and its connection, ask, then stop every agent and forget the credential (`-f` skips the question) |
|
|
95
98
|
|
|
96
99
|
## Build System
|
|
97
100
|
|
package/README.md
CHANGED
|
@@ -275,7 +275,7 @@ Prints the device id, server, masked token, and enrolment time from the local fi
|
|
|
275
275
|
pinggy device remove
|
|
276
276
|
```
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
Prints the device id and whether the device is connected now, in the background or with `--foreground` in another terminal, then asks "Remove this device from this machine? [y/N]". Only `y` removes it: the command stops the device agent, then deletes the local credential. With no terminal, it refuses unless you add `-f`, which removes without asking. The device still exists in the dashboard. Delete it there to revoke it, because a machine that has lost its credential cannot authenticate the delete.
|
|
279
279
|
|
|
280
280
|
### Reconnect and stop conditions
|
|
281
281
|
|
|
@@ -314,11 +314,11 @@ It enrols, learns its device id and heartbeat interval from the dashboard, and s
|
|
|
314
314
|
|
|
315
315
|
### Devices, tunnels, and the daemon
|
|
316
316
|
|
|
317
|
-
- By default the daemon runs the agent. `pinggy device connect` and `login` start a daemon when none runs. `pinggy daemon stop` stops the agent with every tunnel, and so does a reboot. `pinggy device connect` starts it again.
|
|
317
|
+
- By default the daemon runs the agent. `pinggy device connect` and `login` start a daemon when none runs. `pinggy daemon stop` stops the agent with every tunnel, and so does a reboot. Every daemon start runs it again, until `pinggy device remove`. `pinggy device stop` stops it until the daemon starts again. With `pinggy daemon service-install`, the daemon starts at sign-in, so the device comes back online after a reboot. `pinggy device connect` starts it again after a stop.
|
|
318
318
|
- With `--foreground` the agent is its own process. It never starts the daemon, `pinggy daemon stop` leaves it running, and Ctrl+C on it leaves every tunnel running.
|
|
319
319
|
- 1 enrolment per machine. The newest successful connect overwrites `device.json`, and a `--token` on the command line beats the stored one.
|
|
320
|
-
- 1 agent per machine. `--foreground` is refused while the daemon runs an agent. Stop
|
|
321
|
-
- `pinggy device remove` stops
|
|
320
|
+
- 1 agent per machine. `connect` and `login` refuse while another terminal runs a `--foreground` agent. `--foreground` is refused while the daemon runs an agent. Stop that one first with `pinggy device stop`.
|
|
321
|
+
- `pinggy device remove` stops a running agent, in the background or with `--foreground` in another terminal, before it deletes the credential file.
|
|
322
322
|
|
|
323
323
|
|
|
324
324
|
## Usage
|
|
@@ -498,7 +498,7 @@ Config dir varies by OS:
|
|
|
498
498
|
- Linux/macOS: `~/.config/pinggy/`
|
|
499
499
|
- Windows: `%APPDATA%\pinggy\`
|
|
500
500
|
|
|
501
|
-
It holds `daemon.json` (discovery), `daemon-config.json` (persisted settings), `daemon-state.json` (crash recovery), `tunnels/` (saved configs),
|
|
501
|
+
It holds `daemon.json` (discovery), `daemon-config.json` (persisted settings), `daemon-state.json` (crash recovery), `tunnels/` (saved configs), `device.json` (the Pinggy Devices credential, written `0600`), and `device-agent.json` (the PID of a device agent running in a terminal).
|
|
502
502
|
|
|
503
503
|
Log dir varies by OS:
|
|
504
504
|
- Linux: `~/.local/state/pinggy-cli/logs/` (honors `$XDG_STATE_HOME`)
|
|
@@ -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();
|
|
@@ -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;
|