@ghostlytools/cli 1.10.3 → 1.10.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/dist/assets/{api-C4MLg5Rs.js → api-DppWqAP3.js} +12 -12
- package/dist/assets/api-DppWqAP3.js.map +1 -0
- package/dist/assets/{api-BdaxsDvA.js → api-K-i5MrP-.js} +2 -2
- package/dist/assets/{apiKit-BbNaxZGZ.js → apiKit-DFIho4Ev.js} +2 -2
- package/dist/assets/{apiKit-BbNaxZGZ.js.map → apiKit-DFIho4Ev.js.map} +1 -1
- package/dist/assets/{apps-BtGFth7o.js → apps-1MkGMH8m.js} +1 -1
- package/dist/assets/{apps-BluQgEhv.js → apps-yBnbEtfV.js} +3 -3
- package/dist/assets/{apps-BluQgEhv.js.map → apps-yBnbEtfV.js.map} +1 -1
- package/dist/assets/{arkade-DdZx4b_I.js → arkade-bFAS6imn.js} +2 -2
- package/dist/assets/{arkade-DdZx4b_I.js.map → arkade-bFAS6imn.js.map} +1 -1
- package/dist/assets/{backup-I1n7ccz7.js → backup-ejIX59o7.js} +1 -1
- package/dist/assets/{backup-DyDsW7sC.js → backup-vj4J7M3e.js} +6 -6
- package/dist/assets/{backup-DyDsW7sC.js.map → backup-vj4J7M3e.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{blobFiles-BnjN_Vrz.js → blobFiles-XZ9PEXYy.js} +2 -2
- package/dist/assets/{blobFiles-BnjN_Vrz.js.map → blobFiles-XZ9PEXYy.js.map} +1 -1
- package/dist/assets/{buttons-Do7dCku6.js → buttons-BoDMx3Ky.js} +3 -3
- package/dist/assets/{buttons-Do7dCku6.js.map → buttons-BoDMx3Ky.js.map} +1 -1
- package/dist/assets/buttons-DG1CKgAI.js +2 -0
- package/dist/assets/{client-CWsjRiH8.js → client-BQArefYa.js} +10 -4
- package/dist/assets/client-BQArefYa.js.map +1 -0
- package/dist/assets/{codec-DPaXhuYc.js → codec-_MwTUz5E.js} +2 -2
- package/dist/assets/{codec-DPaXhuYc.js.map → codec-_MwTUz5E.js.map} +1 -1
- package/dist/assets/{envelope-5Gu9yGk_.js → envelope-CeZBNGX-.js} +2 -2
- package/dist/assets/{envelope-5Gu9yGk_.js.map → envelope-CeZBNGX-.js.map} +1 -1
- package/dist/assets/{fileBytes-DjBYYyXT.js → fileBytes-BABGEF13.js} +2 -2
- package/dist/assets/{fileBytes-DjBYYyXT.js.map → fileBytes-BABGEF13.js.map} +1 -1
- package/dist/assets/{fileBytes-DMzrIdCu.js → fileBytes-CQQK2uOh.js} +1 -1
- package/dist/assets/{fileBytes-Douk1yOp.js → fileBytes-DqnfKIkj.js} +2 -2
- package/dist/assets/{fileBytes-Douk1yOp.js.map → fileBytes-DqnfKIkj.js.map} +1 -1
- package/dist/assets/fileBytesIdb-BtXATa7j.js +2 -0
- package/dist/assets/{fileBytesIdb-CkClu9YI.js → fileBytesIdb-DrXmDUSy.js} +2 -2
- package/dist/assets/{fileBytesIdb-CkClu9YI.js.map → fileBytesIdb-DrXmDUSy.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-WryQuOgK.js → fileBytesOpfs-udKCzcLe.js} +6 -9
- package/dist/assets/{fileBytesOpfs-WryQuOgK.js.map → fileBytesOpfs-udKCzcLe.js.map} +1 -1
- package/dist/assets/{fixedHosts-PR1BcfKX.js → fixedHosts-B_2Rvyja.js} +3 -3
- package/dist/assets/{fixedHosts-PR1BcfKX.js.map → fixedHosts-B_2Rvyja.js.map} +1 -1
- package/dist/assets/{groupFiles-BuToTMUk.js → groupFiles-D-ZUUHrx.js} +104 -81
- package/dist/assets/groupFiles-D-ZUUHrx.js.map +1 -0
- package/dist/assets/{host-fkQYBvKH.js → host-DFLzzKNr.js} +183 -41
- package/dist/assets/host-DFLzzKNr.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DDCak5PY.js → hyperdhtRelay-CV6qMrom.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DDCak5PY.js.map → hyperdhtRelay-CV6qMrom.js.map} +1 -1
- package/dist/assets/{irohWeb-B4_swKx0.js → irohWeb-C_Wnw7Q9.js} +7 -3
- package/dist/assets/irohWeb-C_Wnw7Q9.js.map +1 -0
- package/dist/assets/{main-ClYsttvY.js → main-xO8MnXxD.js} +19 -19
- package/dist/assets/{main-ClYsttvY.js.map → main-xO8MnXxD.js.map} +1 -1
- package/dist/assets/{mainline-Hsk2SZ1B.js → mainline-Bx184Ixg.js} +94 -2
- package/dist/assets/mainline-Bx184Ixg.js.map +1 -0
- package/dist/assets/{networkReason-C9Hr-hO7.js → networkReason-BlQhTbXk.js} +3 -3
- package/dist/assets/{networkReason-C9Hr-hO7.js.map → networkReason-BlQhTbXk.js.map} +1 -1
- package/dist/assets/{nwc-BbK6qNxS.js → nwc-B3-PHX0L.js} +3 -3
- package/dist/assets/{nwc-BbK6qNxS.js.map → nwc-B3-PHX0L.js.map} +1 -1
- package/dist/assets/{nwcProvider-D_tt2X3Z.js → nwcProvider-BeQBPB2q.js} +2 -2
- package/dist/assets/{nwcProvider-D_tt2X3Z.js.map → nwcProvider-BeQBPB2q.js.map} +1 -1
- package/dist/assets/{ownDid-DkK_jem4.js → ownDid-DAzW-Urb.js} +3 -2
- package/dist/assets/ownDid-DAzW-Urb.js.map +1 -0
- package/dist/assets/{profiles-aV9vaK0B.js → profiles-Bg43mRXu.js} +3 -3
- package/dist/assets/{profiles-aV9vaK0B.js.map → profiles-Bg43mRXu.js.map} +1 -1
- package/dist/assets/{registry-CEjnubep.js → registry-BDnsZJBi.js} +123 -17
- package/dist/assets/registry-BDnsZJBi.js.map +1 -0
- package/dist/assets/{registry-C9T6tYCO.js → registry-CAk2-5BQ.js} +1 -1
- package/dist/assets/{resolve-BBOrN13E.js → resolve-UAfshn6j.js} +2 -2
- package/dist/assets/{resolve-BBOrN13E.js.map → resolve-UAfshn6j.js.map} +1 -1
- package/dist/assets/{server-BJ3T-kx3.js → server-DYdR0_Fj.js} +738 -194
- package/dist/assets/server-DYdR0_Fj.js.map +1 -0
- package/dist/assets/{src-BIdfHB7t.js → src-BTRPAi5X.js} +710 -153
- package/dist/assets/src-BTRPAi5X.js.map +1 -0
- package/dist/assets/{sshForges-CRg-NGld.js → sshForges-KtHK5x1x.js} +2 -2
- package/dist/assets/{sshForges-CRg-NGld.js.map → sshForges-KtHK5x1x.js.map} +1 -1
- package/dist/assets/{translate-b0X61WMI.js → translate-CYuygrvA.js} +2 -2
- package/dist/assets/{translate-b0X61WMI.js.map → translate-CYuygrvA.js.map} +1 -1
- package/dist/assets/{usdt-6CQdfye1.js → usdt-Dw9IENe_.js} +3 -3
- package/dist/assets/{usdt-6CQdfye1.js.map → usdt-Dw9IENe_.js.map} +1 -1
- package/dist/assets/{words-Dk6o6wz4.js → words-BvdNuw_v.js} +3 -3
- package/dist/assets/words-BvdNuw_v.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-C4MLg5Rs.js.map +0 -1
- package/dist/assets/buttons-DpjwXePb.js +0 -2
- package/dist/assets/client-CWsjRiH8.js.map +0 -1
- package/dist/assets/fileBytesIdb-CD5Uv490.js +0 -2
- package/dist/assets/groupFiles-BuToTMUk.js.map +0 -1
- package/dist/assets/host-fkQYBvKH.js.map +0 -1
- package/dist/assets/irohWeb-B4_swKx0.js.map +0 -1
- package/dist/assets/mainline-Hsk2SZ1B.js.map +0 -1
- package/dist/assets/ownDid-DkK_jem4.js.map +0 -1
- package/dist/assets/registry-CEjnubep.js.map +0 -1
- package/dist/assets/server-BJ3T-kx3.js.map +0 -1
- package/dist/assets/src-BIdfHB7t.js.map +0 -1
- package/dist/assets/words-Dk6o6wz4.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { Nu as setLinkTraceSink, Xo as DAEMON_WATCH_PEER_IDLE_MS, _s as callSignalHeardAt, ba as ACTIVE_DHT_POLL_MS, bs as parseCallSignal, ds as CALL_SIGNAL_MAX_AGE_MS, fa as isPublicAddress, fi as checkPushEndpoint, gs as callRtcConfig, hs as buildSdpFromSignal, ms as answersOffer, nd as fromBase64Url, ps as RTC_CONFIG, xs as signalHasVideo, ys as extractParamsFromSdp } from "./src-
|
|
2
|
-
import { o as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-
|
|
1
|
+
import { Nu as setLinkTraceSink, Xo as DAEMON_WATCH_PEER_IDLE_MS, _s as callSignalHeardAt, ba as ACTIVE_DHT_POLL_MS, bs as parseCallSignal, ds as CALL_SIGNAL_MAX_AGE_MS, fa as isPublicAddress, fi as checkPushEndpoint, gs as callRtcConfig, hs as buildSdpFromSignal, ms as answersOffer, nd as fromBase64Url, ps as RTC_CONFIG, xs as signalHasVideo, ys as extractParamsFromSdp } from "./src-BTRPAi5X.js";
|
|
2
|
+
import { o as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-C_Wnw7Q9.js";
|
|
3
3
|
import { r as asCliError, t as CliError } from "./errors-Dt-ZnyOX.js";
|
|
4
|
-
import { s as findChat, u as findOwnNamedChat } from "./apiKit-
|
|
5
|
-
import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-
|
|
6
|
-
import { C as runtimePath, S as privateFolder, _ as startingPath, b as ownProfile, n as RESTORED_MARK, r as acquireLock, y as ownFolder } from "./profiles-
|
|
7
|
-
import { c as proof, d as DEFAULT_RATE, f as PlaybackQueue, g as isCallRate, h as frameSamples, l as removeDaemonSecret, m as frameBytes, o as greeting, p as bytesToMs, s as newDaemonSecret } from "./client-
|
|
4
|
+
import { s as findChat, u as findOwnNamedChat } from "./apiKit-DFIho4Ev.js";
|
|
5
|
+
import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-DppWqAP3.js";
|
|
6
|
+
import { C as runtimePath, S as privateFolder, _ as startingPath, b as ownProfile, n as RESTORED_MARK, r as acquireLock, y as ownFolder } from "./profiles-Bg43mRXu.js";
|
|
7
|
+
import { _ as monotonic, c as proof, d as DEFAULT_RATE, f as PlaybackQueue, g as isCallRate, h as frameSamples, l as removeDaemonSecret, m as frameBytes, o as greeting, p as bytesToMs, s as newDaemonSecret } from "./client-BQArefYa.js";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, truncateSync, writeFileSync, writeSync } from "node:fs";
|
|
10
10
|
import { readFile } from "node:fs/promises";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
13
|
+
import { networkInterfaces } from "node:os";
|
|
13
14
|
import { Readable } from "node:stream";
|
|
14
15
|
import { createServer, isIP } from "node:net";
|
|
15
16
|
import { createInterface } from "node:readline";
|
|
16
|
-
import { lookup } from "node:dns/promises";
|
|
17
17
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
18
18
|
import { Worker } from "node:worker_threads";
|
|
19
19
|
import { request } from "node:https";
|
|
20
|
-
import { lookup
|
|
20
|
+
import { lookup } from "node:dns";
|
|
21
21
|
import { deserialize, serialize } from "node:v8";
|
|
22
22
|
import { IDBFactory, IDBKeyRange, IDBTransaction } from "fake-indexeddb";
|
|
23
23
|
//#region src/announce.ts
|
|
@@ -341,17 +341,21 @@ var CallAudio = class {
|
|
|
341
341
|
lastQuiet = null;
|
|
342
342
|
same = 0;
|
|
343
343
|
quiet = null;
|
|
344
|
+
/** The contact's last packet decoded, what it decoded to, and whether the one before was the same and gave the same (see `decoded`). */
|
|
345
|
+
lastIn = null;
|
|
346
|
+
lastPcm = null;
|
|
347
|
+
steady = false;
|
|
344
348
|
/** Whether the encoder's FEC is on (`OpusCodec.fec`); unknown until the first frame. */
|
|
345
349
|
fecOn;
|
|
346
350
|
stopped = false;
|
|
347
351
|
/** Frames sent and received, for `call list`. */
|
|
348
352
|
sent = 0;
|
|
349
353
|
received = 0;
|
|
350
|
-
/** When the last packet, RTP or RTCP, came from the contact (
|
|
354
|
+
/** When the last packet, RTP or RTCP, came from the contact (on `now`, `monotonic` by default; 0: none yet), for the call's watch. */
|
|
351
355
|
heardAt = 0;
|
|
352
356
|
constructor(options) {
|
|
353
357
|
this.options = options;
|
|
354
|
-
const now = options.now ??
|
|
358
|
+
const now = options.now ?? monotonic;
|
|
355
359
|
this.queue = options.queue ?? new PlaybackQueue(options.rate, now);
|
|
356
360
|
this.writer = new RtpWriter(options.ssrc, options.payloadType);
|
|
357
361
|
this.frame = frameBytes(options.rate);
|
|
@@ -362,7 +366,7 @@ var CallAudio = class {
|
|
|
362
366
|
/** Starts sending, a frame every 20 ms from now on. */
|
|
363
367
|
start() {
|
|
364
368
|
if (this.timer || this.stopped) return;
|
|
365
|
-
this.startedAt = (this.options.now ??
|
|
369
|
+
this.startedAt = (this.options.now ?? monotonic)();
|
|
366
370
|
this.ticks = 0;
|
|
367
371
|
this.schedule();
|
|
368
372
|
}
|
|
@@ -423,25 +427,49 @@ var CallAudio = class {
|
|
|
423
427
|
/** Handles one packet from the track. Exposed for tests. */
|
|
424
428
|
receive(packet) {
|
|
425
429
|
if (this.stopped) return;
|
|
426
|
-
this.heardAt = (this.options.now ??
|
|
430
|
+
this.heardAt = (this.options.now ?? monotonic)();
|
|
427
431
|
if (isRtcp(packet)) return;
|
|
428
432
|
const rtp = parseRtp(packet);
|
|
429
433
|
if (!rtp || rtp.payloadType !== this.options.payloadType) return;
|
|
430
434
|
for (const item of this.reorder.push(rtp)) {
|
|
431
435
|
let pcm;
|
|
432
|
-
if ("lost" in item)
|
|
433
|
-
|
|
436
|
+
if ("lost" in item) {
|
|
437
|
+
this.forgetSteady();
|
|
438
|
+
pcm = this.conceal();
|
|
439
|
+
} else {
|
|
434
440
|
this.concealed = null;
|
|
435
|
-
|
|
436
|
-
pcm = this.options.decoder.decode(item.payload);
|
|
437
|
-
} catch {
|
|
438
|
-
pcm = this.silence;
|
|
439
|
-
}
|
|
441
|
+
pcm = this.decoded(item.payload);
|
|
440
442
|
}
|
|
441
443
|
this.emit(pcm);
|
|
442
444
|
}
|
|
443
445
|
}
|
|
444
446
|
/**
|
|
447
|
+
* A packet of the contact's, decoded. Their silence settles into one packet sent again and again (the CLI's own,
|
|
448
|
+
* `settle`; an app's muted microphone), and the decoder settles with it: once the same packet gave the same audio
|
|
449
|
+
* twice in a row, it is not decoded again while it lasts, and the program gets that audio again. The audio after it
|
|
450
|
+
* decodes to the same bytes as with every packet decoded, and decoding it was half of a quiet call's work on the
|
|
451
|
+
* daemon's thread (libopus in WebAssembly, 50 times a second).
|
|
452
|
+
*/
|
|
453
|
+
decoded(payload) {
|
|
454
|
+
if (this.steady && this.lastIn.equals(payload)) return this.lastPcm;
|
|
455
|
+
let pcm;
|
|
456
|
+
try {
|
|
457
|
+
pcm = this.options.decoder.decode(payload);
|
|
458
|
+
} catch {
|
|
459
|
+
this.forgetSteady();
|
|
460
|
+
return this.silence;
|
|
461
|
+
}
|
|
462
|
+
this.steady = !!this.lastIn?.equals(payload) && !!this.lastPcm?.equals(pcm);
|
|
463
|
+
this.lastIn = Buffer.from(payload);
|
|
464
|
+
this.lastPcm = Buffer.from(pcm);
|
|
465
|
+
return pcm;
|
|
466
|
+
}
|
|
467
|
+
/** A packet lost or unreadable: the decoder moved on without the packet (`decoded`) that came last. */
|
|
468
|
+
forgetSteady() {
|
|
469
|
+
this.lastIn = this.lastPcm = null;
|
|
470
|
+
this.steady = false;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
445
473
|
* A frame for one that never came: the decoder's loss concealment (libopus PLC, what an empty packet decodes to), as
|
|
446
474
|
* the apps' WebRTC stacks do, not a frame of silence (a click). opusscript conceals 60 ms at a time (its largest
|
|
447
475
|
* frame), so one run of it serves the frames of a gap in turn (ReorderBuffer gives MAX_LOST_FRAMES at most).
|
|
@@ -468,7 +496,7 @@ var CallAudio = class {
|
|
|
468
496
|
this.pending = Buffer.from(data);
|
|
469
497
|
}
|
|
470
498
|
schedule() {
|
|
471
|
-
const now = this.options.now ??
|
|
499
|
+
const now = this.options.now ?? monotonic;
|
|
472
500
|
const due = this.startedAt + (this.ticks + 1) * 20;
|
|
473
501
|
this.timer = setTimeout(() => {
|
|
474
502
|
if (this.stopped) return;
|
|
@@ -494,7 +522,7 @@ var CallAudio = class {
|
|
|
494
522
|
* rest of the call.
|
|
495
523
|
*/
|
|
496
524
|
catchUp(late) {
|
|
497
|
-
const now = this.options.now ??
|
|
525
|
+
const now = this.options.now ?? monotonic;
|
|
498
526
|
if (late > 1e3) {
|
|
499
527
|
this.owed = late;
|
|
500
528
|
this.kept = this.ahead;
|
|
@@ -517,7 +545,7 @@ var CallAudio = class {
|
|
|
517
545
|
*/
|
|
518
546
|
drop() {
|
|
519
547
|
if (this.owed <= 0) return;
|
|
520
|
-
if ((this.options.now ??
|
|
548
|
+
if ((this.options.now ?? monotonic)() > this.owedUntil) {
|
|
521
549
|
this.owed = 0;
|
|
522
550
|
return;
|
|
523
551
|
}
|
|
@@ -910,13 +938,14 @@ var CallMedia = class CallMedia {
|
|
|
910
938
|
/**
|
|
911
939
|
* WebKit (Safari, the macOS app) hides its host addresses behind mDNS names, which other machines, and often this
|
|
912
940
|
* one, cannot resolve: then the call can only connect when the contact's own checks reach this side. The log says so,
|
|
913
|
-
* since that is what a call stuck on "connecting" needs to be understood.
|
|
941
|
+
* since that is what a call stuck on "connecting" needs to be understood. The names are not looked up for it: a name
|
|
942
|
+
* nobody answers holds one of the few threads every other lookup of the daemon waits on, for seconds.
|
|
914
943
|
*/
|
|
915
944
|
function mdnsNote(signal, log) {
|
|
916
945
|
for (const candidate of signal.c ?? []) {
|
|
917
946
|
const host = candidate.split(" ")[4];
|
|
918
947
|
if (!host?.endsWith(".local")) continue;
|
|
919
|
-
|
|
948
|
+
log(`${host}: an mDNS name, not resolved here: the call connects only if the contact's checks reach this side`);
|
|
920
949
|
}
|
|
921
950
|
}
|
|
922
951
|
/** Whether a call's ICE servers (`callIceServers`) have a TURN server: its relay candidate is then the one waited for. */
|
|
@@ -1089,7 +1118,7 @@ var CallManager = class {
|
|
|
1089
1118
|
call.offering = false;
|
|
1090
1119
|
call.state = "connecting";
|
|
1091
1120
|
const attempt = call.answered = call.attempt;
|
|
1092
|
-
call.answeredAt =
|
|
1121
|
+
call.answeredAt = monotonic();
|
|
1093
1122
|
try {
|
|
1094
1123
|
call.media.applyAnswer(answer);
|
|
1095
1124
|
} catch (error) {
|
|
@@ -1240,7 +1269,7 @@ var CallManager = class {
|
|
|
1240
1269
|
const link = this.callable(chat);
|
|
1241
1270
|
if (this.byChat(link.id)) throw new CliError("busy", "A call is already on in this chat");
|
|
1242
1271
|
const held = this.held.get(link.id);
|
|
1243
|
-
if (held && this.
|
|
1272
|
+
if (held && this.within(held.at, 6e4)) {
|
|
1244
1273
|
this.incoming(link.id, held.offer);
|
|
1245
1274
|
throw new CliError("busy", "The contact is calling: their call rings here");
|
|
1246
1275
|
}
|
|
@@ -1409,6 +1438,7 @@ var CallManager = class {
|
|
|
1409
1438
|
queue: null,
|
|
1410
1439
|
startedAt: this.now,
|
|
1411
1440
|
connectedAt: null,
|
|
1441
|
+
connectedTick: null,
|
|
1412
1442
|
timer: null,
|
|
1413
1443
|
watcher: null,
|
|
1414
1444
|
stalledFrom: null,
|
|
@@ -1456,7 +1486,7 @@ var CallManager = class {
|
|
|
1456
1486
|
}
|
|
1457
1487
|
if (state === "closed" && failed) return;
|
|
1458
1488
|
failed ||= state === "failed";
|
|
1459
|
-
if (state === "failed" && call.direction === "out" && call.answered === attempt && call.state !== "connected" &&
|
|
1489
|
+
if (state === "failed" && call.direction === "out" && call.answered === attempt && call.state !== "connected" && monotonic() - call.answeredAt < 2e3) {
|
|
1460
1490
|
this.refused(call, "the connection failed as the answer went in");
|
|
1461
1491
|
return;
|
|
1462
1492
|
}
|
|
@@ -1474,6 +1504,7 @@ var CallManager = class {
|
|
|
1474
1504
|
if (call.state === "connected") return;
|
|
1475
1505
|
call.state = "connected";
|
|
1476
1506
|
call.connectedAt = this.now;
|
|
1507
|
+
call.connectedTick = monotonic();
|
|
1477
1508
|
this.disarm(call);
|
|
1478
1509
|
this.host.emit("call.connected", `call.connected:${call.id}`, {
|
|
1479
1510
|
call: call.id,
|
|
@@ -1494,11 +1525,11 @@ var CallManager = class {
|
|
|
1494
1525
|
afterMs: 5e3,
|
|
1495
1526
|
endMs: 15e3
|
|
1496
1527
|
};
|
|
1497
|
-
const since =
|
|
1528
|
+
const since = monotonic();
|
|
1498
1529
|
call.watcher = setInterval(() => {
|
|
1499
1530
|
if (call.ended) return;
|
|
1500
1531
|
const heardAt = Math.max(since, call.media?.audio.heardAt ?? 0);
|
|
1501
|
-
const silentMs =
|
|
1532
|
+
const silentMs = monotonic() - heardAt;
|
|
1502
1533
|
const fields = {
|
|
1503
1534
|
call: call.id,
|
|
1504
1535
|
chat: call.chat,
|
|
@@ -1536,7 +1567,7 @@ var CallManager = class {
|
|
|
1536
1567
|
this.calls.delete(call.id);
|
|
1537
1568
|
if (call.direction === "out" && call.connectedAt === null && call.state === "ringing" && (reason === "hangup" || reason === "unanswered")) this.unansweredAt.set(call.chat, this.now);
|
|
1538
1569
|
if (call.direction === "in" && call.connectedAt === null && reason !== "hangup" && reason !== "stopped") {
|
|
1539
|
-
if (this.
|
|
1570
|
+
if (this.within(call.startedAt, 1e3)) this.missedAt.set(call.chat, this.now);
|
|
1540
1571
|
else this.missedAt.delete(call.chat);
|
|
1541
1572
|
}
|
|
1542
1573
|
if (report) process.stderr.write(`ghostly: call ${call.id}: ended (${reason})${call.media ? `, ice ${call.media.ice.state}` : ""}\n`);
|
|
@@ -1568,7 +1599,7 @@ var CallManager = class {
|
|
|
1568
1599
|
chat: call.chat,
|
|
1569
1600
|
direction: call.direction,
|
|
1570
1601
|
reason,
|
|
1571
|
-
...call.
|
|
1602
|
+
...call.connectedTick !== null ? { duration: Math.round(monotonic() - call.connectedTick) } : {}
|
|
1572
1603
|
});
|
|
1573
1604
|
if (this.stopping) await closing;
|
|
1574
1605
|
}
|
|
@@ -1576,17 +1607,25 @@ var CallManager = class {
|
|
|
1576
1607
|
paced(chat) {
|
|
1577
1608
|
const pace = this.host.callPaceMs ?? 2e3, last = this.unansweredAt.get(chat);
|
|
1578
1609
|
if (!pace || last === void 0) return;
|
|
1579
|
-
|
|
1580
|
-
if (left <= 0) {
|
|
1610
|
+
if (!this.within(last, pace)) {
|
|
1581
1611
|
this.unansweredAt.delete(chat);
|
|
1582
1612
|
return;
|
|
1583
1613
|
}
|
|
1614
|
+
const left = last + pace - this.now;
|
|
1584
1615
|
throw new CliError("busy", `Your last call in this chat ended unanswered a moment ago: call again in ${Math.ceil(left / 100) / 10} s`, { retryAfterMs: left });
|
|
1585
1616
|
}
|
|
1586
1617
|
/** Whether the contact's call coming now in the chat is held back: its last one was missed after it barely rang, or held, a moment ago. */
|
|
1587
1618
|
quickRedial(chat) {
|
|
1588
1619
|
const quick = this.host.quickRedialMs ?? 2e3, last = this.missedAt.get(chat);
|
|
1589
|
-
return !!quick && last !== void 0 && this.
|
|
1620
|
+
return !!quick && last !== void 0 && this.within(last, quick);
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Whether less than `ms` passed since `at`, on the device's clock (`now`, which the timestamps the contact sees are on).
|
|
1624
|
+
* An `at` later than now is the clock set back since: the wait is taken as over, not as lasting as long as the jump.
|
|
1625
|
+
*/
|
|
1626
|
+
within(at, ms) {
|
|
1627
|
+
const passed = this.now - at;
|
|
1628
|
+
return passed >= 0 && passed < ms;
|
|
1590
1629
|
}
|
|
1591
1630
|
arm(call, ms, reason, tell) {
|
|
1592
1631
|
this.disarm(call);
|
|
@@ -3267,7 +3306,7 @@ var publicOnly = (resolve) => (hostname, options, callback) => {
|
|
|
3267
3306
|
callback(null, addresses[0].address, addresses[0].family);
|
|
3268
3307
|
});
|
|
3269
3308
|
};
|
|
3270
|
-
var publicOnlyLookup = publicOnly(lookup
|
|
3309
|
+
var publicOnlyLookup = publicOnly(lookup);
|
|
3271
3310
|
/**
|
|
3272
3311
|
* Posts a wake-up (WISP 401 § Wake-up push) the way the Desktop does from Rust: only to a push service's endpoint
|
|
3273
3312
|
* (`checkPushEndpoint`), whose name must resolve to public addresses only, no redirect followed, no proxy, 10 s at most.
|
|
@@ -3323,6 +3362,26 @@ function nodeHoldFetch(lookup = publicOnlyLookup) {
|
|
|
3323
3362
|
});
|
|
3324
3363
|
}
|
|
3325
3364
|
//#endregion
|
|
3365
|
+
//#region src/runtime/irohRelay.ts
|
|
3366
|
+
/**
|
|
3367
|
+
* Whether the CLI's Iroh may dial a contact through the relay its descriptor names (irohWeb.ts `publicRelay`): at a
|
|
3368
|
+
* public address, or at a name whose every address is public now, as a held item's is (`publicOnlyLookup`). Asked again
|
|
3369
|
+
* before each dial. The wasm resolves the name once more when it connects, so a name that changes its answer in
|
|
3370
|
+
* between is not caught here.
|
|
3371
|
+
*/
|
|
3372
|
+
function nodePublicRelay(lookup = publicOnlyLookup) {
|
|
3373
|
+
return (relay) => new Promise((resolve) => {
|
|
3374
|
+
let host;
|
|
3375
|
+
try {
|
|
3376
|
+
host = new URL(relay).hostname.replace(/^\[(.*)\]$/, "$1");
|
|
3377
|
+
} catch {
|
|
3378
|
+
return resolve(false);
|
|
3379
|
+
}
|
|
3380
|
+
if (isIP(host)) return resolve(isPublicIp(host));
|
|
3381
|
+
lookup(host, { all: true }, (error) => resolve(!error));
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
//#endregion
|
|
3326
3385
|
//#region src/runtime/rows.ts
|
|
3327
3386
|
/** The warning `node:sqlite` gives as it loads (experimental on Node 22 and 23): said once for every command, it is noise. */
|
|
3328
3387
|
var SQLITE_WARNING = /^SQLite is an experimental feature/;
|
|
@@ -5138,6 +5197,84 @@ function blobsFromDisk(value, depth = 0) {
|
|
|
5138
5197
|
for (const [k, v] of Object.entries(value)) out[k] = blobsFromDisk(v, depth + 1);
|
|
5139
5198
|
return out;
|
|
5140
5199
|
}
|
|
5200
|
+
/**
|
|
5201
|
+
* A wake republishes every chat with nothing published in the last seconds (on the CLI the DHT copy goes whatever the
|
|
5202
|
+
* relays' budgets say: 200 chats are 200 DHT puts and a ~76 ms turn). A network that flaps (Wi-Fi at the edge of range,
|
|
5203
|
+
* a VPN in a reconnect loop) changed the addresses every tick and woke the engine every 10 s for nothing new. A network
|
|
5204
|
+
* wake within this long of the previous wake is held and runs once when the gap is over, the latest change included; each
|
|
5205
|
+
* held one run doubles the gap, up to `WAKE_GAP_MAX_MS`, and a whole gap with no change brings it back. A network change
|
|
5206
|
+
* after a quiet spell, and a sleep, still wake at once.
|
|
5207
|
+
*/
|
|
5208
|
+
var WAKE_GAP_MS = 6e4;
|
|
5209
|
+
var WAKE_GAP_MAX_MS = 6e5;
|
|
5210
|
+
/**
|
|
5211
|
+
* The machine's own virtual bridges, for containers and VMs on it: Docker's (`docker0`, a compose network's `br-<id>`,
|
|
5212
|
+
* `veth*`), libvirt's, CNI's, LXD's, VirtualBox's and VMware's host networks, macOS's `bridge100` (sharing, a VM), and
|
|
5213
|
+
* Windows's WSL and Default Switch. A container network made or removed changes them with nothing changed for the
|
|
5214
|
+
* internet, and a network wake makes every chat read and publish at once. A Hyper-V switch bound to the network card (`vEthernet
|
|
5215
|
+
* (External)`) holds the machine's real address and stays.
|
|
5216
|
+
*/
|
|
5217
|
+
var LOCAL_BRIDGE = /^(docker\d*|br-[0-9a-f]+|veth.*|virbr\d+|cni\d+|flannel.*|cali.*|lxcbr\d+|lxdbr\d+|incusbr\d+|podman\d+|vboxnet\d+|vmnet\d+|bridge\d+|vEthernet \((WSL.*|Default Switch)\))$/;
|
|
5218
|
+
/** The machine's own non-internal addresses, sorted: a change means another network (Wi-Fi to cable, a new DHCP lease). */
|
|
5219
|
+
function addressesKey(nets = networkInterfaces()) {
|
|
5220
|
+
const out = [];
|
|
5221
|
+
for (const [name, list] of Object.entries(nets)) {
|
|
5222
|
+
if (LOCAL_BRIDGE.test(name)) continue;
|
|
5223
|
+
for (const entry of list ?? []) {
|
|
5224
|
+
if (entry.internal || entry.family === "IPv6" && entry.address.toLowerCase().startsWith("fe80")) continue;
|
|
5225
|
+
out.push(`${name}/${entry.address}`);
|
|
5226
|
+
}
|
|
5227
|
+
}
|
|
5228
|
+
return out.sort().join(",");
|
|
5229
|
+
}
|
|
5230
|
+
/** Starts the watch; the returned function stops it. The timer never keeps the process alive. */
|
|
5231
|
+
function watchWake(onWake, options = {}) {
|
|
5232
|
+
const tickMs = options.tickMs ?? 1e4;
|
|
5233
|
+
const lateMs = options.lateMs ?? 3e4;
|
|
5234
|
+
const now = options.now ?? Date.now;
|
|
5235
|
+
const addresses = options.addresses ?? (() => addressesKey());
|
|
5236
|
+
let last = now();
|
|
5237
|
+
let key = safe(addresses);
|
|
5238
|
+
let wokeAt = -Infinity;
|
|
5239
|
+
let gap = WAKE_GAP_MS;
|
|
5240
|
+
/** A network change seen within the gap, not woken for yet. */
|
|
5241
|
+
let held = false;
|
|
5242
|
+
const wake = (why, at) => {
|
|
5243
|
+
wokeAt = at;
|
|
5244
|
+
held = false;
|
|
5245
|
+
try {
|
|
5246
|
+
onWake(why);
|
|
5247
|
+
} catch {}
|
|
5248
|
+
};
|
|
5249
|
+
const timer = setInterval(() => {
|
|
5250
|
+
const at = now();
|
|
5251
|
+
const slept = at - last > tickMs + lateMs;
|
|
5252
|
+
last = at;
|
|
5253
|
+
const next = safe(addresses);
|
|
5254
|
+
const moved = next !== "" && next !== key;
|
|
5255
|
+
key = next;
|
|
5256
|
+
if (slept) return wake("sleep", at);
|
|
5257
|
+
if (!(at - wokeAt >= gap)) {
|
|
5258
|
+
held ||= moved;
|
|
5259
|
+
return;
|
|
5260
|
+
}
|
|
5261
|
+
if (held) {
|
|
5262
|
+
gap = Math.min(gap * 2, WAKE_GAP_MAX_MS);
|
|
5263
|
+
return wake("network", at);
|
|
5264
|
+
}
|
|
5265
|
+
gap = WAKE_GAP_MS;
|
|
5266
|
+
if (moved) wake("network", at);
|
|
5267
|
+
}, tickMs);
|
|
5268
|
+
timer.unref?.();
|
|
5269
|
+
return () => clearInterval(timer);
|
|
5270
|
+
}
|
|
5271
|
+
function safe(read) {
|
|
5272
|
+
try {
|
|
5273
|
+
return read();
|
|
5274
|
+
} catch {
|
|
5275
|
+
return "";
|
|
5276
|
+
}
|
|
5277
|
+
}
|
|
5141
5278
|
//#endregion
|
|
5142
5279
|
//#region src/runtime/engine.ts
|
|
5143
5280
|
/**
|
|
@@ -5360,20 +5497,21 @@ async function startRuntime(paths, options = {}) {
|
|
|
5360
5497
|
await installEventSource();
|
|
5361
5498
|
await preloadWalletModules();
|
|
5362
5499
|
(await import("./ghostly_iroh_web-BzAXJUYH.js")).initSync({ module: irohWasmBytes() });
|
|
5363
|
-
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-
|
|
5500
|
+
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-CQQK2uOh.js"), import("./fileBytes-DqnfKIkj.js")]);
|
|
5364
5501
|
registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
|
|
5365
|
-
if (await (await import("./blobFiles-
|
|
5366
|
-
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-
|
|
5367
|
-
const mainline = dht.off ? null : new (await (import("./mainline-
|
|
5502
|
+
if (await (await import("./blobFiles-XZ9PEXYy.js")).moveBlobFiles()) await store.compact();
|
|
5503
|
+
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-DYdR0_Fj.js"), import("./endpoint-DWHkXWVM.js")]);
|
|
5504
|
+
const mainline = dht.off ? null : new (await (import("./mainline-Bx184Ixg.js"))).Mainline({
|
|
5368
5505
|
bootstrap: dht.bootstrap,
|
|
5369
5506
|
host: dht.host
|
|
5370
5507
|
});
|
|
5371
|
-
const transport = mainline || pinned ? new (await (import("./mainline-
|
|
5508
|
+
const transport = mainline || pinned ? new (await (import("./mainline-Bx184Ixg.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
|
|
5372
5509
|
const apps = servedApps(paths.dir).length > 0;
|
|
5373
5510
|
const server = new EngineServer({
|
|
5374
5511
|
...transport ? { transport } : {},
|
|
5375
5512
|
irohWeb: true,
|
|
5376
5513
|
...pinnedIroh ? { irohRelays: pinnedIroh } : {},
|
|
5514
|
+
irohPublicRelay: nodePublicRelay(),
|
|
5377
5515
|
singleDevice: true,
|
|
5378
5516
|
nativeTransports: { "hyperdht/1": (seedB64) => createHyperEndpoint(fromBase64Url(seedB64), network) },
|
|
5379
5517
|
automaticWallets: false,
|
|
@@ -5400,6 +5538,9 @@ async function startRuntime(paths, options = {}) {
|
|
|
5400
5538
|
await store.close().catch(() => {});
|
|
5401
5539
|
throw error;
|
|
5402
5540
|
}
|
|
5541
|
+
const stopWake = options.offline ? () => {} : watchWake(() => {
|
|
5542
|
+
server.node.wake({ network: true });
|
|
5543
|
+
});
|
|
5403
5544
|
let closing = null;
|
|
5404
5545
|
return {
|
|
5405
5546
|
paths,
|
|
@@ -5409,6 +5550,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
5409
5550
|
callsUnavailable,
|
|
5410
5551
|
apps,
|
|
5411
5552
|
close: () => closing ??= (async () => {
|
|
5553
|
+
stopWake();
|
|
5412
5554
|
await server.node.shutdown({ quitting: true }).catch(() => {});
|
|
5413
5555
|
await mainline?.destroy().catch(() => {});
|
|
5414
5556
|
await store.close();
|
|
@@ -5731,4 +5873,4 @@ function connection(ctx, socket, secret) {
|
|
|
5731
5873
|
//#endregion
|
|
5732
5874
|
export { BASELINE_NEWEST, MAX_UNREAD, keepServing, openHost, serve };
|
|
5733
5875
|
|
|
5734
|
-
//# sourceMappingURL=host-
|
|
5876
|
+
//# sourceMappingURL=host-DFLzzKNr.js.map
|