pinggy 0.3.9 → 0.4.0
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.
|
@@ -99,7 +99,7 @@ _CLIPrinter.errorDefinitions = [
|
|
|
99
99
|
message: (err) => {
|
|
100
100
|
const match = /Unknown option '(.+?)'/.exec(err.message);
|
|
101
101
|
const option = match ? match[1] : "(unknown)";
|
|
102
|
-
return `Unknown option '${option}'. Please check your command or use pinggy
|
|
102
|
+
return `Unknown option '${option}'. Please check your command or use pinggy -h for guidance.`;
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
{
|
|
@@ -234,7 +234,8 @@ var TunnelManager = class _TunnelManager {
|
|
|
234
234
|
createdAt: now,
|
|
235
235
|
startedAt: null,
|
|
236
236
|
stoppedAt: null,
|
|
237
|
-
autoReconnect: params.autoReconnect
|
|
237
|
+
autoReconnect: params.autoReconnect,
|
|
238
|
+
lastError: {}
|
|
238
239
|
};
|
|
239
240
|
instance.setTunnelEstablishedCallback(({}) => {
|
|
240
241
|
managed.startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -265,6 +266,13 @@ var TunnelManager = class _TunnelManager {
|
|
|
265
266
|
urls = await managed.instance.start();
|
|
266
267
|
} catch (error) {
|
|
267
268
|
logger.warn("Failed to start tunnel", { tunnelId, error });
|
|
269
|
+
managed.isStopped = true;
|
|
270
|
+
managed.stoppedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
271
|
+
managed.lastError = {
|
|
272
|
+
message: "Failed to start tunnel",
|
|
273
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
274
|
+
isFatal: true
|
|
275
|
+
};
|
|
268
276
|
throw error;
|
|
269
277
|
}
|
|
270
278
|
logger.info("Tunnel started", { tunnelId, urls });
|
|
@@ -342,7 +350,6 @@ var TunnelManager = class _TunnelManager {
|
|
|
342
350
|
return [];
|
|
343
351
|
}
|
|
344
352
|
const urls = await managed.instance.urls();
|
|
345
|
-
logger.debug("Queried tunnel URLs", { tunnelId, urls });
|
|
346
353
|
return urls;
|
|
347
354
|
} catch (error) {
|
|
348
355
|
logger.error("Error fetching tunnel URLs", { tunnelId, error });
|
|
@@ -361,7 +368,7 @@ var TunnelManager = class _TunnelManager {
|
|
|
361
368
|
configId: tunnel.configId,
|
|
362
369
|
tunnelName: tunnel.tunnelName,
|
|
363
370
|
tunnelConfig: tunnel.tunnelConfig,
|
|
364
|
-
remoteurls:
|
|
371
|
+
remoteurls: tunnel.isStopped || tunnel.lastError?.isFatal ? [] : await this.getTunnelUrls(tunnel.tunnelid),
|
|
365
372
|
serve: tunnel.serve
|
|
366
373
|
};
|
|
367
374
|
}));
|
|
@@ -384,7 +391,6 @@ var TunnelManager = class _TunnelManager {
|
|
|
384
391
|
return "exited";
|
|
385
392
|
}
|
|
386
393
|
const status = await managed.instance.getStatus();
|
|
387
|
-
logger.debug("Queried tunnel status", { tunnelId, status });
|
|
388
394
|
return status;
|
|
389
395
|
}
|
|
390
396
|
/**
|
|
@@ -1038,6 +1044,14 @@ var TunnelManager = class _TunnelManager {
|
|
|
1038
1044
|
try {
|
|
1039
1045
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1040
1046
|
logger.info("Tunnel reported polling error", { tunnelId, errorMessage });
|
|
1047
|
+
const managedTunnel = this.tunnelsByTunnelId.get(tunnelId);
|
|
1048
|
+
if (managedTunnel) {
|
|
1049
|
+
managedTunnel.lastError = {
|
|
1050
|
+
message: errorMessage,
|
|
1051
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1052
|
+
isFatal: true
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1041
1055
|
this.notifyPollingErrorListeners(tunnelId, errorMessage);
|
|
1042
1056
|
} catch (e) {
|
|
1043
1057
|
logger.warn("Error handling tunnel polling error callback", { tunnelId, e });
|
|
@@ -1086,6 +1100,14 @@ var TunnelManager = class _TunnelManager {
|
|
|
1086
1100
|
const msg = typeof error === "string" ? error : String(error);
|
|
1087
1101
|
const isFatal = true;
|
|
1088
1102
|
logger.debug("Tunnel reported error", { tunnelId, errorNo, errorMsg: msg, recoverable });
|
|
1103
|
+
const managedTunnel = this.tunnelsByTunnelId.get(tunnelId);
|
|
1104
|
+
if (managedTunnel) {
|
|
1105
|
+
managedTunnel.lastError = {
|
|
1106
|
+
message: msg,
|
|
1107
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1108
|
+
isFatal: false
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1089
1111
|
this.notifyErrorListeners(tunnelId, msg, isFatal);
|
|
1090
1112
|
} catch (e) {
|
|
1091
1113
|
logger.warn("Error handling tunnel error callback", { tunnelId, e });
|
|
@@ -1742,6 +1764,9 @@ var TunnelOperations = class {
|
|
|
1742
1764
|
status.starttimestamp = managed.startedAt || "";
|
|
1743
1765
|
status.endtimestamp = managed.stoppedAt || "";
|
|
1744
1766
|
}
|
|
1767
|
+
if (managed?.lastError) {
|
|
1768
|
+
status.lastError = managed.lastError;
|
|
1769
|
+
}
|
|
1745
1770
|
} catch (e) {
|
|
1746
1771
|
}
|
|
1747
1772
|
return status;
|
package/dist/index.cjs
CHANGED
|
@@ -149,7 +149,7 @@ var init_printer = __esm({
|
|
|
149
149
|
message: (err) => {
|
|
150
150
|
const match = /Unknown option '(.+?)'/.exec(err.message);
|
|
151
151
|
const option = match ? match[1] : "(unknown)";
|
|
152
|
-
return `Unknown option '${option}'. Please check your command or use pinggy
|
|
152
|
+
return `Unknown option '${option}'. Please check your command or use pinggy -h for guidance.`;
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
{
|
|
@@ -405,7 +405,8 @@ var init_TunnelManager = __esm({
|
|
|
405
405
|
createdAt: now,
|
|
406
406
|
startedAt: null,
|
|
407
407
|
stoppedAt: null,
|
|
408
|
-
autoReconnect: params.autoReconnect
|
|
408
|
+
autoReconnect: params.autoReconnect,
|
|
409
|
+
lastError: {}
|
|
409
410
|
};
|
|
410
411
|
instance.setTunnelEstablishedCallback(({}) => {
|
|
411
412
|
managed.startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -436,6 +437,13 @@ var init_TunnelManager = __esm({
|
|
|
436
437
|
urls = await managed.instance.start();
|
|
437
438
|
} catch (error) {
|
|
438
439
|
logger.warn("Failed to start tunnel", { tunnelId, error });
|
|
440
|
+
managed.isStopped = true;
|
|
441
|
+
managed.stoppedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
442
|
+
managed.lastError = {
|
|
443
|
+
message: "Failed to start tunnel",
|
|
444
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
445
|
+
isFatal: true
|
|
446
|
+
};
|
|
439
447
|
throw error;
|
|
440
448
|
}
|
|
441
449
|
logger.info("Tunnel started", { tunnelId, urls });
|
|
@@ -513,7 +521,6 @@ var init_TunnelManager = __esm({
|
|
|
513
521
|
return [];
|
|
514
522
|
}
|
|
515
523
|
const urls = await managed.instance.urls();
|
|
516
|
-
logger.debug("Queried tunnel URLs", { tunnelId, urls });
|
|
517
524
|
return urls;
|
|
518
525
|
} catch (error) {
|
|
519
526
|
logger.error("Error fetching tunnel URLs", { tunnelId, error });
|
|
@@ -532,7 +539,7 @@ var init_TunnelManager = __esm({
|
|
|
532
539
|
configId: tunnel.configId,
|
|
533
540
|
tunnelName: tunnel.tunnelName,
|
|
534
541
|
tunnelConfig: tunnel.tunnelConfig,
|
|
535
|
-
remoteurls:
|
|
542
|
+
remoteurls: tunnel.isStopped || tunnel.lastError?.isFatal ? [] : await this.getTunnelUrls(tunnel.tunnelid),
|
|
536
543
|
serve: tunnel.serve
|
|
537
544
|
};
|
|
538
545
|
}));
|
|
@@ -555,7 +562,6 @@ var init_TunnelManager = __esm({
|
|
|
555
562
|
return "exited";
|
|
556
563
|
}
|
|
557
564
|
const status = await managed.instance.getStatus();
|
|
558
|
-
logger.debug("Queried tunnel status", { tunnelId, status });
|
|
559
565
|
return status;
|
|
560
566
|
}
|
|
561
567
|
/**
|
|
@@ -1209,6 +1215,14 @@ var init_TunnelManager = __esm({
|
|
|
1209
1215
|
try {
|
|
1210
1216
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1211
1217
|
logger.info("Tunnel reported polling error", { tunnelId, errorMessage });
|
|
1218
|
+
const managedTunnel = this.tunnelsByTunnelId.get(tunnelId);
|
|
1219
|
+
if (managedTunnel) {
|
|
1220
|
+
managedTunnel.lastError = {
|
|
1221
|
+
message: errorMessage,
|
|
1222
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1223
|
+
isFatal: true
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1212
1226
|
this.notifyPollingErrorListeners(tunnelId, errorMessage);
|
|
1213
1227
|
} catch (e) {
|
|
1214
1228
|
logger.warn("Error handling tunnel polling error callback", { tunnelId, e });
|
|
@@ -1257,6 +1271,14 @@ var init_TunnelManager = __esm({
|
|
|
1257
1271
|
const msg = typeof error === "string" ? error : String(error);
|
|
1258
1272
|
const isFatal = true;
|
|
1259
1273
|
logger.debug("Tunnel reported error", { tunnelId, errorNo, errorMsg: msg, recoverable });
|
|
1274
|
+
const managedTunnel = this.tunnelsByTunnelId.get(tunnelId);
|
|
1275
|
+
if (managedTunnel) {
|
|
1276
|
+
managedTunnel.lastError = {
|
|
1277
|
+
message: msg,
|
|
1278
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1279
|
+
isFatal: false
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1260
1282
|
this.notifyErrorListeners(tunnelId, msg, isFatal);
|
|
1261
1283
|
} catch (e) {
|
|
1262
1284
|
logger.warn("Error handling tunnel error callback", { tunnelId, e });
|
|
@@ -1938,6 +1960,9 @@ var init_handler = __esm({
|
|
|
1938
1960
|
status.starttimestamp = managed.startedAt || "";
|
|
1939
1961
|
status.endtimestamp = managed.stoppedAt || "";
|
|
1940
1962
|
}
|
|
1963
|
+
if (managed?.lastError) {
|
|
1964
|
+
status.lastError = managed.lastError;
|
|
1965
|
+
}
|
|
1941
1966
|
} catch (e) {
|
|
1942
1967
|
}
|
|
1943
1968
|
return status;
|
|
@@ -3388,16 +3413,19 @@ function parseLocalTunnelAddr(finalConfig, values) {
|
|
|
3388
3413
|
if (!Array.isArray(values.L) || values.L.length === 0) return null;
|
|
3389
3414
|
const firstL = values.L[0];
|
|
3390
3415
|
const parts = firstL.split(":");
|
|
3416
|
+
let lp;
|
|
3391
3417
|
if (parts.length === 3) {
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
} else {
|
|
3396
|
-
return new Error(`Invalid debugger port ${lp}`);
|
|
3397
|
-
}
|
|
3418
|
+
lp = parseInt(parts[0], 10);
|
|
3419
|
+
} else if (parts.length === 4) {
|
|
3420
|
+
lp = parseInt(parts[1], 10);
|
|
3398
3421
|
} else {
|
|
3399
3422
|
return new Error("Incorrect command line arguments: web debugger address incorrect. Please use '-h' option for help.");
|
|
3400
3423
|
}
|
|
3424
|
+
if (!Number.isNaN(lp) && isValidPort(lp)) {
|
|
3425
|
+
finalConfig.webDebugger = `localhost:${lp}`;
|
|
3426
|
+
} else {
|
|
3427
|
+
return new Error(`Invalid debugger port ${lp}`);
|
|
3428
|
+
}
|
|
3401
3429
|
}
|
|
3402
3430
|
function parseDebugger(finalConfig, values) {
|
|
3403
3431
|
let dbg = values.debugger;
|
package/dist/index.d.cts
CHANGED
|
@@ -49,6 +49,7 @@ interface Status {
|
|
|
49
49
|
starttimestamp: string;
|
|
50
50
|
endtimestamp: string;
|
|
51
51
|
warnings: Warning[];
|
|
52
|
+
lastError?: lastError;
|
|
52
53
|
}
|
|
53
54
|
type FinalConfig = (TunnelConfigurationV1) & {
|
|
54
55
|
conf?: string;
|
|
@@ -95,6 +96,12 @@ interface ManagedTunnel {
|
|
|
95
96
|
startedAt?: string | null;
|
|
96
97
|
stoppedAt?: string | null;
|
|
97
98
|
autoReconnect?: boolean;
|
|
99
|
+
lastError: lastError;
|
|
100
|
+
}
|
|
101
|
+
interface lastError {
|
|
102
|
+
message: string;
|
|
103
|
+
timestamp: string;
|
|
104
|
+
isFatal: boolean;
|
|
98
105
|
}
|
|
99
106
|
interface TunnelList {
|
|
100
107
|
tunnelid: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ interface Status {
|
|
|
49
49
|
starttimestamp: string;
|
|
50
50
|
endtimestamp: string;
|
|
51
51
|
warnings: Warning[];
|
|
52
|
+
lastError?: lastError;
|
|
52
53
|
}
|
|
53
54
|
type FinalConfig = (TunnelConfigurationV1) & {
|
|
54
55
|
conf?: string;
|
|
@@ -95,6 +96,12 @@ interface ManagedTunnel {
|
|
|
95
96
|
startedAt?: string | null;
|
|
96
97
|
stoppedAt?: string | null;
|
|
97
98
|
autoReconnect?: boolean;
|
|
99
|
+
lastError: lastError;
|
|
100
|
+
}
|
|
101
|
+
interface lastError {
|
|
102
|
+
message: string;
|
|
103
|
+
timestamp: string;
|
|
104
|
+
isFatal: boolean;
|
|
98
105
|
}
|
|
99
106
|
interface TunnelList {
|
|
100
107
|
tunnelid: string;
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getRemoteManagementState,
|
|
10
10
|
initiateRemoteManagement,
|
|
11
11
|
printer_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-MBN3YBO4.js";
|
|
13
13
|
import {
|
|
14
14
|
enablePackageLogging
|
|
15
15
|
} from "./chunk-HUN2MRZO.js";
|
|
@@ -104,7 +104,7 @@ async function verifyAndLoad() {
|
|
|
104
104
|
process.exit(1);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
await import("./main-
|
|
107
|
+
await import("./main-QQGE7G67.js");
|
|
108
108
|
}
|
|
109
109
|
verifyAndLoad().catch((err) => {
|
|
110
110
|
printer_default.error(`Failed to start CLI:, ${err}`);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isValidPort,
|
|
11
11
|
parseRemoteManagement,
|
|
12
12
|
printer_default
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-MBN3YBO4.js";
|
|
14
14
|
import {
|
|
15
15
|
configureLogger,
|
|
16
16
|
enablePackageLogging,
|
|
@@ -524,16 +524,19 @@ function parseLocalTunnelAddr(finalConfig, values) {
|
|
|
524
524
|
if (!Array.isArray(values.L) || values.L.length === 0) return null;
|
|
525
525
|
const firstL = values.L[0];
|
|
526
526
|
const parts = firstL.split(":");
|
|
527
|
+
let lp;
|
|
527
528
|
if (parts.length === 3) {
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
} else {
|
|
532
|
-
return new Error(`Invalid debugger port ${lp}`);
|
|
533
|
-
}
|
|
529
|
+
lp = parseInt(parts[0], 10);
|
|
530
|
+
} else if (parts.length === 4) {
|
|
531
|
+
lp = parseInt(parts[1], 10);
|
|
534
532
|
} else {
|
|
535
533
|
return new Error("Incorrect command line arguments: web debugger address incorrect. Please use '-h' option for help.");
|
|
536
534
|
}
|
|
535
|
+
if (!Number.isNaN(lp) && isValidPort(lp)) {
|
|
536
|
+
finalConfig.webDebugger = `localhost:${lp}`;
|
|
537
|
+
} else {
|
|
538
|
+
return new Error(`Invalid debugger port ${lp}`);
|
|
539
|
+
}
|
|
537
540
|
}
|
|
538
541
|
function parseDebugger(finalConfig, values) {
|
|
539
542
|
let dbg = values.debugger;
|