pinggy 0.6.8 → 0.6.9

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 CHANGED
@@ -52,6 +52,8 @@ Logs live under `getPinggyLogDir()`:
52
52
  <logDir>/
53
53
  ├── daemon.log Daemon process log (rolled)
54
54
  ├── update.log The last background update, overwritten each run
55
+ ├── libpinggy/
56
+ │ └── libpinggy.log libpinggy's lines for every tunnel (rolled at daemon start)
55
57
  └── tunnels/
56
58
  └── <origin>__<name>__<tunnelId>.log Per-tunnel logs (rolled 10MB×3)
57
59
  ```
@@ -454,15 +456,18 @@ This is how a shared daemon distinguishes tunnels from different clients on disk
454
456
 
455
457
  ## 14. Logging architecture
456
458
 
457
- Three log artifacts:
459
+ Four log artifacts:
458
460
 
459
461
  | Log | Writer | Path | Lifetime |
460
462
  | --------------- | ------------------------------------- | ----------------------------------------------------- | ----------------------------- |
461
463
  | Application log | Electron host via `electron-log` | `<userData>/logs/` | Persistent, rolled |
462
464
  | Daemon log | winston root inside daemon | `<logDir>/daemon.log` | Persistent, rolled |
463
- | Tunnel log | winston `File` transport per tunnel | `<logDir>/tunnels/<origin>__<name>__<tunnelId>.log` | While tunnel runs (10MB × 3) |
465
+ | Tunnel log | winston `File` transport per tunnel, plus the SDK worker's own lines | `<logDir>/tunnels/<origin>__<name>__<tunnelId>.log` | While tunnel runs (10MB × 3) |
466
+ | libpinggy log | libpinggy, for every tunnel | `<logDir>/libpinggy/libpinggy.log` | Persistent, rolled at daemon start |
464
467
 
465
- Toggle: `setTunnelLoggingEnabled(false)` detaches every per-tunnel transport immediately. Tunnels keep running; nothing else changes. Re-enabling does not retroactively re-attach to running tunnels (transports are recreated on next tunnel start).
468
+ libpinggy has one log file per process, not per tunnel, and whoever sets its path last gets the lines of every tunnel. So `setNativeLogging()` in `src/logger/nativeLog.ts` sets the path once, from the main thread, the first time logging is on, and tunnels are created with `libpinggyLogPath: null`. libpinggy keeps the file open, so it rotates only before that first open. libpinggy has no log level at runtime, only on or off; a release build writes DEBUG and above. `pinggy logs libpinggy` and `pinggy log path libpinggy` reach the file: `logLookup.ts` answers with it when no tunnel or saved config has that name, without asking the daemon.
469
+
470
+ Toggle: `POST /config/tunnel-logging` covers all per-tunnel output. Off detaches every per-tunnel transport, turns libpinggy logging off, and tells each running worker to stop writing; tunnels keep running. On turns libpinggy and the running workers back on at once, but does not re-attach the winston transport to running tunnels (it is recreated on the next tunnel start). A daemon starts with the toggle on.
466
471
 
467
472
  CLI logs (the short-lived foreground process) go to stdout by default. The daemon log captures everything inside the long-running process.
468
473
 
package/README.md CHANGED
@@ -477,7 +477,7 @@ pinggy -p 3000 --logfile ~/.pinggy/pinggy.log --loglevel INFO --v
477
477
  If you pass `--v`, `--vv`, or `--vvv` without a log level, the default is INFO. If a logfile path is provided, the log directory is created if it does not exist.
478
478
 
479
479
  ### Daemon and per-tunnel log files
480
- The daemon writes its own log file and a separate log per tunnel under the platform log directory (see [State and file locations](#state-and-file-locations)).
480
+ The daemon writes its own log file and a separate log per tunnel under the platform log directory (see [State and file locations](#state-and-file-locations)). The native tunnel library logs to `libpinggy/libpinggy.log` in the same directory: one file for all tunnels.
481
481
 
482
482
  #### Tail the daemon log
483
483
  ```bash
@@ -491,10 +491,18 @@ pinggy logs my-tunnel # last 100 lines of that tunnel's log
491
491
  pinggy logs my-tunnel -f # follow new lines (survives log rotation)
492
492
  ```
493
493
 
494
+ #### Tail the native library log
495
+ ```bash
496
+ pinggy logs libpinggy # last 100 lines of libpinggy.log
497
+ pinggy logs libpinggy -f # follow new lines
498
+ ```
499
+ The file holds the library's lines for every tunnel. A tunnel or saved config named `libpinggy` keeps the name for its own log.
500
+
494
501
  #### Print the log file path
495
502
  ```bash
496
503
  pinggy log path # daemon log path
497
504
  pinggy log path my-tunnel # path to a specific tunnel's log
