vibelet 1.2.77 → 1.2.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/runtime-version.cjs +1 -1
- package/dist/vibelet.mjs +222 -197
- package/package.json +1 -1
package/dist/runtime-version.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=require("node:fs"),n=require("node:path"),c="@vibelet/cli";function a(e){try{let r=JSON.parse((0,s.readFileSync)(e,"utf8"));if(r.name===c&&typeof r.version=="string"&&r.version.length>0)return r.version}catch{}return null}function p(){return"1.2.
|
|
1
|
+
var s=require("node:fs"),n=require("node:path"),c="@vibelet/cli";function a(e){try{let r=JSON.parse((0,s.readFileSync)(e,"utf8"));if(r.name===c&&typeof r.version=="string"&&r.version.length>0)return r.version}catch{}return null}function p(){return"1.2.78"}var i=p();process.stdout.write(`${i}
|
|
2
2
|
`);
|
package/dist/vibelet.mjs
CHANGED
|
@@ -6224,12 +6224,27 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("zlib");
|
|
|
6224
6224
|
|
|
6225
6225
|
/***/ }),
|
|
6226
6226
|
|
|
6227
|
-
/***/
|
|
6227
|
+
/***/ 2155:
|
|
6228
6228
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
6229
6229
|
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6230
|
+
|
|
6231
|
+
// EXPORTS
|
|
6232
|
+
__nccwpck_require__.d(__webpack_exports__, {
|
|
6233
|
+
vD: () => (/* binding */ clearTunnelState),
|
|
6234
|
+
QQ: () => (/* binding */ getAliveTunnel),
|
|
6235
|
+
DH: () => (/* binding */ startTunnel),
|
|
6236
|
+
HM: () => (/* binding */ stopTunnel)
|
|
6237
|
+
});
|
|
6238
|
+
|
|
6239
|
+
// UNUSED EXPORTS: isProcessAlive, loadTunnelState, readCloudflaredLog, saveTunnelState
|
|
6240
|
+
|
|
6241
|
+
// EXTERNAL MODULE: external "node:child_process"
|
|
6242
|
+
var external_node_child_process_ = __nccwpck_require__(1421);
|
|
6243
|
+
// EXTERNAL MODULE: external "node:fs"
|
|
6244
|
+
var external_node_fs_ = __nccwpck_require__(3024);
|
|
6245
|
+
// EXTERNAL MODULE: external "node:path"
|
|
6246
|
+
var external_node_path_ = __nccwpck_require__(6760);
|
|
6247
|
+
;// CONCATENATED MODULE: ./bin/cloudflared-quick-tunnel.mjs
|
|
6233
6248
|
const QUICK_TUNNEL_URL_PATTERN = /https:\/\/[a-z0-9-]+\.trycloudflare\.com(?=$|[\s"',)\]])/g;
|
|
6234
6249
|
|
|
6235
6250
|
function extractQuickTunnelUrl(logContent) {
|
|
@@ -6242,27 +6257,8 @@ function extractQuickTunnelUrl(logContent) {
|
|
|
6242
6257
|
return match?.[0] ?? null;
|
|
6243
6258
|
}
|
|
6244
6259
|
|
|
6245
|
-
|
|
6246
|
-
/***/ }),
|
|
6247
|
-
|
|
6248
|
-
/***/ 3006:
|
|
6249
|
-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
// EXPORTS
|
|
6253
|
-
__nccwpck_require__.d(__webpack_exports__, {
|
|
6254
|
-
Ic: () => (/* binding */ formatCloudflaredFailureMessage),
|
|
6255
|
-
Wo: () => (/* binding */ resolveCloudflaredLaunchSpec)
|
|
6256
|
-
});
|
|
6257
|
-
|
|
6258
|
-
// UNUSED EXPORTS: findExecutableInPath, findExecutablesInPath, resolveInstalledCloudflaredCliPath, summarizeCloudflaredLog
|
|
6259
|
-
|
|
6260
6260
|
;// CONCATENATED MODULE: external "node:module"
|
|
6261
6261
|
const external_node_module_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:module");
|
|
6262
|
-
// EXTERNAL MODULE: external "node:fs"
|
|
6263
|
-
var external_node_fs_ = __nccwpck_require__(3024);
|
|
6264
|
-
// EXTERNAL MODULE: external "node:path"
|
|
6265
|
-
var external_node_path_ = __nccwpck_require__(6760);
|
|
6266
6262
|
;// CONCATENATED MODULE: ./bin/cloudflared-resolver.mjs
|
|
6267
6263
|
|
|
6268
6264
|
|
|
@@ -6463,6 +6459,199 @@ function formatCloudflaredFailureMessage({
|
|
|
6463
6459
|
return `cloudflared exited before producing a tunnel URL${launchSuffix}. Check ${logPath}.`;
|
|
6464
6460
|
}
|
|
6465
6461
|
|
|
6462
|
+
;// CONCATENATED MODULE: ./bin/cloudflared-tunnel-manager.mjs
|
|
6463
|
+
|
|
6464
|
+
|
|
6465
|
+
|
|
6466
|
+
|
|
6467
|
+
|
|
6468
|
+
|
|
6469
|
+
function isProcessAlive(pid) {
|
|
6470
|
+
try {
|
|
6471
|
+
process.kill(pid, 0);
|
|
6472
|
+
return true;
|
|
6473
|
+
} catch {
|
|
6474
|
+
return false;
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
|
|
6478
|
+
function loadTunnelState({ tunnelStatePath }) {
|
|
6479
|
+
try {
|
|
6480
|
+
return JSON.parse((0,external_node_fs_.readFileSync)(tunnelStatePath, 'utf8'));
|
|
6481
|
+
} catch {
|
|
6482
|
+
return null;
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
|
|
6486
|
+
function saveTunnelState({ tunnelStatePath, pid, url }) {
|
|
6487
|
+
(0,external_node_fs_.mkdirSync)((0,external_node_path_.dirname)(tunnelStatePath), { recursive: true });
|
|
6488
|
+
(0,external_node_fs_.writeFileSync)(tunnelStatePath, JSON.stringify({ pid, url }, null, 2) + '\n', 'utf8');
|
|
6489
|
+
}
|
|
6490
|
+
|
|
6491
|
+
function clearTunnelState({ tunnelStatePath }) {
|
|
6492
|
+
(0,external_node_fs_.rmSync)(tunnelStatePath, { force: true });
|
|
6493
|
+
}
|
|
6494
|
+
|
|
6495
|
+
function stopTunnel({
|
|
6496
|
+
tunnelStatePath,
|
|
6497
|
+
isAlive = isProcessAlive,
|
|
6498
|
+
killProcess = process.kill,
|
|
6499
|
+
}) {
|
|
6500
|
+
const state = loadTunnelState({ tunnelStatePath });
|
|
6501
|
+
if (state?.pid && isAlive(state.pid)) {
|
|
6502
|
+
try { killProcess(state.pid, 'SIGTERM'); } catch { /* already dead */ }
|
|
6503
|
+
}
|
|
6504
|
+
clearTunnelState({ tunnelStatePath });
|
|
6505
|
+
}
|
|
6506
|
+
|
|
6507
|
+
function getAliveTunnel({
|
|
6508
|
+
tunnelStatePath,
|
|
6509
|
+
isAlive = isProcessAlive,
|
|
6510
|
+
}) {
|
|
6511
|
+
const state = loadTunnelState({ tunnelStatePath });
|
|
6512
|
+
if (state?.pid && state?.url && isAlive(state.pid)) {
|
|
6513
|
+
return state;
|
|
6514
|
+
}
|
|
6515
|
+
return null;
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
function readCloudflaredLog(logPath) {
|
|
6519
|
+
try {
|
|
6520
|
+
return (0,external_node_fs_.readFileSync)(logPath, 'utf8');
|
|
6521
|
+
} catch {
|
|
6522
|
+
return '';
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
|
|
6526
|
+
function startTunnel({
|
|
6527
|
+
port,
|
|
6528
|
+
logDir,
|
|
6529
|
+
tunnelStatePath,
|
|
6530
|
+
resolveLaunchSpec = resolveCloudflaredLaunchSpec,
|
|
6531
|
+
}) {
|
|
6532
|
+
return new Promise((resolve, reject) => {
|
|
6533
|
+
const logPath = (0,external_node_path_.join)(logDir, 'tunnel.stderr.log');
|
|
6534
|
+
(0,external_node_fs_.mkdirSync)(logDir, { recursive: true });
|
|
6535
|
+
|
|
6536
|
+
const launchSpec = resolveLaunchSpec();
|
|
6537
|
+
|
|
6538
|
+
// Truncate first so URL polling cannot match a stale quick-tunnel URL.
|
|
6539
|
+
(0,external_node_fs_.writeFileSync)(logPath, '', 'utf8');
|
|
6540
|
+
const stdoutLogFd = (0,external_node_fs_.openSync)(logPath, 'a');
|
|
6541
|
+
const stderrLogFd = (0,external_node_fs_.openSync)(logPath, 'a');
|
|
6542
|
+
let child;
|
|
6543
|
+
try {
|
|
6544
|
+
child = (0,external_node_child_process_.spawn)(launchSpec.command, [
|
|
6545
|
+
...launchSpec.args,
|
|
6546
|
+
'tunnel',
|
|
6547
|
+
'--protocol',
|
|
6548
|
+
'http2',
|
|
6549
|
+
'--url',
|
|
6550
|
+
`http://localhost:${port}`,
|
|
6551
|
+
], {
|
|
6552
|
+
detached: true,
|
|
6553
|
+
stdio: ['ignore', stdoutLogFd, stderrLogFd],
|
|
6554
|
+
windowsHide: true,
|
|
6555
|
+
...(launchSpec.shell ? { shell: true } : {}),
|
|
6556
|
+
});
|
|
6557
|
+
} catch (err) {
|
|
6558
|
+
try { (0,external_node_fs_.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
6559
|
+
try { (0,external_node_fs_.closeSync)(stderrLogFd); } catch { /* */ }
|
|
6560
|
+
reject(new Error(formatCloudflaredFailureMessage({
|
|
6561
|
+
launchSpec,
|
|
6562
|
+
logContent: readCloudflaredLog(logPath),
|
|
6563
|
+
logPath,
|
|
6564
|
+
err,
|
|
6565
|
+
phase: 'spawn',
|
|
6566
|
+
})));
|
|
6567
|
+
return;
|
|
6568
|
+
}
|
|
6569
|
+
child.unref();
|
|
6570
|
+
try { (0,external_node_fs_.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
6571
|
+
try { (0,external_node_fs_.closeSync)(stderrLogFd); } catch { /* */ }
|
|
6572
|
+
|
|
6573
|
+
const pid = child.pid;
|
|
6574
|
+
let url = null;
|
|
6575
|
+
let settled = false;
|
|
6576
|
+
let childExited = false;
|
|
6577
|
+
let poll;
|
|
6578
|
+
let timeout;
|
|
6579
|
+
|
|
6580
|
+
function settle(callback, value) {
|
|
6581
|
+
if (settled) {
|
|
6582
|
+
return;
|
|
6583
|
+
}
|
|
6584
|
+
settled = true;
|
|
6585
|
+
clearInterval(poll);
|
|
6586
|
+
clearTimeout(timeout);
|
|
6587
|
+
callback(value);
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6590
|
+
timeout = setTimeout(() => {
|
|
6591
|
+
if (!url) {
|
|
6592
|
+
try { process.kill(pid, 'SIGTERM'); } catch { /* */ }
|
|
6593
|
+
settle(reject, new Error(formatCloudflaredFailureMessage({
|
|
6594
|
+
launchSpec,
|
|
6595
|
+
logContent: readCloudflaredLog(logPath),
|
|
6596
|
+
logPath,
|
|
6597
|
+
phase: 'timeout',
|
|
6598
|
+
})));
|
|
6599
|
+
}
|
|
6600
|
+
}, launchSpec.urlTimeoutMs);
|
|
6601
|
+
|
|
6602
|
+
poll = setInterval(() => {
|
|
6603
|
+
try {
|
|
6604
|
+
const content = (0,external_node_fs_.readFileSync)(logPath, 'utf8');
|
|
6605
|
+
const tunnelUrl = extractQuickTunnelUrl(content);
|
|
6606
|
+
if (tunnelUrl) {
|
|
6607
|
+
url = tunnelUrl;
|
|
6608
|
+
saveTunnelState({ tunnelStatePath, pid, url });
|
|
6609
|
+
settle(resolve, { pid, url });
|
|
6610
|
+
return;
|
|
6611
|
+
}
|
|
6612
|
+
if (childExited) {
|
|
6613
|
+
settle(reject, new Error(formatCloudflaredFailureMessage({
|
|
6614
|
+
launchSpec,
|
|
6615
|
+
logContent: content,
|
|
6616
|
+
logPath,
|
|
6617
|
+
phase: 'exit',
|
|
6618
|
+
})));
|
|
6619
|
+
}
|
|
6620
|
+
} catch { /* file not ready yet */ }
|
|
6621
|
+
}, 300);
|
|
6622
|
+
|
|
6623
|
+
child.once('exit', () => {
|
|
6624
|
+
childExited = true;
|
|
6625
|
+
if (!url) {
|
|
6626
|
+
const content = readCloudflaredLog(logPath);
|
|
6627
|
+
const tunnelUrl = extractQuickTunnelUrl(content);
|
|
6628
|
+
if (tunnelUrl) {
|
|
6629
|
+
url = tunnelUrl;
|
|
6630
|
+
saveTunnelState({ tunnelStatePath, pid, url });
|
|
6631
|
+
settle(resolve, { pid, url });
|
|
6632
|
+
return;
|
|
6633
|
+
}
|
|
6634
|
+
settle(reject, new Error(formatCloudflaredFailureMessage({
|
|
6635
|
+
launchSpec,
|
|
6636
|
+
logContent: content,
|
|
6637
|
+
logPath,
|
|
6638
|
+
phase: 'exit',
|
|
6639
|
+
})));
|
|
6640
|
+
}
|
|
6641
|
+
});
|
|
6642
|
+
|
|
6643
|
+
child.on('error', (err) => {
|
|
6644
|
+
settle(reject, new Error(formatCloudflaredFailureMessage({
|
|
6645
|
+
launchSpec,
|
|
6646
|
+
logContent: readCloudflaredLog(logPath),
|
|
6647
|
+
logPath,
|
|
6648
|
+
err,
|
|
6649
|
+
phase: 'spawn',
|
|
6650
|
+
})));
|
|
6651
|
+
});
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6466
6655
|
|
|
6467
6656
|
/***/ }),
|
|
6468
6657
|
|
|
@@ -7027,8 +7216,7 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
7027
7216
|
/* harmony import */ var node_url__WEBPACK_IMPORTED_MODULE_4__ = __nccwpck_require__(3136);
|
|
7028
7217
|
/* harmony import */ var qrcode__WEBPACK_IMPORTED_MODULE_5__ = __nccwpck_require__(1302);
|
|
7029
7218
|
/* harmony import */ var _vibelet_cli_args_mjs__WEBPACK_IMPORTED_MODULE_12__ = __nccwpck_require__(3428);
|
|
7030
|
-
/* harmony import */ var
|
|
7031
|
-
/* harmony import */ var _cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(3006);
|
|
7219
|
+
/* harmony import */ var _cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__ = __nccwpck_require__(2155);
|
|
7032
7220
|
/* harmony import */ var _vibelet_launchd_mjs__WEBPACK_IMPORTED_MODULE_9__ = __nccwpck_require__(2927);
|
|
7033
7221
|
/* harmony import */ var _linux_systemd_mjs__WEBPACK_IMPORTED_MODULE_7__ = __nccwpck_require__(5400);
|
|
7034
7222
|
/* harmony import */ var _vibelet_stop_logic_mjs__WEBPACK_IMPORTED_MODULE_10__ = __nccwpck_require__(9917);
|
|
@@ -7049,7 +7237,6 @@ __nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependen
|
|
|
7049
7237
|
|
|
7050
7238
|
|
|
7051
7239
|
|
|
7052
|
-
|
|
7053
7240
|
// ─── Paths & constants ─────────────────────────────────────────────────────────
|
|
7054
7241
|
|
|
7055
7242
|
const rootDir = (0,node_path__WEBPACK_IMPORTED_MODULE_3__.resolve)((0,node_path__WEBPACK_IMPORTED_MODULE_3__.dirname)((0,node_url__WEBPACK_IMPORTED_MODULE_4__.fileURLToPath)(import.meta.url)), '..');
|
|
@@ -7960,170 +8147,8 @@ function clearRelayConfig() {
|
|
|
7960
8147
|
|
|
7961
8148
|
// ─── Tunnel management ──────────────────────────────────────────────────────────
|
|
7962
8149
|
|
|
7963
|
-
function
|
|
7964
|
-
|
|
7965
|
-
return JSON.parse((0,node_fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync)(tunnelStatePath, 'utf8'));
|
|
7966
|
-
} catch {
|
|
7967
|
-
return null;
|
|
7968
|
-
}
|
|
7969
|
-
}
|
|
7970
|
-
|
|
7971
|
-
function saveTunnelState(pid, url) {
|
|
7972
|
-
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync)(vibeletDir, { recursive: true });
|
|
7973
|
-
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync)(tunnelStatePath, JSON.stringify({ pid, url }, null, 2) + '\n', 'utf8');
|
|
7974
|
-
}
|
|
7975
|
-
|
|
7976
|
-
function clearTunnelState() {
|
|
7977
|
-
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.rmSync)(tunnelStatePath, { force: true });
|
|
7978
|
-
}
|
|
7979
|
-
|
|
7980
|
-
function stopTunnel() {
|
|
7981
|
-
const state = loadTunnelState();
|
|
7982
|
-
if (state?.pid && isProcessAlive(state.pid)) {
|
|
7983
|
-
try { process.kill(state.pid, 'SIGTERM'); } catch { /* already dead */ }
|
|
7984
|
-
}
|
|
7985
|
-
clearTunnelState();
|
|
7986
|
-
}
|
|
7987
|
-
|
|
7988
|
-
function getAliveTunnel() {
|
|
7989
|
-
const state = loadTunnelState();
|
|
7990
|
-
if (state?.pid && state?.url && isProcessAlive(state.pid)) {
|
|
7991
|
-
return state;
|
|
7992
|
-
}
|
|
7993
|
-
return null;
|
|
7994
|
-
}
|
|
7995
|
-
|
|
7996
|
-
function readCloudflaredLog(logPath) {
|
|
7997
|
-
try {
|
|
7998
|
-
return (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync)(logPath, 'utf8');
|
|
7999
|
-
} catch {
|
|
8000
|
-
return '';
|
|
8001
|
-
}
|
|
8002
|
-
}
|
|
8003
|
-
|
|
8004
|
-
function startTunnel() {
|
|
8005
|
-
return new Promise((resolve, reject) => {
|
|
8006
|
-
const logPath = (0,node_path__WEBPACK_IMPORTED_MODULE_3__.join)(logDir, 'tunnel.stderr.log');
|
|
8007
|
-
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync)(logDir, { recursive: true });
|
|
8008
|
-
|
|
8009
|
-
const launchSpec = (0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .resolveCloudflaredLaunchSpec */ .Wo)();
|
|
8010
|
-
|
|
8011
|
-
// Strategy: start cloudflared with output to log files (so it survives detach),
|
|
8012
|
-
// then tail the log to capture the URL.
|
|
8013
|
-
// Truncate log so we don't match a stale URL from a previous run.
|
|
8014
|
-
(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync)(logPath, '', 'utf8');
|
|
8015
|
-
const stdoutLogFd = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.openSync)(logPath, 'a');
|
|
8016
|
-
const stderrLogFd = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.openSync)(logPath, 'a');
|
|
8017
|
-
let child;
|
|
8018
|
-
try {
|
|
8019
|
-
child = (0,node_child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)(launchSpec.command, [
|
|
8020
|
-
...launchSpec.args,
|
|
8021
|
-
'tunnel',
|
|
8022
|
-
'--protocol',
|
|
8023
|
-
'http2',
|
|
8024
|
-
'--url',
|
|
8025
|
-
`http://localhost:${port}`,
|
|
8026
|
-
], {
|
|
8027
|
-
detached: true,
|
|
8028
|
-
stdio: ['ignore', stdoutLogFd, stderrLogFd],
|
|
8029
|
-
windowsHide: true,
|
|
8030
|
-
...(launchSpec.shell ? { shell: true } : {}),
|
|
8031
|
-
});
|
|
8032
|
-
} catch (err) {
|
|
8033
|
-
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
8034
|
-
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stderrLogFd); } catch { /* */ }
|
|
8035
|
-
reject(new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
8036
|
-
launchSpec,
|
|
8037
|
-
logContent: readCloudflaredLog(logPath),
|
|
8038
|
-
logPath,
|
|
8039
|
-
err,
|
|
8040
|
-
phase: 'spawn',
|
|
8041
|
-
})));
|
|
8042
|
-
return;
|
|
8043
|
-
}
|
|
8044
|
-
child.unref();
|
|
8045
|
-
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stdoutLogFd); } catch { /* */ }
|
|
8046
|
-
try { (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.closeSync)(stderrLogFd); } catch { /* */ }
|
|
8047
|
-
|
|
8048
|
-
const pid = child.pid;
|
|
8049
|
-
let url = null;
|
|
8050
|
-
let settled = false;
|
|
8051
|
-
let childExited = false;
|
|
8052
|
-
|
|
8053
|
-
function settle(callback, value) {
|
|
8054
|
-
if (settled) {
|
|
8055
|
-
return;
|
|
8056
|
-
}
|
|
8057
|
-
settled = true;
|
|
8058
|
-
clearInterval(poll);
|
|
8059
|
-
clearTimeout(timeout);
|
|
8060
|
-
callback(value);
|
|
8061
|
-
}
|
|
8062
|
-
|
|
8063
|
-
const timeout = setTimeout(() => {
|
|
8064
|
-
if (!url) {
|
|
8065
|
-
try { process.kill(pid, 'SIGTERM'); } catch { /* */ }
|
|
8066
|
-
settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
8067
|
-
launchSpec,
|
|
8068
|
-
logContent: readCloudflaredLog(logPath),
|
|
8069
|
-
logPath,
|
|
8070
|
-
phase: 'timeout',
|
|
8071
|
-
})));
|
|
8072
|
-
}
|
|
8073
|
-
}, launchSpec.urlTimeoutMs);
|
|
8074
|
-
|
|
8075
|
-
// Poll the log file for the tunnel URL
|
|
8076
|
-
const poll = setInterval(() => {
|
|
8077
|
-
try {
|
|
8078
|
-
const content = (0,node_fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync)(logPath, 'utf8');
|
|
8079
|
-
const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_13__/* .extractQuickTunnelUrl */ .k)(content);
|
|
8080
|
-
if (tunnelUrl) {
|
|
8081
|
-
url = tunnelUrl;
|
|
8082
|
-
saveTunnelState(pid, url);
|
|
8083
|
-
settle(resolve, { pid, url });
|
|
8084
|
-
return;
|
|
8085
|
-
}
|
|
8086
|
-
if (childExited) {
|
|
8087
|
-
settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
8088
|
-
launchSpec,
|
|
8089
|
-
logContent: content,
|
|
8090
|
-
logPath,
|
|
8091
|
-
phase: 'exit',
|
|
8092
|
-
})));
|
|
8093
|
-
}
|
|
8094
|
-
} catch { /* file not ready yet */ }
|
|
8095
|
-
}, 300);
|
|
8096
|
-
|
|
8097
|
-
child.once('exit', () => {
|
|
8098
|
-
childExited = true;
|
|
8099
|
-
if (!url) {
|
|
8100
|
-
const content = readCloudflaredLog(logPath);
|
|
8101
|
-
const tunnelUrl = (0,_cloudflared_quick_tunnel_mjs__WEBPACK_IMPORTED_MODULE_13__/* .extractQuickTunnelUrl */ .k)(content);
|
|
8102
|
-
if (tunnelUrl) {
|
|
8103
|
-
url = tunnelUrl;
|
|
8104
|
-
saveTunnelState(pid, url);
|
|
8105
|
-
settle(resolve, { pid, url });
|
|
8106
|
-
return;
|
|
8107
|
-
}
|
|
8108
|
-
settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
8109
|
-
launchSpec,
|
|
8110
|
-
logContent: content,
|
|
8111
|
-
logPath,
|
|
8112
|
-
phase: 'exit',
|
|
8113
|
-
})));
|
|
8114
|
-
}
|
|
8115
|
-
});
|
|
8116
|
-
|
|
8117
|
-
child.on('error', (err) => {
|
|
8118
|
-
settle(reject, new Error((0,_cloudflared_resolver_mjs__WEBPACK_IMPORTED_MODULE_6__/* .formatCloudflaredFailureMessage */ .Ic)({
|
|
8119
|
-
launchSpec,
|
|
8120
|
-
logContent: readCloudflaredLog(logPath),
|
|
8121
|
-
logPath,
|
|
8122
|
-
err,
|
|
8123
|
-
phase: 'spawn',
|
|
8124
|
-
})));
|
|
8125
|
-
});
|
|
8126
|
-
});
|
|
8150
|
+
function getTunnelManagerOptions() {
|
|
8151
|
+
return { tunnelStatePath, isAlive: isProcessAlive };
|
|
8127
8152
|
}
|
|
8128
8153
|
|
|
8129
8154
|
async function main() {
|
|
@@ -8171,20 +8196,20 @@ async function main() {
|
|
|
8171
8196
|
}
|
|
8172
8197
|
|
|
8173
8198
|
if (shouldManageTunnel) {
|
|
8174
|
-
const existing = forceFlag ? null : getAliveTunnel();
|
|
8199
|
+
const existing = forceFlag ? null : (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .getAliveTunnel */ .QQ)(getTunnelManagerOptions());
|
|
8175
8200
|
if (existing) {
|
|
8176
8201
|
process.stdout.write(`Reusing tunnel: ${existing.url} (pid ${existing.pid})\n`);
|
|
8177
8202
|
saveRelayConfig(existing.url);
|
|
8178
8203
|
} else {
|
|
8179
|
-
if (forceFlag) stopTunnel();
|
|
8204
|
+
if (forceFlag) (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .stopTunnel */ .HM)(getTunnelManagerOptions());
|
|
8180
8205
|
process.stdout.write('Starting Cloudflare Tunnel...\n');
|
|
8181
8206
|
try {
|
|
8182
|
-
const tunnel = await startTunnel();
|
|
8207
|
+
const tunnel = await (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .startTunnel */ .DH)({ port, logDir, tunnelStatePath });
|
|
8183
8208
|
process.stdout.write(`Tunnel ready: ${tunnel.url}\n`);
|
|
8184
8209
|
saveRelayConfig(tunnel.url);
|
|
8185
8210
|
} catch (err) {
|
|
8186
8211
|
managedTunnelFailed = true;
|
|
8187
|
-
clearTunnelState();
|
|
8212
|
+
(0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .clearTunnelState */ .vD)({ tunnelStatePath });
|
|
8188
8213
|
clearRelayConfig();
|
|
8189
8214
|
const message = err instanceof Error ? err.message : String(err);
|
|
8190
8215
|
process.stderr.write(`${message}\n`);
|
|
@@ -8229,9 +8254,9 @@ async function main() {
|
|
|
8229
8254
|
// close sessions and flush logs before the service manager kills it.
|
|
8230
8255
|
await stopRunningDaemon(backend);
|
|
8231
8256
|
// Also stop tunnel if running
|
|
8232
|
-
const tunnelState = getAliveTunnel();
|
|
8257
|
+
const tunnelState = (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .getAliveTunnel */ .QQ)(getTunnelManagerOptions());
|
|
8233
8258
|
if (tunnelState) {
|
|
8234
|
-
stopTunnel();
|
|
8259
|
+
(0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .stopTunnel */ .HM)(getTunnelManagerOptions());
|
|
8235
8260
|
process.stdout.write('Tunnel stopped.\n');
|
|
8236
8261
|
}
|
|
8237
8262
|
process.stdout.write('Daemon stopped.\n');
|
|
@@ -8241,7 +8266,7 @@ async function main() {
|
|
|
8241
8266
|
if (command === 'status') {
|
|
8242
8267
|
process.stdout.write(`Service (${backend.name}): ${backend.statusLabel()}\n`);
|
|
8243
8268
|
process.stdout.write(`Runtime: ${(0,node_fs__WEBPACK_IMPORTED_MODULE_1__.existsSync)(runtimeDaemonEntryPath) ? runtimeDaemonEntryPath : 'not installed'}\n`);
|
|
8244
|
-
const tunnelState = getAliveTunnel();
|
|
8269
|
+
const tunnelState = (0,_cloudflared_tunnel_manager_mjs__WEBPACK_IMPORTED_MODULE_6__/* .getAliveTunnel */ .QQ)(getTunnelManagerOptions());
|
|
8245
8270
|
if (tunnelState) {
|
|
8246
8271
|
process.stdout.write(`Tunnel: ${tunnelState.url} (pid ${tunnelState.pid})\n`);
|
|
8247
8272
|
}
|