505
+ pinggy log path libpinggy # path to the native library's log
498
506
  ```
499
507
 
500
508
  #### Get or set the daemon log level
@@ -2,11 +2,11 @@ import {
2
2
  TunnelAlreadyRunningError,
3
3
  TunnelManager,
4
4
  TunnelRebuildInProgressError
5
- } from "./chunk-3WMTTJHI.js";
5
+ } from "./chunk-5HBGVJSW.js";
6
6
  import "./chunk-UB26QJ4T.js";
7
7
  import "./chunk-HTIWY3O5.js";
8
- import "./chunk-LWCVB42S.js";
9
- import "./chunk-MAK5R4WQ.js";
8
+ import "./chunk-DGAH7UVX.js";
9
+ import "./chunk-WFHMERT3.js";
10
10
  export {
11
11
  TunnelAlreadyRunningError,
12
12
  TunnelManager,
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-XZ64ZAGO.js";
4
4
  import {
5
5
  TunnelManager
6
- } from "./chunk-3WMTTJHI.js";
6
+ } from "./chunk-5HBGVJSW.js";
7
7
  import "./chunk-UB26QJ4T.js";
8
8
  import "./chunk-HTIWY3O5.js";
9
9
  import {
10
10
  logger
11
- } from "./chunk-LWCVB42S.js";
12
- import "./chunk-MAK5R4WQ.js";
11
+ } from "./chunk-DGAH7UVX.js";
12
+ import "./chunk-WFHMERT3.js";
13
13
 
14
14
  // src/tui/blessed/TunnelTui.ts
15
15
  import blessed3 from "blessed";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-LWCVB42S.js";
3
+ } from "./chunk-DGAH7UVX.js";
4
4
  import {
5
5
  ensureTunnelConfigDir,
6
6
  getTunnelConfigDir
7
- } from "./chunk-MAK5R4WQ.js";
7
+ } from "./chunk-WFHMERT3.js";
8
8
 
9
9
  // src/cli/configStore.ts
10
10
  import fs from "fs";
@@ -9,10 +9,12 @@ import {
9
9
  import {
10
10
  getLogLevel,
11
11
  logger
12
- } from "./chunk-LWCVB42S.js";
12
+ } from "./chunk-DGAH7UVX.js";
13
13
  import {
14
+ ensureLibpinggyLogDir,
15
+ getLibpinggyLogPath,
14
16
  getTunnelLogPath
15
- } from "./chunk-MAK5R4WQ.js";
17
+ } from "./chunk-WFHMERT3.js";
16
18
 
17
19
  // src/tunnel_manager/TunnelManager.ts
18
20
  import { TunnelInstance, LogLevel as SdkLogLevel } from "@pinggy/pinggy";
@@ -71,6 +73,9 @@ function detachAllTunnelLoggers() {
71
73
  }
72
74
  }
73
75
 
76
+ // src/logger/nativeLog.ts
77
+ import { Pinggy } from "@pinggy/pinggy";
78
+
74
79
  // src/logger/rotateLog.ts
75
80
  import fs2 from "fs";
76
81
  var DEFAULT_MAX_BYTES = 10 * 1024 * 1024;
@@ -99,6 +104,34 @@ function maybeRotate(file, maxBytes = DEFAULT_MAX_BYTES, maxArchives = DEFAULT_M
99
104
  }
100
105
  }
101
106
 
107
+ // src/logger/nativeLog.ts
108
+ var pathSet = false;
109
+ var warned = false;
110
+ function sdkAddon() {
111
+ return Pinggy.addon;
112
+ }
113
+ function setNativeLogging(enabled, addon = sdkAddon()) {
114
+ if (!addon) {
115
+ if (!warned) {
116
+ warned = true;
117
+ logger.warn("libpinggy logging unavailable: the SDK does not expose its native addon");
118
+ }
119
+ return;
120
+ }
121
+ try {
122
+ if (enabled && !pathSet) {
123
+ ensureLibpinggyLogDir();
124
+ const logPath = getLibpinggyLogPath();
125
+ maybeRotate(logPath);
126
+ addon.setLogPath(logPath);
127
+ pathSet = true;
128
+ }
129
+ addon.setLogEnable(enabled);
130
+ } catch (err) {
131
+ logger.error("Failed to configure libpinggy logging", { error: err instanceof Error ? err.message : String(err) });
132
+ }
133
+ }
134
+
102
135
  // src/tunnel_manager/TunnelManager.ts
103
136
  import path2 from "path";
104
137
  import { Worker } from "worker_threads";
@@ -198,14 +231,16 @@ var TunnelManager = class _TunnelManager {
198
231
  const tunnelLogPath = getTunnelLogPath(params.tunnelid, params.origin, tunnelLogName);
199
232
  maybeRotate(tunnelLogPath);
200
233
  attachTunnelLogger(params.tunnelid, params.origin, tunnelLogName);
234
+ const loggingEnabled = isTunnelLoggingEnabled();
235
+ setNativeLogging(loggingEnabled);
201
236
  let instance;
202
237
  try {
203
238
  logger.debug("Creating tunnel instance with processed config", tunnelConfig);
204
239
  instance = await TunnelInstance.create(tunnelConfig, {
205
- enabled: true,
240
+ enabled: loggingEnabled,
206
241
  logLevel: mapToSdkLogLevel(getLogLevel()),
207
242
  logFilePath: tunnelLogPath,
208
- libpinggyLogPath: tunnelLogPath
243
+ libpinggyLogPath: null
209
244
  });
210
245
  } catch (e) {
211
246
  logger.error("Error creating tunnel instance:", e);
@@ -398,17 +433,17 @@ var TunnelManager = class _TunnelManager {
398
433
  }
399
434
  }
400
435
  /**
401
- * Re-apply the given log level to every live tunnel's worker JS logger.
402
- * Native libpinggy level is fixed at worker init and cannot be re-pathed
403
- * or re-levelled at runtime without restarting the tunnel.
436
+ * Re-apply the given log level, and the tunnel-logging switch, to every live tunnel's worker
437
+ * JS logger. libpinggy has no log level at runtime, only on or off (see nativeLog.ts).
404
438
  */
405
439
  applyLogLevelToActiveTunnels(level) {
406
440
  const sdkLevel = mapToSdkLogLevel(level);
441
+ const loggingEnabled = isTunnelLoggingEnabled();
407
442
  for (const tunnel of this.tunnelsByTunnelId.values()) {
408
443
  if (tunnel.isStopped) continue;
409
444
  if (tunnel.lastError?.isFatal) continue;
410
445
  const logPath = getTunnelLogPath(tunnel.tunnelid, tunnel.origin, tunnel.tunnelName || tunnel.tunnelConfig?.name);
411
- tunnel.instance.setDebugLogging(true, sdkLevel, logPath).catch((err) => {
446
+ tunnel.instance.setDebugLogging(loggingEnabled, sdkLevel, logPath).catch((err) => {
412
447
  logger.error("Failed to apply log level to tunnel", { tunnelId: tunnel.tunnelid, error: err?.message ?? err });
413
448
  });
414
449
  }
@@ -1637,6 +1672,7 @@ export {
1637
1672
  setTunnelLoggingEnabled,
1638
1673
  isTunnelLoggingEnabled,
1639
1674
  detachAllTunnelLoggers,
1675
+ setNativeLogging,
1640
1676
  TunnelAlreadyRunningError,
1641
1677
  TunnelRebuildInProgressError,
1642
1678
  TunnelManager
@@ -14,9 +14,9 @@ function setLogLevel(level) {
14
14
  if (_sdkLogFilePath) {
15
15
  enableLoggingByLogLevelInSdk(level, _sdkLogFilePath);
16
16
  }
17
- import("./daemonConfig-VWK4TXVS.js").then(({ writeDaemonConfig }) => writeDaemonConfig({ logLevel: level })).catch(() => {
17
+ import("./daemonConfig-R34QH73H.js").then(({ writeDaemonConfig }) => writeDaemonConfig({ logLevel: level })).catch(() => {
18
18
  });
19
- import("./TunnelManager-JRVEADS4.js").then(({ TunnelManager }) => TunnelManager.getInstance().applyLogLevelToActiveTunnels(level)).catch(() => {
19
+ import("./TunnelManager-CDQGC6ZU.js").then(({ TunnelManager }) => TunnelManager.getInstance().applyLogLevelToActiveTunnels(level)).catch(() => {
20
20
  });
21
21
  }
22
22
  var _logger = null;
@@ -7,17 +7,17 @@ import {
7
7
  readUpdateState,
8
8
  unixLayoutPaths,
9
9
  writeUpdateState
10
- } from "./chunk-FBKAYNFS.js";
10
+ } from "./chunk-OQVFQ5VG.js";
11
11
  import {
12
12
  errorMessage
13
13
  } from "./chunk-HTIWY3O5.js";
14
14
  import {
15
15
  logger
16
- } from "./chunk-LWCVB42S.js";
16
+ } from "./chunk-DGAH7UVX.js";
17
17
  import {
18
18
  ensurePinggyConfigDir,
19
19
  getUpdateLockPath
20
- } from "./chunk-MAK5R4WQ.js";
20
+ } from "./chunk-WFHMERT3.js";
21
21
 
22
22
  // src/update/latestRelease.ts
23
23
  import http from "http";
@@ -5,14 +5,14 @@ import {
5
5
  buildRemoteManagementWsUrl,
6
6
  initiateRemoteManagement,
7
7
  startRemoteManagement
8
- } from "./chunk-NO6NLGYZ.js";
8
+ } from "./chunk-Q5RYSWFK.js";
9
9
  import {
10
10
  configuredLogLevel,
11
11
  forgetDeviceAgent,
12
12
  saveDeviceAgent,
13
13
  savedDeviceAgent,
14
14
  writeDaemonConfig
15
- } from "./chunk-CZOKR73F.js";
15
+ } from "./chunk-VD5ZFCZW.js";
16
16
  import {
17
17
  HTTP_NOT_FOUND,
18
18
  IPCClient,
@@ -36,7 +36,7 @@ import {
36
36
  upsertConfig,
37
37
  validateName,
38
38
  validateNameStrict
39
- } from "./chunk-2GIJXE4K.js";
39
+ } from "./chunk-3IPMFCEF.js";
40
40
  import {
41
41
  createQrCodes
42
42
  } from "./chunk-XZ64ZAGO.js";
@@ -44,8 +44,9 @@ import {
44
44
  TunnelManager,
45
45
  detachAllTunnelLoggers,
46
46
  isTunnelLoggingEnabled,
47
+ setNativeLogging,
47
48
  setTunnelLoggingEnabled
48
- } from "./chunk-3WMTTJHI.js";
49
+ } from "./chunk-5HBGVJSW.js";
49
50
  import {
50
51
  UpdateError,
51
52
  acquireUpdateLock,
@@ -68,7 +69,7 @@ import {
68
69
  runPinggyBinary,
69
70
  versionFromTag,
70
71
  windowsInstallPaths
71
- } from "./chunk-LX5LDLLH.js";
72
+ } from "./chunk-HJECJ7LC.js";
72
73
  import {
73
74
  InstallKind,
74
75
  NPM_INSTALL_COMMAND,
@@ -103,7 +104,7 @@ import {
103
104
  uninstallService,
104
105
  unixLayoutPaths,
105
106
  writeUpdateState
106
- } from "./chunk-FBKAYNFS.js";
107
+ } from "./chunk-OQVFQ5VG.js";
107
108
  import {
108
109
  DaemonHost,
109
110
  DeviceAgentState,
@@ -130,7 +131,7 @@ import {
130
131
  getLogLevel,
131
132
  logger,
132
133
  setLogLevel
133
- } from "./chunk-LWCVB42S.js";
134
+ } from "./chunk-DGAH7UVX.js";
134
135
  import {
135
136
  ensurePinggyConfigDir,
136
137
  ensurePinggyLogDir,
@@ -139,10 +140,11 @@ import {
139
140
  getDaemonLogPath,
140
141
  getDeviceConfigPath,
141
142
  getForegroundAgentPath,
143
+ getLibpinggyLogPath,
142
144
  getPinggyConfigDir,
143
145
  getTunnelLogDir,
144
146
  getTunnelLogPath
145
- } from "./chunk-MAK5R4WQ.js";
147
+ } from "./chunk-WFHMERT3.js";
146
148
 
147
149
  // src/cli/options.ts
148
150
  var cliOptions = {
@@ -263,6 +265,7 @@ function printHelpMessage() {
263
265
  console.log(" pinggy attach <name|id> # Re-attach TUI to a running tunnel");
264
266
  console.log(" pinggy restart <name|id> # Restart a running tunnel (picks up latest log level)");
265
267
  console.log(" pinggy logs [-f] [<name|id>] # Show (or follow) tunnel or daemon logs");
268
+ console.log(" pinggy logs [-f] libpinggy # Show (or follow) the native library log, shared by all tunnels");
266
269
  console.log(" pinggy log level [debug|info|error] # Get or set the log level");
267
270
  console.log(" pinggy log path [<name|id>] # Print log file path");
268
271
  console.log("\nBackground Mode:");
@@ -1839,7 +1842,7 @@ async function connectTui(opts) {
1839
1842
  const exitMessage = opts.exitMessage || "Stopping tunnel...";
1840
1843
  if (!noTui && process.stdin.isTTY) {
1841
1844
  try {
1842
- const { TunnelTui } = await import("./TunnelTui-6H4NPUNF.js");
1845
+ const { TunnelTui } = await import("./TunnelTui-M5SIZX6B.js");
1843
1846
  const tui = new TunnelTui({
1844
1847
  urls,
1845
1848
  greet,
@@ -2062,7 +2065,7 @@ async function startBackgroundTunnels(configs, values, positionals) {
2062
2065
  client.close();
2063
2066
  }
2064
2067
  async function startAutoStartTunnels() {
2065
- const { getAutoStartConfigs: getAutoStartConfigs2 } = await import("./configStore-JJUWT2YO.js");
2068
+ const { getAutoStartConfigs: getAutoStartConfigs2 } = await import("./configStore-6LCHFPQX.js");
2066
2069
  const configs = getAutoStartConfigs2();
2067
2070
  if (configs.length === 0) {
2068
2071
  printer_default.warn("No configs marked for auto-start. Use: pinggy config auto <name>");
@@ -2206,7 +2209,8 @@ function printLogHelp() {
2206
2209
  console.log(" level Print current log level");
2207
2210
  console.log(" level debug|info|error Set log level");
2208
2211
  console.log(" path Print daemon log path");
2209
- console.log(" path <name|id> Print tunnel log path\n");
2212
+ console.log(" path <name|id> Print tunnel log path");
2213
+ console.log(" path libpinggy Print the native library's log path (one file for all tunnels)\n");
2210
2214
  }
2211
2215
  function printConfigHelp() {
2212
2216
  console.log("\nUsage: pinggy config <command> [name] [options]\n");
@@ -5809,18 +5813,25 @@ function resolveStoppedLogPath(q) {
5809
5813
  }
5810
5814
 
5811
5815
  // src/cli/subcommand/handlers/logLookup.ts
5816
+ var LIBPINGGY_LOG_NAME = "libpinggy";
5817
+ function orLibpinggyLog(nameOrId, result) {
5818
+ if (nameOrId === LIBPINGGY_LOG_NAME && result.status === "not-found") {
5819
+ return { status: "libpinggy", path: getLibpinggyLogPath() };
5820
+ }
5821
+ return result;
5822
+ }
5812
5823
  function openLogLookup() {
5813
5824
  const client = new TunnelClient();
5814
5825
  if (!client.connectIfRunning()) {
5815
5826
  return {
5816
5827
  daemonLogPath: () => Promise.resolve(getDaemonLogPath()),
5817
- resolve: (nameOrId) => Promise.resolve(resolveStoppedLogPath(nameOrId)),
5828
+ resolve: (nameOrId) => Promise.resolve(orLibpinggyLog(nameOrId, resolveStoppedLogPath(nameOrId))),
5818
5829
  close: () => void 0
5819
5830
  };
5820
5831
  }
5821
5832
  return {
5822
5833
  daemonLogPath: async () => (await client.getLogPaths()).daemon,
5823
- resolve: (nameOrId) => client.resolveLogPath(nameOrId),
5834
+ resolve: async (nameOrId) => orLibpinggyLog(nameOrId, await client.resolveLogPath(nameOrId)),
5824
5835
  close: () => client.close()
5825
5836
  };
5826
5837
  }
@@ -5991,6 +6002,7 @@ async function handleLogPath(args) {
5991
6002
  switch (result.status) {
5992
6003
  case "running":
5993
6004
  case "historical":
6005
+ case "libpinggy":
5994
6006
  printer_default.print(result.path);
5995
6007
  break;
5996
6008
  case "config-only":
@@ -6946,6 +6958,8 @@ var IPCServer = class {
6946
6958
  [Route.SetTunnelLogging]: (req) => {
6947
6959
  if (typeof req.enabled !== "boolean") throw new Error("Missing 'enabled' boolean");
6948
6960
  setTunnelLoggingEnabled(req.enabled);
6961
+ setNativeLogging(req.enabled);
6962
+ TunnelManager.getInstance().applyLogLevelToActiveTunnels(getLogLevel());
6949
6963
  return { enabled: isTunnelLoggingEnabled() };
6950
6964
  },
6951
6965
  [Route.GetLogPaths]: async () => {
@@ -7961,7 +7975,7 @@ async function main() {
7961
7975
  const { values, positionals, hasAnyArgs } = parseCliArgs(cliOptions);
7962
7976
  configureLogger(values);
7963
7977
  if (values["_daemon-child"]) {
7964
- const { runDaemonChild: runDaemonChild2 } = await import("./daemonChild-NWLM422N.js");
7978
+ const { runDaemonChild: runDaemonChild2 } = await import("./daemonChild-WTZ7X6SZ.js");
7965
7979
  await runDaemonChild2();
7966
7980
  return;
7967
7981
  }
@@ -7970,7 +7984,7 @@ async function main() {
7970
7984
  return;
7971
7985
  }
7972
7986
  if (values["_update-child"]) {
7973
- const { runUpdateChild } = await import("./updateChild-66NKH5Y4.js");
7987
+ const { runUpdateChild } = await import("./updateChild-BPWBQ3WR.js");
7974
7988
  await runUpdateChild();
7975
7989
  process.exit(0);
7976
7990
  }
@@ -11,14 +11,14 @@ import {
11
11
  } from "./chunk-HTIWY3O5.js";
12
12
  import {
13
13
  logger
14
- } from "./chunk-LWCVB42S.js";
14
+ } from "./chunk-DGAH7UVX.js";
15
15
  import {
16
16
  ensurePinggyConfigDir,
17
17
  getDaemonInfoPath,
18
18
  getDaemonLogPath,
19
19
  getPinggyConfigDir,
20
20
  getUpdateStatePath
21
- } from "./chunk-MAK5R4WQ.js";
21
+ } from "./chunk-WFHMERT3.js";
22
22
 
23
23
  // src/update/updateState.ts
24
24
  import fs from "fs";
@@ -895,7 +895,7 @@ async function ensureDaemonRunning() {
895
895
  return existing;
896
896
  }
897
897
  if (process.versions.electron) {
898
- const { runDaemonChild } = await import("./daemonChild-NWLM422N.js");
898
+ const { runDaemonChild } = await import("./daemonChild-WTZ7X6SZ.js");
899
899
  const handle = await runDaemonChild({
900
900
  installSignalHandlers: false,
901
901
  exitOnFailure: false,
@@ -5,7 +5,7 @@ import {
5
5
  TunnelAlreadyRunningError,
6
6
  TunnelManager,
7
7
  TunnelRebuildInProgressError
8
- } from "./chunk-3WMTTJHI.js";
8
+ } from "./chunk-5HBGVJSW.js";
9
9
  import {
10
10
  ensureDaemonRunning,
11
11
  getDaemonInfo,
@@ -13,7 +13,7 @@ import {
13
13
  ipcMismatchMessage,
14
14
  isIpcCompatible,
15
15
  printDaemonVersionNoticeOnce
16
- } from "./chunk-FBKAYNFS.js";
16
+ } from "./chunk-OQVFQ5VG.js";
17
17
  import {
18
18
  SessionMode
19
19
  } from "./chunk-MKGD2QAI.js";
@@ -33,7 +33,7 @@ import {
33
33
  } from "./chunk-HTIWY3O5.js";
34
34
  import {
35
35
  logger
36
- } from "./chunk-LWCVB42S.js";
36
+ } from "./chunk-DGAH7UVX.js";
37
37
 
38
38
  // src/remote_management/remote_schema.ts
39
39
  import { HaProxyVersion, TunnelType } from "@pinggy/pinggy";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ensurePinggyConfigDir,
3
3
  getDaemonConfigPath
4
- } from "./chunk-MAK5R4WQ.js";
4
+ } from "./chunk-WFHMERT3.js";
5
5
 
6
6
  // src/daemon/lifecycle/daemonConfig.ts
7
7
  import fs from "fs";
@@ -58,6 +58,17 @@ function ensurePinggyLogDir() {
58
58
  function getTunnelLogDir() {
59
59
  return path.join(getPinggyLogDir(), "tunnels");
60
60
  }
61
+ function getLibpinggyLogDir() {
62
+ return path.join(getPinggyLogDir(), "libpinggy");
63
+ }
64
+ function ensureLibpinggyLogDir() {
65
+ const dir = getLibpinggyLogDir();
66
+ fs.mkdirSync(dir, { recursive: true });
67
+ return dir;
68
+ }
69
+ function getLibpinggyLogPath() {
70
+ return path.join(getLibpinggyLogDir(), "libpinggy.log");
71
+ }
61
72
  function getTunnelLogPath(tunnelId, origin, name) {
62
73
  const dir = getTunnelLogDir();
63
74
  if (name) {
@@ -93,6 +104,8 @@ export {
93
104
  getDaemonConfigPath,
94
105
  ensurePinggyLogDir,
95
106
  getTunnelLogDir,
107
+ ensureLibpinggyLogDir,
108
+ getLibpinggyLogPath,
96
109
  getTunnelLogPath,
97
110
  getDaemonLogPath,
98
111
  getDeviceConfigPath,
@@ -22,9 +22,9 @@ import {
22
22
  validateName,
23
23
  validateNameForStorage,
24
24
  validateNameStrict
25
- } from "./chunk-2GIJXE4K.js";
26
- import "./chunk-LWCVB42S.js";
27
- import "./chunk-MAK5R4WQ.js";
25
+ } from "./chunk-3IPMFCEF.js";
26
+ import "./chunk-DGAH7UVX.js";
27
+ import "./chunk-WFHMERT3.js";
28
28
  export {
29
29
  CONFIG_VERBS,
30
30
  ConfigVerb,
@@ -6,22 +6,22 @@ import {
6
6
  trackIPCTunnelStart,
7
7
  trackTunnelStart,
8
8
  trackTunnelStop
9
- } from "./chunk-VMED2V36.js";
10
- import "./chunk-NO6NLGYZ.js";
11
- import "./chunk-CZOKR73F.js";
9
+ } from "./chunk-LF6WMFWT.js";
10
+ import "./chunk-Q5RYSWFK.js";
11
+ import "./chunk-VD5ZFCZW.js";
12
12
  import "./chunk-MHQ3CVEB.js";
13
- import "./chunk-2GIJXE4K.js";
13
+ import "./chunk-3IPMFCEF.js";
14
14
  import "./chunk-XZ64ZAGO.js";
15
- import "./chunk-3WMTTJHI.js";
15
+ import "./chunk-5HBGVJSW.js";
16
16
  import "./chunk-UB26QJ4T.js";
17
- import "./chunk-LX5LDLLH.js";
18
- import "./chunk-FBKAYNFS.js";
17
+ import "./chunk-HJECJ7LC.js";
18
+ import "./chunk-OQVFQ5VG.js";
19
19
  import {
20
20
  DaemonHost
21
21
  } from "./chunk-MKGD2QAI.js";
22
22
  import "./chunk-HTIWY3O5.js";
23
- import "./chunk-LWCVB42S.js";
24
- import "./chunk-MAK5R4WQ.js";
23
+ import "./chunk-DGAH7UVX.js";
24
+ import "./chunk-WFHMERT3.js";
25
25
  export {
26
26
  DaemonHost,
27
27
  getDaemonHost,
@@ -5,8 +5,8 @@ import {
5
5
  saveDeviceAgent,
6
6
  savedDeviceAgent,
7
7
  writeDaemonConfig
8
- } from "./chunk-CZOKR73F.js";
9
- import "./chunk-MAK5R4WQ.js";
8
+ } from "./chunk-VD5ZFCZW.js";
9
+ import "./chunk-WFHMERT3.js";
10
10
  export {
11
11
  configuredLogLevel,
12
12
  forgetDeviceAgent,
package/dist/index.cjs CHANGED
@@ -237,6 +237,17 @@ function ensurePinggyLogDir() {
237
237
  function getTunnelLogDir() {
238
238
  return import_path2.default.join(getPinggyLogDir(), "tunnels");
239
239
  }
240
+ function getLibpinggyLogDir() {
241
+ return import_path2.default.join(getPinggyLogDir(), "libpinggy");
242
+ }
243
+ function ensureLibpinggyLogDir() {
244
+ const dir = getLibpinggyLogDir();
245
+ import_fs2.default.mkdirSync(dir, { recursive: true });
246
+ return dir;
247
+ }
248
+ function getLibpinggyLogPath() {
249
+ return import_path2.default.join(getLibpinggyLogDir(), "libpinggy.log");
250
+ }
240
251
  function getTunnelLogPath(tunnelId, origin, name) {
241
252
  const dir = getTunnelLogDir();
242
253
  if (name) {
@@ -556,6 +567,45 @@ var init_rotateLog = __esm({
556
567
  }
557
568
  });
558
569
 
570
+ // src/logger/nativeLog.ts
571
+ function sdkAddon() {
572
+ return import_pinggy2.Pinggy.addon;
573
+ }
574
+ function setNativeLogging(enabled, addon = sdkAddon()) {
575
+ if (!addon) {
576
+ if (!warned) {
577
+ warned = true;
578
+ logger.warn("libpinggy logging unavailable: the SDK does not expose its native addon");
579
+ }
580
+ return;
581
+ }
582
+ try {
583
+ if (enabled && !pathSet) {
584
+ ensureLibpinggyLogDir();
585
+ const logPath = getLibpinggyLogPath();
586
+ maybeRotate(logPath);
587
+ addon.setLogPath(logPath);
588
+ pathSet = true;
589
+ }
590
+ addon.setLogEnable(enabled);
591
+ } catch (err) {
592
+ logger.error("Failed to configure libpinggy logging", { error: err instanceof Error ? err.message : String(err) });
593
+ }
594
+ }
595
+ var import_pinggy2, pathSet, warned;
596
+ var init_nativeLog = __esm({
597
+ "src/logger/nativeLog.ts"() {
598
+ "use strict";
599
+ init_cjs_shims();
600
+ import_pinggy2 = require("@pinggy/pinggy");
601
+ init_logger();
602
+ init_configDir();
603
+ init_rotateLog();
604
+ pathSet = false;
605
+ warned = false;
606
+ }
607
+ });
608
+
559
609
  // src/types.ts
560
610
  function isErrorResponse(obj) {
561
611
  return typeof obj === "object" && obj !== null && "code" in obj && "message" in obj && typeof obj.message === "string" && Object.values(ErrorCode).includes(obj.code);
@@ -741,18 +791,19 @@ __export(TunnelManager_exports, {
741
791
  TunnelRebuildInProgressError: () => TunnelRebuildInProgressError
742
792
  });
743
793
  function mapToSdkLogLevel(level) {
744
- if (level === "debug") return import_pinggy2.LogLevel.DEBUG;
745
- if (level === "error") return import_pinggy2.LogLevel.ERROR;
746
- return import_pinggy2.LogLevel.INFO;
794
+ if (level === "debug") return import_pinggy3.LogLevel.DEBUG;
795
+ if (level === "error") return import_pinggy3.LogLevel.ERROR;
796
+ return import_pinggy3.LogLevel.INFO;
747
797
  }
748
- var import_pinggy2, import_node_path, import_node_worker_threads, import_node_url, __filename3, __dirname2, START_FAILED_MESSAGE, STATS_HISTORY_LIMIT, TunnelAlreadyRunningError, TunnelRebuildInProgressError, TunnelManager;
798
+ var import_pinggy3, import_node_path, import_node_worker_threads, import_node_url, __filename3, __dirname2, START_FAILED_MESSAGE, STATS_HISTORY_LIMIT, TunnelAlreadyRunningError, TunnelRebuildInProgressError, TunnelManager;
749
799
  var init_TunnelManager = __esm({
750
800
  "src/tunnel_manager/TunnelManager.ts"() {
751
801
  "use strict";
752
802
  init_cjs_shims();
753
- import_pinggy2 = require("@pinggy/pinggy");
803
+ import_pinggy3 = require("@pinggy/pinggy");
754
804
  init_logger();
755
805
  init_tunnelLogger();
806
+ init_nativeLog();
756
807
  init_rotateLog();
757
808
  init_types();
758
809
  import_node_path = __toESM(require("path"), 1);
@@ -852,14 +903,16 @@ var init_TunnelManager = __esm({
852
903
  const tunnelLogPath = getTunnelLogPath(params.tunnelid, params.origin, tunnelLogName);
853
904
  maybeRotate(tunnelLogPath);
854
905
  attachTunnelLogger(params.tunnelid, params.origin, tunnelLogName);
906
+ const loggingEnabled = isTunnelLoggingEnabled();
907
+ setNativeLogging(loggingEnabled);
855
908
  let instance;
856
909
  try {
857
910
  logger.debug("Creating tunnel instance with processed config", tunnelConfig);
858
- instance = await import_pinggy2.TunnelInstance.create(tunnelConfig, {
859
- enabled: true,
911
+ instance = await import_pinggy3.TunnelInstance.create(tunnelConfig, {
912
+ enabled: loggingEnabled,
860
913
  logLevel: mapToSdkLogLevel(getLogLevel()),
861
914
  logFilePath: tunnelLogPath,
862
- libpinggyLogPath: tunnelLogPath
915
+ libpinggyLogPath: null
863
916
  });
864
917
  } catch (e) {
865
918
  logger.error("Error creating tunnel instance:", e);
@@ -1052,17 +1105,17 @@ var init_TunnelManager = __esm({
1052
1105
  }
1053
1106
  }
1054
1107
  /**
1055
- * Re-apply the given log level to every live tunnel's worker JS logger.
1056
- * Native libpinggy level is fixed at worker init and cannot be re-pathed
1057
- * or re-levelled at runtime without restarting the tunnel.
1108
+ * Re-apply the given log level, and the tunnel-logging switch, to every live tunnel's worker
1109
+ * JS logger. libpinggy has no log level at runtime, only on or off (see nativeLog.ts).
1058
1110
  */
1059
1111
  applyLogLevelToActiveTunnels(level) {
1060
1112
  const sdkLevel = mapToSdkLogLevel(level);
1113
+ const loggingEnabled = isTunnelLoggingEnabled();
1061
1114
  for (const tunnel of this.tunnelsByTunnelId.values()) {
1062
1115
  if (tunnel.isStopped) continue;
1063
1116
  if (tunnel.lastError?.isFatal) continue;
1064
1117
  const logPath = getTunnelLogPath(tunnel.tunnelid, tunnel.origin, tunnel.tunnelName || tunnel.tunnelConfig?.name);
1065
- tunnel.instance.setDebugLogging(true, sdkLevel, logPath).catch((err) => {
1118
+ tunnel.instance.setDebugLogging(loggingEnabled, sdkLevel, logPath).catch((err) => {
1066
1119
  logger.error("Failed to apply log level to tunnel", { tunnelId: tunnel.tunnelid, error: err?.message ?? err });
1067
1120
  });
1068
1121
  }
@@ -2324,7 +2377,7 @@ function tunnelConfigToPinggyOptions(config) {
2324
2377
  const forwardingData = [];
2325
2378
  forwardingData.push({
2326
2379
  address: `${config.forwardedhost}:${config.localport}`,
2327
- type: config.type || import_pinggy3.TunnelType.Http
2380
+ type: config.type || import_pinggy4.TunnelType.Http
2328
2381
  // Default to HTTP for the primary forwarding entry
2329
2382
  });
2330
2383
  if (config.additionalForwarding && Array.isArray(config.additionalForwarding)) {
@@ -2334,7 +2387,7 @@ function tunnelConfigToPinggyOptions(config) {
2334
2387
  forwardingData.push({
2335
2388
  address: `${entry.localDomain}:${entry.localPort}`,
2336
2389
  listenAddress,
2337
- type: import_pinggy3.TunnelType.Http
2390
+ type: import_pinggy4.TunnelType.Http
2338
2391
  });
2339
2392
  }
2340
2393
  });
@@ -2372,7 +2425,7 @@ function pinggyOptionsToTunnelConfig(opts, configid, configName, localserverTls,
2372
2425
  const forwarding = primaryEntry ? String(primaryEntry.address) : String(opts.forwarding);
2373
2426
  const [parsedForwardedHost, portStr] = forwarding.split(":");
2374
2427
  const parsedLocalPort = parseInt(portStr, 10);
2375
- const tunnelType = primaryEntry?.type ?? import_pinggy3.TunnelType.Http;
2428
+ const tunnelType = primaryEntry?.type ?? import_pinggy4.TunnelType.Http;
2376
2429
  const additionalForwarding = additionalEntries.map((e) => {
2377
2430
  const [localDomain, localPortStr] = String(e.address).split(":");
2378
2431
  const [remoteDomain, remotePortStr] = String(e.listenAddress).split(":");
@@ -2420,12 +2473,12 @@ function pinggyOptionsToTunnelConfig(opts, configid, configName, localserverTls,
2420
2473
  serve: serve || ""
2421
2474
  };
2422
2475
  }
2423
- var import_pinggy3, import_zod, HeaderModificationSchema, AdditionalForwardingSchema, TunnelConfigSchema, StartSchema, StopSchema, GetSchema, RestartSchema, UpdateConfigSchema, ForwardingEntryV2Schema, OptionalSchema, TunnelConfigV1Schema, TUNNEL_CONFIG_V1_KEYS, StartV2Schema, UpdateConfigV2Schema;
2476
+ var import_pinggy4, import_zod, HeaderModificationSchema, AdditionalForwardingSchema, TunnelConfigSchema, StartSchema, StopSchema, GetSchema, RestartSchema, UpdateConfigSchema, ForwardingEntryV2Schema, OptionalSchema, TunnelConfigV1Schema, TUNNEL_CONFIG_V1_KEYS, StartV2Schema, UpdateConfigV2Schema;
2424
2477
  var init_remote_schema = __esm({
2425
2478
  "src/remote_management/remote_schema.ts"() {
2426
2479
  "use strict";
2427
2480
  init_cjs_shims();
2428
- import_pinggy3 = require("@pinggy/pinggy");
2481
+ import_pinggy4 = require("@pinggy/pinggy");
2429
2482
  import_zod = require("zod");
2430
2483
  init_util();
2431
2484
  HeaderModificationSchema = import_zod.z.object({
@@ -2468,11 +2521,11 @@ var init_remote_schema = __esm({
2468
2521
  token: import_zod.z.string(),
2469
2522
  tunnelTimeout: import_zod.z.number(),
2470
2523
  type: import_zod.z.enum([
2471
- import_pinggy3.TunnelType.Http,
2472
- import_pinggy3.TunnelType.Tcp,
2473
- import_pinggy3.TunnelType.Udp,
2474
- import_pinggy3.TunnelType.Tls,
2475
- import_pinggy3.TunnelType.TlsTcp
2524
+ import_pinggy4.TunnelType.Http,
2525
+ import_pinggy4.TunnelType.Tcp,
2526
+ import_pinggy4.TunnelType.Udp,
2527
+ import_pinggy4.TunnelType.Tls,
2528
+ import_pinggy4.TunnelType.TlsTcp
2476
2529
  ]),
2477
2530
  webdebuggerport: import_zod.z.number(),
2478
2531
  xff: import_zod.z.string(),
@@ -2506,7 +2559,7 @@ var init_remote_schema = __esm({
2506
2559
  ForwardingEntryV2Schema = import_zod.z.object({
2507
2560
  listenAddress: import_zod.z.string().optional(),
2508
2561
  address: import_zod.z.string(),
2509
- type: import_zod.z.enum([import_pinggy3.TunnelType.Http, import_pinggy3.TunnelType.Tcp, import_pinggy3.TunnelType.Udp, import_pinggy3.TunnelType.Tls, import_pinggy3.TunnelType.TlsTcp]).default(import_pinggy3.TunnelType.Http)
2562
+ type: import_zod.z.enum([import_pinggy4.TunnelType.Http, import_pinggy4.TunnelType.Tcp, import_pinggy4.TunnelType.Udp, import_pinggy4.TunnelType.Tls, import_pinggy4.TunnelType.TlsTcp]).default(import_pinggy4.TunnelType.Http)
2510
2563
  });
2511
2564
  OptionalSchema = import_zod.z.object({
2512
2565
  sniServerName: import_zod.z.string().optional(),
@@ -2550,7 +2603,7 @@ var init_remote_schema = __esm({
2550
2603
  httpsOnly: import_zod.z.boolean().optional(),
2551
2604
  originalRequestUrl: import_zod.z.boolean().optional(),
2552
2605
  allowPreflight: import_zod.z.boolean().optional(),
2553
- haProxy: import_zod.z.enum([import_pinggy3.HaProxyVersion.V1, import_pinggy3.HaProxyVersion.V2]).optional(),
2606
+ haProxy: import_zod.z.enum([import_pinggy4.HaProxyVersion.V1, import_pinggy4.HaProxyVersion.V2]).optional(),
2554
2607
  serve: import_zod.z.string().optional(),
2555
2608
  optional: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional()
2556
2609
  }).superRefine((config, ctx) => {
@@ -2559,11 +2612,11 @@ var init_remote_schema = __esm({
2559
2612
  }
2560
2613
  const entries = Array.isArray(config.forwarding) ? config.forwarding : [];
2561
2614
  const primaryType = entries.length > 0 ? entries[0].type : void 0;
2562
- if (primaryType !== import_pinggy3.TunnelType.Tcp) {
2615
+ if (primaryType !== import_pinggy4.TunnelType.Tcp) {
2563
2616
  ctx.addIssue({
2564
2617
  code: "custom",
2565
2618
  path: ["haProxy"],
2566
- message: `haProxy can only be used with "tcp" tunnels, but the first forwarding rule has type: ${primaryType ?? import_pinggy3.TunnelType.Http}`
2619
+ message: `haProxy can only be used with "tcp" tunnels, but the first forwarding rule has type: ${primaryType ?? import_pinggy4.TunnelType.Http}`
2567
2620
  });
2568
2621
  }
2569
2622
  });
@@ -4049,6 +4102,7 @@ function printHelpMessage() {
4049
4102
  console.log(" pinggy attach <name|id> # Re-attach TUI to a running tunnel");
4050
4103
  console.log(" pinggy restart <name|id> # Restart a running tunnel (picks up latest log level)");
4051
4104
  console.log(" pinggy logs [-f] [<name|id>] # Show (or follow) tunnel or daemon logs");
4105
+ console.log(" pinggy logs [-f] libpinggy # Show (or follow) the native library log, shared by all tunnels");
4052
4106
  console.log(" pinggy log level [debug|info|error] # Get or set the log level");
4053
4107
  console.log(" pinggy log path [<name|id>] # Print log file path");
4054
4108
  console.log("\nBackground Mode:");
@@ -6589,10 +6643,10 @@ function parseExtendedOptions(options, config, localServerTls) {
6589
6643
  break;
6590
6644
  case "haproxy":
6591
6645
  case "haproxy:v1":
6592
- config.haProxy = import_pinggy4.HaProxyVersion.V1;
6646
+ config.haProxy = import_pinggy5.HaProxyVersion.V1;
6593
6647
  break;
6594
6648
  case "haproxy:v2":
6595
- config.haProxy = import_pinggy4.HaProxyVersion.V2;
6649
+ config.haProxy = import_pinggy5.HaProxyVersion.V2;
6596
6650
  break;
6597
6651
  default: {
6598
6652
  if (value && (value.startsWith("localServerTls") || value.startsWith("localservertls"))) {
@@ -6702,12 +6756,12 @@ function isValidIpV6Cidr(input) {
6702
6756
  }
6703
6757
  return false;
6704
6758
  }
6705
- var import_pinggy4, import_net;
6759
+ var import_pinggy5, import_net;
6706
6760
  var init_extendedOptions = __esm({
6707
6761
  "src/cli/extendedOptions.ts"() {
6708
6762
  "use strict";
6709
6763
  init_cjs_shims();
6710
- import_pinggy4 = require("@pinggy/pinggy");
6764
+ import_pinggy5 = require("@pinggy/pinggy");
6711
6765
  import_net = require("net");
6712
6766
  init_logger();
6713
6767
  init_printer();
@@ -6744,7 +6798,7 @@ function parseUserAndDomain(str) {
6744
6798
  const [user, domain] = str.split("@", 2);
6745
6799
  if (isValidServerAddress(domain)) {
6746
6800
  let processKeyword2 = function(keyword) {
6747
- if ([import_pinggy5.TunnelType.Http, import_pinggy5.TunnelType.Tcp, import_pinggy5.TunnelType.Tls, import_pinggy5.TunnelType.Udp, import_pinggy5.TunnelType.TlsTcp].includes(keyword)) {
6801
+ if ([import_pinggy6.TunnelType.Http, import_pinggy6.TunnelType.Tcp, import_pinggy6.TunnelType.Tls, import_pinggy6.TunnelType.Udp, import_pinggy6.TunnelType.TlsTcp].includes(keyword)) {
6748
6802
  type = keyword;
6749
6803
  } else if (keyword === "force") {
6750
6804
  forceFlag = true;
@@ -6832,7 +6886,7 @@ function parseUsers(positionalArgs, explicitToken) {
6832
6886
  }
6833
6887
  function parseType(finalConfig, values, inferredType) {
6834
6888
  const t = inferredType || values.type;
6835
- if (t === import_pinggy5.TunnelType.Http || t === import_pinggy5.TunnelType.Tcp || t === import_pinggy5.TunnelType.Tls || t === import_pinggy5.TunnelType.Udp || t === import_pinggy5.TunnelType.TlsTcp) {
6889
+ if (t === import_pinggy6.TunnelType.Http || t === import_pinggy6.TunnelType.Tcp || t === import_pinggy6.TunnelType.Tls || t === import_pinggy6.TunnelType.Udp || t === import_pinggy6.TunnelType.TlsTcp) {
6836
6890
  return t;
6837
6891
  }
6838
6892
  }
@@ -6930,7 +6984,7 @@ function parseAdditionalForwarding(forwarding) {
6930
6984
  }
6931
6985
  const firstPart = parsed[0];
6932
6986
  const [hostPart] = firstPart.split("@");
6933
- let protocol = import_pinggy5.TunnelType.Http;
6987
+ let protocol = import_pinggy6.TunnelType.Http;
6934
6988
  let remoteDomainRaw;
6935
6989
  let remotePort = 0;
6936
6990
  if (hostPart.includes("//")) {
@@ -6963,7 +7017,7 @@ function parseAdditionalForwarding(forwarding) {
6963
7017
  if (!isValidServerAddress(remoteDomainRaw)) {
6964
7018
  return new Error("invalid remote domain");
6965
7019
  }
6966
- protocol = import_pinggy5.TunnelType.Http;
7020
+ protocol = import_pinggy6.TunnelType.Http;
6967
7021
  remotePort = 0;
6968
7022
  }
6969
7023
  const localDomain = removeIPv6Brackets(parsed[2] || "localhost");
@@ -6993,7 +7047,7 @@ function parseReverseTunnelAddr(finalConfig, values, primaryType) {
6993
7047
  if (parsed instanceof Error) return parsed;
6994
7048
  forwardingData.push({
6995
7049
  address: `${parsed.localDomain}:${parsed.localPort}`,
6996
- type: primaryType || import_pinggy5.TunnelType.Http
7050
+ type: primaryType || import_pinggy6.TunnelType.Http
6997
7051
  });
6998
7052
  } else if (slicedForwarding.length === 4) {
6999
7053
  const parsed = parseAdditionalForwarding(forwarding);
@@ -7059,7 +7113,7 @@ function normalizeForwardingToArray(finalConfig, type) {
7059
7113
  if (typeof fwd !== "string") {
7060
7114
  return;
7061
7115
  }
7062
- finalConfig.forwarding = fwd.trim() === "" ? [] : [{ type: type || import_pinggy5.TunnelType.Http, address: fwd.trim() }];
7116
+ finalConfig.forwarding = fwd.trim() === "" ? [] : [{ type: type || import_pinggy6.TunnelType.Http, address: fwd.trim() }];
7063
7117
  }
7064
7118
  function parseArgs2(finalConfig, remainingPositionals) {
7065
7119
  let localserverTls = "";
@@ -7128,11 +7182,11 @@ function validateHaProxy(finalConfig) {
7128
7182
  const forwarding = finalConfig.forwarding;
7129
7183
  const entries = Array.isArray(forwarding) ? forwarding : [];
7130
7184
  const primaryType = entries.length > 0 ? entries[0].type : void 0;
7131
- if (primaryType === import_pinggy5.TunnelType.Tcp) {
7185
+ if (primaryType === import_pinggy6.TunnelType.Tcp) {
7132
7186
  return null;
7133
7187
  }
7134
7188
  return new Error(
7135
- `HAProxy PROXY protocol (x:haproxy) can only be used with TCP tunnels, but this tunnel is "${primaryType ?? import_pinggy5.TunnelType.Http}". Make it a TCP tunnel (--type tcp, or the tcp@ server prefix) or drop x:haproxy.`
7189
+ `HAProxy PROXY protocol (x:haproxy) can only be used with TCP tunnels, but this tunnel is "${primaryType ?? import_pinggy6.TunnelType.Http}". Make it a TCP tunnel (--type tcp, or the tcp@ server prefix) or drop x:haproxy.`
7136
7190
  );
7137
7191
  }
7138
7192
  function buildFinalConfig(values, positionals, baseConfig) {
@@ -7206,7 +7260,7 @@ function buildFinalConfig(values, positionals, baseConfig) {
7206
7260
  storeJson(finalConfig, saveconf);
7207
7261
  return finalConfig;
7208
7262
  }
7209
- var import_pinggy5, import_fs7, import_path7, import_net2, domainRegex, KEYWORDS, VALID_PROTOCOLS;
7263
+ var import_pinggy6, import_fs7, import_path7, import_net2, domainRegex, KEYWORDS, VALID_PROTOCOLS;
7210
7264
  var init_buildConfig = __esm({
7211
7265
  "src/cli/buildConfig.ts"() {
7212
7266
  "use strict";
@@ -7215,21 +7269,21 @@ var init_buildConfig = __esm({
7215
7269
  init_extendedOptions();
7216
7270
  init_logger();
7217
7271
  init_util();
7218
- import_pinggy5 = require("@pinggy/pinggy");
7272
+ import_pinggy6 = require("@pinggy/pinggy");
7219
7273
  import_fs7 = __toESM(require("fs"), 1);
7220
7274
  import_path7 = __toESM(require("path"), 1);
7221
7275
  import_net2 = require("net");
7222
7276
  domainRegex = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
7223
7277
  KEYWORDS = /* @__PURE__ */ new Set([
7224
- import_pinggy5.TunnelType.Http,
7225
- import_pinggy5.TunnelType.Tcp,
7226
- import_pinggy5.TunnelType.Tls,
7227
- import_pinggy5.TunnelType.Udp,
7228
- import_pinggy5.TunnelType.TlsTcp,
7278
+ import_pinggy6.TunnelType.Http,
7279
+ import_pinggy6.TunnelType.Tcp,
7280
+ import_pinggy6.TunnelType.Tls,
7281
+ import_pinggy6.TunnelType.Udp,
7282
+ import_pinggy6.TunnelType.TlsTcp,
7229
7283
  "force",
7230
7284
  "qr"
7231
7285
  ]);
7232
- VALID_PROTOCOLS = [import_pinggy5.TunnelType.Http, import_pinggy5.TunnelType.Tcp, import_pinggy5.TunnelType.Udp, import_pinggy5.TunnelType.Tls, import_pinggy5.TunnelType.TlsTcp];
7286
+ VALID_PROTOCOLS = [import_pinggy6.TunnelType.Http, import_pinggy6.TunnelType.Tcp, import_pinggy6.TunnelType.Udp, import_pinggy6.TunnelType.Tls, import_pinggy6.TunnelType.TlsTcp];
7233
7287
  }
7234
7288
  });
7235
7289
 
@@ -9689,7 +9743,8 @@ function printLogHelp() {
9689
9743
  console.log(" level Print current log level");
9690
9744
  console.log(" level debug|info|error Set log level");
9691
9745
  console.log(" path Print daemon log path");
9692
- console.log(" path <name|id> Print tunnel log path\n");
9746
+ console.log(" path <name|id> Print tunnel log path");
9747
+ console.log(" path libpinggy Print the native library's log path (one file for all tunnels)\n");
9693
9748
  }
9694
9749
  function printConfigHelp() {
9695
9750
  console.log("\nUsage: pinggy config <command> [name] [options]\n");
@@ -13604,21 +13659,28 @@ var init_logPaths = __esm({
13604
13659
  });
13605
13660
 
13606
13661
  // src/cli/subcommand/handlers/logLookup.ts
13662
+ function orLibpinggyLog(nameOrId, result) {
13663
+ if (nameOrId === LIBPINGGY_LOG_NAME && result.status === "not-found") {
13664
+ return { status: "libpinggy", path: getLibpinggyLogPath() };
13665
+ }
13666
+ return result;
13667
+ }
13607
13668
  function openLogLookup() {
13608
13669
  const client = new TunnelClient();
13609
13670
  if (!client.connectIfRunning()) {
13610
13671
  return {
13611
13672
  daemonLogPath: () => Promise.resolve(getDaemonLogPath()),
13612
- resolve: (nameOrId) => Promise.resolve(resolveStoppedLogPath(nameOrId)),
13673
+ resolve: (nameOrId) => Promise.resolve(orLibpinggyLog(nameOrId, resolveStoppedLogPath(nameOrId))),
13613
13674
  close: () => void 0
13614
13675
  };
13615
13676
  }
13616
13677
  return {
13617
13678
  daemonLogPath: async () => (await client.getLogPaths()).daemon,
13618
- resolve: (nameOrId) => client.resolveLogPath(nameOrId),
13679
+ resolve: async (nameOrId) => orLibpinggyLog(nameOrId, await client.resolveLogPath(nameOrId)),
13619
13680
  close: () => client.close()
13620
13681
  };
13621
13682
  }
13683
+ var LIBPINGGY_LOG_NAME;
13622
13684
  var init_logLookup = __esm({
13623
13685
  "src/cli/subcommand/handlers/logLookup.ts"() {
13624
13686
  "use strict";
@@ -13626,6 +13688,7 @@ var init_logLookup = __esm({
13626
13688
  init_tunnelClient();
13627
13689
  init_logPaths();
13628
13690
  init_configDir();
13691
+ LIBPINGGY_LOG_NAME = "libpinggy";
13629
13692
  }
13630
13693
  });
13631
13694
 
@@ -13805,6 +13868,7 @@ async function handleLogPath(args) {
13805
13868
  switch (result.status) {
13806
13869
  case "running":
13807
13870
  case "historical":
13871
+ case "libpinggy":
13808
13872
  printer_default.print(result.path);
13809
13873
  break;
13810
13874
  case "config-only":
@@ -15141,6 +15205,7 @@ var init_ipcServer = __esm({
15141
15205
  init_main();
15142
15206
  init_logger();
15143
15207
  init_tunnelLogger();
15208
+ init_nativeLog();
15144
15209
  init_configStore();
15145
15210
  init_configDir();
15146
15211
  init_logPaths();
@@ -15279,6 +15344,8 @@ var init_ipcServer = __esm({
15279
15344
  [Route.SetTunnelLogging]: (req) => {
15280
15345
  if (typeof req.enabled !== "boolean") throw new Error("Missing 'enabled' boolean");
15281
15346
  setTunnelLoggingEnabled(req.enabled);
15347
+ setNativeLogging(req.enabled);
15348
+ TunnelManager.getInstance().applyLogLevelToActiveTunnels(getLogLevel());
15282
15349
  return { enabled: isTunnelLoggingEnabled() };
15283
15350
  },
15284
15351
  [Route.GetLogPaths]: async () => {
package/dist/index.d.cts CHANGED
@@ -257,9 +257,8 @@ declare class TunnelManager implements ITunnelManager {
257
257
  */
258
258
  getAllTunnels(): Promise<TunnelList[]>;
259
259
  /**
260
- * Re-apply the given log level to every live tunnel's worker JS logger.
261
- * Native libpinggy level is fixed at worker init and cannot be re-pathed
262
- * or re-levelled at runtime without restarting the tunnel.
260
+ * Re-apply the given log level, and the tunnel-logging switch, to every live tunnel's worker
261
+ * JS logger. libpinggy has no log level at runtime, only on or off (see nativeLog.ts).
263
262
  */
264
263
  applyLogLevelToActiveTunnels(level: string): void;
265
264
  /**
package/dist/index.d.ts CHANGED
@@ -257,9 +257,8 @@ declare class TunnelManager implements ITunnelManager {
257
257
  */
258
258
  getAllTunnels(): Promise<TunnelList[]>;
259
259
  /**
260
- * Re-apply the given log level to every live tunnel's worker JS logger.
261
- * Native libpinggy level is fixed at worker init and cannot be re-pathed
262
- * or re-levelled at runtime without restarting the tunnel.
260
+ * Re-apply the given log level, and the tunnel-logging switch, to every live tunnel's worker
261
+ * JS logger. libpinggy has no log level at runtime, only on or off (see nativeLog.ts).
263
262
  */
264
263
  applyLogLevelToActiveTunnels(level: string): void;
265
264
  /**
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  getRemoteManagementState,
10
10
  initiateRemoteManagement,
11
11
  startRemoteManagement
12
- } from "./chunk-NO6NLGYZ.js";
12
+ } from "./chunk-Q5RYSWFK.js";
13
13
  import "./chunk-MHQ3CVEB.js";
14
14
  import {
15
15
  bulkReplace,
@@ -28,15 +28,15 @@ import {
28
28
  validateName,
29
29
  validateNameForStorage,
30
30
  validateNameStrict
31
- } from "./chunk-2GIJXE4K.js";
31
+ } from "./chunk-3IPMFCEF.js";
32
32
  import {
33
33
  TunnelManager
34
- } from "./chunk-3WMTTJHI.js";
34
+ } from "./chunk-5HBGVJSW.js";
35
35
  import "./chunk-UB26QJ4T.js";
36
36
  import {
37
37
  getDaemonInfo,
38
38
  isDaemonRunning
39
- } from "./chunk-FBKAYNFS.js";
39
+ } from "./chunk-OQVFQ5VG.js";
40
40
  import {
41
41
  DeviceAgentState
42
42
  } from "./chunk-MKGD2QAI.js";
@@ -48,13 +48,13 @@ import {
48
48
  } from "./chunk-HTIWY3O5.js";
49
49
  import {
50
50
  enablePackageLogging
51
- } from "./chunk-LWCVB42S.js";
51
+ } from "./chunk-DGAH7UVX.js";
52
52
  import {
53
53
  ensureTunnelConfigDir,
54
54
  getDaemonInfoPath,
55
55
  getPinggyConfigDir,
56
56
  getTunnelConfigDir
57
- } from "./chunk-MAK5R4WQ.js";
57
+ } from "./chunk-WFHMERT3.js";
58
58
 
59
59
  // src/utils/detect_vc_redist_on_windows.ts
60
60
  import fs from "fs";
@@ -146,7 +146,7 @@ async function verifyAndLoad() {
146
146
  process.exit(1);
147
147
  }
148
148
  }
149
- await import("./main-E4DWDOKD.js");
149
+ await import("./main-INPCUGAN.js");
150
150
  }
151
151
  verifyAndLoad().catch((err) => {
152
152
  printer_default.fatal(`Failed to start CLI:, ${err}`);
@@ -1,38 +1,38 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runDaemonChild
4
- } from "./chunk-VMED2V36.js";
4
+ } from "./chunk-LF6WMFWT.js";
5
5
  import {
6
6
  RemoteManagementUnauthorizedError,
7
7
  TunnelOperations,
8
8
  closeRemoteManagement,
9
9
  getRemoteManagementState,
10
10
  initiateRemoteManagement
11
- } from "./chunk-NO6NLGYZ.js";
12
- import "./chunk-CZOKR73F.js";
11
+ } from "./chunk-Q5RYSWFK.js";
12
+ import "./chunk-VD5ZFCZW.js";
13
13
  import "./chunk-MHQ3CVEB.js";
14
- import "./chunk-2GIJXE4K.js";
14
+ import "./chunk-3IPMFCEF.js";
15
15
  import "./chunk-XZ64ZAGO.js";
16
16
  import {
17
17
  TunnelManager
18
- } from "./chunk-3WMTTJHI.js";
18
+ } from "./chunk-5HBGVJSW.js";
19
19
  import "./chunk-UB26QJ4T.js";
20
- import "./chunk-LX5LDLLH.js";
20
+ import "./chunk-HJECJ7LC.js";
21
21
  import {
22
22
  ensureDaemonRunning,
23
23
  getActiveTunnelSummaries,
24
24
  getDaemonInfo,
25
25
  getInProcessDaemonHandle,
26
26
  isDaemonRunning
27
- } from "./chunk-FBKAYNFS.js";
27
+ } from "./chunk-OQVFQ5VG.js";
28
28
  import {
29
29
  DaemonHost
30
30
  } from "./chunk-MKGD2QAI.js";
31
31
  import "./chunk-HTIWY3O5.js";
32
32
  import {
33
33
  enablePackageLogging
34
- } from "./chunk-LWCVB42S.js";
35
- import "./chunk-MAK5R4WQ.js";
34
+ } from "./chunk-DGAH7UVX.js";
35
+ import "./chunk-WFHMERT3.js";
36
36
  export {
37
37
  DaemonHost,
38
38
  RemoteManagementUnauthorizedError,
@@ -16,7 +16,7 @@ import {
16
16
  resolveLatestTag,
17
17
  runPinggyBinary,
18
18
  versionFromTag
19
- } from "./chunk-LX5LDLLH.js";
19
+ } from "./chunk-HJECJ7LC.js";
20
20
  import {
21
21
  InstallKind,
22
22
  backgroundInstallKind,
@@ -30,17 +30,17 @@ import {
30
30
  recordLatestVersion,
31
31
  unixLayoutPaths,
32
32
  writeUpdateState
33
- } from "./chunk-FBKAYNFS.js";
33
+ } from "./chunk-OQVFQ5VG.js";
34
34
  import "./chunk-MKGD2QAI.js";
35
35
  import {
36
36
  errorMessage,
37
37
  getVersion
38
38
  } from "./chunk-HTIWY3O5.js";
39
- import "./chunk-LWCVB42S.js";
39
+ import "./chunk-DGAH7UVX.js";
40
40
  import {
41
41
  ensurePinggyLogDir,
42
42
  getUpdateLogPath
43
- } from "./chunk-MAK5R4WQ.js";
43
+ } from "./chunk-WFHMERT3.js";
44
44
 
45
45
  // src/update/updateChild.ts
46
46
  import fs from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  } from "../chunk-UB26QJ4T.js";
4
4
  import {
5
5
  logger
6
- } from "../chunk-LWCVB42S.js";
6
+ } from "../chunk-DGAH7UVX.js";
7
7
 
8
8
  // src/workers/file_serve_worker.ts
9
9
  import { parentPort, workerData } from "worker_threads";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinggy",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Create secure, shareable tunnels to your localhost and manage them from the command line. ",