@dxos/network-manager 0.5.1-main.ff7d242 → 0.5.1-next.1634f4d
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/lib/browser/{chunk-TVNVOM33.mjs → chunk-66SM4LDV.mjs} +105 -64
- package/dist/lib/browser/chunk-66SM4LDV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-ZULA2NNI.cjs → chunk-3ZJXMDGK.cjs} +103 -62
- package/dist/lib/node/chunk-3ZJXMDGK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +27 -27
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +18 -18
- package/dist/types/src/swarm/connection.d.ts +4 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/topology/topology.d.ts +4 -0
- package/dist/types/src/topology/topology.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +3 -2
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/swarm/connection.ts +24 -8
- package/src/swarm/peer.ts +2 -2
- package/src/swarm/swarm.ts +6 -2
- package/src/topology/topology.ts +5 -0
- package/src/wire-protocol.ts +4 -2
- package/dist/lib/browser/chunk-TVNVOM33.mjs.map +0 -7
- package/dist/lib/node/chunk-ZULA2NNI.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_3ZJXMDGK_exports = {};
|
|
30
|
+
__export(chunk_3ZJXMDGK_exports, {
|
|
31
31
|
Connection: () => Connection,
|
|
32
32
|
ConnectionLimiter: () => ConnectionLimiter,
|
|
33
33
|
ConnectionLog: () => ConnectionLog,
|
|
@@ -55,7 +55,7 @@ __export(chunk_ZULA2NNI_exports, {
|
|
|
55
55
|
createSimplePeerTransportFactory: () => createSimplePeerTransportFactory,
|
|
56
56
|
createTeleportProtocolFactory: () => createTeleportProtocolFactory
|
|
57
57
|
});
|
|
58
|
-
module.exports = __toCommonJS(
|
|
58
|
+
module.exports = __toCommonJS(chunk_3ZJXMDGK_exports);
|
|
59
59
|
var import_async = require("@dxos/async");
|
|
60
60
|
var import_context = require("@dxos/context");
|
|
61
61
|
var import_debug = require("@dxos/debug");
|
|
@@ -199,6 +199,8 @@ var Connection = class {
|
|
|
199
199
|
this._callbacks = _callbacks;
|
|
200
200
|
this._ctx = new import_context.Context();
|
|
201
201
|
this.connectedTimeoutContext = new import_context.Context();
|
|
202
|
+
this._protocolClosed = new import_async.Trigger();
|
|
203
|
+
this._transportClosed = new import_async.Trigger();
|
|
202
204
|
this._state = "CREATED";
|
|
203
205
|
this._incomingSignalBuffer = [];
|
|
204
206
|
this._outgoingSignalBuffer = [];
|
|
@@ -218,7 +220,7 @@ var Connection = class {
|
|
|
218
220
|
initiator: this.initiator
|
|
219
221
|
}, {
|
|
220
222
|
F: __dxlog_file,
|
|
221
|
-
L:
|
|
223
|
+
L: 137,
|
|
222
224
|
S: this,
|
|
223
225
|
C: (f, a) => f(...a)
|
|
224
226
|
});
|
|
@@ -241,7 +243,7 @@ var Connection = class {
|
|
|
241
243
|
async openConnection() {
|
|
242
244
|
(0, import_invariant.invariant)(this._state === "INITIAL", "Invalid state.", {
|
|
243
245
|
F: __dxlog_file,
|
|
244
|
-
L:
|
|
246
|
+
L: 167,
|
|
245
247
|
S: this,
|
|
246
248
|
A: [
|
|
247
249
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -252,7 +254,7 @@ var Connection = class {
|
|
|
252
254
|
id: this._instanceId
|
|
253
255
|
}), {
|
|
254
256
|
F: __dxlog_file,
|
|
255
|
-
L:
|
|
257
|
+
L: 168,
|
|
256
258
|
S: this,
|
|
257
259
|
C: (f, a) => f(...a)
|
|
258
260
|
});
|
|
@@ -264,7 +266,7 @@ var Connection = class {
|
|
|
264
266
|
initiator: this.initiator
|
|
265
267
|
}, {
|
|
266
268
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
269
|
+
L: 169,
|
|
268
270
|
S: this,
|
|
269
271
|
C: (f, a) => f(...a)
|
|
270
272
|
});
|
|
@@ -275,16 +277,17 @@ var Connection = class {
|
|
|
275
277
|
this._protocol.stream.on("close", () => {
|
|
276
278
|
(0, import_log.log)("protocol stream closed", void 0, {
|
|
277
279
|
F: __dxlog_file,
|
|
278
|
-
L:
|
|
280
|
+
L: 186,
|
|
279
281
|
S: this,
|
|
280
282
|
C: (f, a) => f(...a)
|
|
281
283
|
});
|
|
284
|
+
this._protocolClosed.wake();
|
|
282
285
|
this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
283
286
|
});
|
|
284
287
|
(0, import_async.scheduleTask)(this.connectedTimeoutContext, async () => {
|
|
285
288
|
import_log.log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
286
289
|
F: __dxlog_file,
|
|
287
|
-
L:
|
|
290
|
+
L: 194,
|
|
288
291
|
S: this,
|
|
289
292
|
C: (f, a) => f(...a)
|
|
290
293
|
});
|
|
@@ -292,7 +295,7 @@ var Connection = class {
|
|
|
292
295
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
293
296
|
(0, import_invariant.invariant)(!this._transport, void 0, {
|
|
294
297
|
F: __dxlog_file,
|
|
295
|
-
L:
|
|
298
|
+
L: 202,
|
|
296
299
|
S: this,
|
|
297
300
|
A: [
|
|
298
301
|
"!this._transport",
|
|
@@ -314,9 +317,10 @@ var Connection = class {
|
|
|
314
317
|
});
|
|
315
318
|
this._transport.closed.once(() => {
|
|
316
319
|
this._transport = void 0;
|
|
320
|
+
this._transportClosed.wake();
|
|
317
321
|
(0, import_log.log)("abort triggered by transport close", void 0, {
|
|
318
322
|
F: __dxlog_file,
|
|
319
|
-
L:
|
|
323
|
+
L: 223,
|
|
320
324
|
S: this,
|
|
321
325
|
C: (f, a) => f(...a)
|
|
322
326
|
});
|
|
@@ -327,7 +331,7 @@ var Connection = class {
|
|
|
327
331
|
err
|
|
328
332
|
}, {
|
|
329
333
|
F: __dxlog_file,
|
|
330
|
-
L:
|
|
334
|
+
L: 228,
|
|
331
335
|
S: this,
|
|
332
336
|
C: (f, a) => f(...a)
|
|
333
337
|
});
|
|
@@ -337,7 +341,7 @@ var Connection = class {
|
|
|
337
341
|
if (err instanceof import_protocols.ConnectionResetError) {
|
|
338
342
|
import_log.log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
339
343
|
F: __dxlog_file,
|
|
340
|
-
L:
|
|
344
|
+
L: 235,
|
|
341
345
|
S: this,
|
|
342
346
|
C: (f, a) => f(...a)
|
|
343
347
|
});
|
|
@@ -345,7 +349,7 @@ var Connection = class {
|
|
|
345
349
|
} else if (err instanceof import_protocols.ConnectivityError) {
|
|
346
350
|
import_log.log.info("aborting due to transport ConnectivityError", void 0, {
|
|
347
351
|
F: __dxlog_file,
|
|
348
|
-
L:
|
|
352
|
+
L: 238,
|
|
349
353
|
S: this,
|
|
350
354
|
C: (f, a) => f(...a)
|
|
351
355
|
});
|
|
@@ -355,7 +359,7 @@ var Connection = class {
|
|
|
355
359
|
err
|
|
356
360
|
}, {
|
|
357
361
|
F: __dxlog_file,
|
|
358
|
-
L:
|
|
362
|
+
L: 241,
|
|
359
363
|
S: this,
|
|
360
364
|
C: (f, a) => f(...a)
|
|
361
365
|
});
|
|
@@ -373,7 +377,7 @@ var Connection = class {
|
|
|
373
377
|
id: this._instanceId
|
|
374
378
|
}), {
|
|
375
379
|
F: __dxlog_file,
|
|
376
|
-
L:
|
|
380
|
+
L: 257,
|
|
377
381
|
S: this,
|
|
378
382
|
C: (f, a) => f(...a)
|
|
379
383
|
});
|
|
@@ -383,14 +387,14 @@ var Connection = class {
|
|
|
383
387
|
err
|
|
384
388
|
}, {
|
|
385
389
|
F: __dxlog_file,
|
|
386
|
-
L:
|
|
390
|
+
L: 264,
|
|
387
391
|
S: this,
|
|
388
392
|
C: (f, a) => f(...a)
|
|
389
393
|
});
|
|
390
394
|
if (this._state === "CLOSED" || this._state === "ABORTED") {
|
|
391
395
|
(0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
392
396
|
F: __dxlog_file,
|
|
393
|
-
L:
|
|
397
|
+
L: 266,
|
|
394
398
|
S: this,
|
|
395
399
|
C: (f, a) => f(...a)
|
|
396
400
|
});
|
|
@@ -403,27 +407,21 @@ var Connection = class {
|
|
|
403
407
|
}
|
|
404
408
|
await this._ctx.dispose();
|
|
405
409
|
try {
|
|
406
|
-
|
|
407
|
-
F: __dxlog_file,
|
|
408
|
-
L: 275,
|
|
409
|
-
S: this,
|
|
410
|
-
C: (f, a) => f(...a)
|
|
411
|
-
});
|
|
412
|
-
await this._protocol.abort();
|
|
410
|
+
await this._closeProtocol();
|
|
413
411
|
} catch (err2) {
|
|
414
412
|
import_log.log.catch(err2, void 0, {
|
|
415
413
|
F: __dxlog_file,
|
|
416
|
-
L:
|
|
414
|
+
L: 282,
|
|
417
415
|
S: this,
|
|
418
416
|
C: (f, a) => f(...a)
|
|
419
417
|
});
|
|
420
418
|
}
|
|
421
419
|
try {
|
|
422
|
-
await this.
|
|
420
|
+
await this._closeTransport();
|
|
423
421
|
} catch (err2) {
|
|
424
422
|
import_log.log.catch(err2, void 0, {
|
|
425
423
|
F: __dxlog_file,
|
|
426
|
-
L:
|
|
424
|
+
L: 289,
|
|
427
425
|
S: this,
|
|
428
426
|
C: (f, a) => f(...a)
|
|
429
427
|
});
|
|
@@ -433,7 +431,7 @@ var Connection = class {
|
|
|
433
431
|
} catch (err2) {
|
|
434
432
|
import_log.log.catch(err2, void 0, {
|
|
435
433
|
F: __dxlog_file,
|
|
436
|
-
L:
|
|
434
|
+
L: 295,
|
|
437
435
|
S: this,
|
|
438
436
|
C: (f, a) => f(...a)
|
|
439
437
|
});
|
|
@@ -457,27 +455,27 @@ var Connection = class {
|
|
|
457
455
|
peerId: this.ownId
|
|
458
456
|
}, {
|
|
459
457
|
F: __dxlog_file,
|
|
460
|
-
L:
|
|
458
|
+
L: 320,
|
|
461
459
|
S: this,
|
|
462
460
|
C: (f, a) => f(...a)
|
|
463
461
|
});
|
|
464
462
|
if (lastState === "CONNECTED") {
|
|
465
463
|
try {
|
|
466
|
-
await this.
|
|
464
|
+
await this._closeProtocol();
|
|
467
465
|
} catch (err2) {
|
|
468
466
|
import_log.log.catch(err2, void 0, {
|
|
469
467
|
F: __dxlog_file,
|
|
470
|
-
L:
|
|
468
|
+
L: 327,
|
|
471
469
|
S: this,
|
|
472
470
|
C: (f, a) => f(...a)
|
|
473
471
|
});
|
|
474
472
|
}
|
|
475
473
|
try {
|
|
476
|
-
await this.
|
|
474
|
+
await this._closeTransport();
|
|
477
475
|
} catch (err2) {
|
|
478
476
|
import_log.log.catch(err2, void 0, {
|
|
479
477
|
F: __dxlog_file,
|
|
480
|
-
L:
|
|
478
|
+
L: 334,
|
|
481
479
|
S: this,
|
|
482
480
|
C: (f, a) => f(...a)
|
|
483
481
|
});
|
|
@@ -485,26 +483,26 @@ var Connection = class {
|
|
|
485
483
|
} else {
|
|
486
484
|
(0, import_log.log)(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
487
485
|
F: __dxlog_file,
|
|
488
|
-
L:
|
|
486
|
+
L: 337,
|
|
489
487
|
S: this,
|
|
490
488
|
C: (f, a) => f(...a)
|
|
491
489
|
});
|
|
492
490
|
try {
|
|
493
|
-
await this.
|
|
491
|
+
await this._closeProtocol();
|
|
494
492
|
} catch (err2) {
|
|
495
493
|
import_log.log.catch(err2, void 0, {
|
|
496
494
|
F: __dxlog_file,
|
|
497
|
-
L:
|
|
495
|
+
L: 341,
|
|
498
496
|
S: this,
|
|
499
497
|
C: (f, a) => f(...a)
|
|
500
498
|
});
|
|
501
499
|
}
|
|
502
500
|
try {
|
|
503
|
-
await this.
|
|
501
|
+
await this._closeTransport();
|
|
504
502
|
} catch (err2) {
|
|
505
503
|
import_log.log.catch(err2, void 0, {
|
|
506
504
|
F: __dxlog_file,
|
|
507
|
-
L:
|
|
505
|
+
L: 346,
|
|
508
506
|
S: this,
|
|
509
507
|
C: (f, a) => f(...a)
|
|
510
508
|
});
|
|
@@ -514,13 +512,49 @@ var Connection = class {
|
|
|
514
512
|
peerId: this.ownId
|
|
515
513
|
}, {
|
|
516
514
|
F: __dxlog_file,
|
|
517
|
-
L:
|
|
515
|
+
L: 350,
|
|
518
516
|
S: this,
|
|
519
517
|
C: (f, a) => f(...a)
|
|
520
518
|
});
|
|
521
519
|
this._changeState("CLOSED");
|
|
522
520
|
this._callbacks?.onClosed?.(err);
|
|
523
521
|
}
|
|
522
|
+
async _closeProtocol() {
|
|
523
|
+
(0, import_log.log)("closing protocol", void 0, {
|
|
524
|
+
F: __dxlog_file,
|
|
525
|
+
L: 356,
|
|
526
|
+
S: this,
|
|
527
|
+
C: (f, a) => f(...a)
|
|
528
|
+
});
|
|
529
|
+
await Promise.race([
|
|
530
|
+
this._protocol.close(),
|
|
531
|
+
this._protocolClosed.wait()
|
|
532
|
+
]);
|
|
533
|
+
(0, import_log.log)("protocol closed", void 0, {
|
|
534
|
+
F: __dxlog_file,
|
|
535
|
+
L: 358,
|
|
536
|
+
S: this,
|
|
537
|
+
C: (f, a) => f(...a)
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
async _closeTransport() {
|
|
541
|
+
(0, import_log.log)("closing transport", void 0, {
|
|
542
|
+
F: __dxlog_file,
|
|
543
|
+
L: 362,
|
|
544
|
+
S: this,
|
|
545
|
+
C: (f, a) => f(...a)
|
|
546
|
+
});
|
|
547
|
+
await Promise.race([
|
|
548
|
+
this._transport?.close(),
|
|
549
|
+
this._transportClosed.wait()
|
|
550
|
+
]);
|
|
551
|
+
(0, import_log.log)("transport closed", void 0, {
|
|
552
|
+
F: __dxlog_file,
|
|
553
|
+
L: 364,
|
|
554
|
+
S: this,
|
|
555
|
+
C: (f, a) => f(...a)
|
|
556
|
+
});
|
|
557
|
+
}
|
|
524
558
|
_sendSignal(signal) {
|
|
525
559
|
this._outgoingSignalBuffer.push(signal);
|
|
526
560
|
this._signalSendTask.schedule();
|
|
@@ -557,7 +591,7 @@ var Connection = class {
|
|
|
557
591
|
err
|
|
558
592
|
}, {
|
|
559
593
|
F: __dxlog_file,
|
|
560
|
-
L:
|
|
594
|
+
L: 400,
|
|
561
595
|
S: this,
|
|
562
596
|
C: (f, a) => f(...a)
|
|
563
597
|
});
|
|
@@ -570,7 +604,7 @@ var Connection = class {
|
|
|
570
604
|
async signal(msg) {
|
|
571
605
|
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
572
606
|
F: __dxlog_file,
|
|
573
|
-
L:
|
|
607
|
+
L: 409,
|
|
574
608
|
S: this,
|
|
575
609
|
A: [
|
|
576
610
|
"msg.sessionId",
|
|
@@ -580,7 +614,7 @@ var Connection = class {
|
|
|
580
614
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
581
615
|
(0, import_log.log)("dropping signal for incorrect session id", void 0, {
|
|
582
616
|
F: __dxlog_file,
|
|
583
|
-
L:
|
|
617
|
+
L: 411,
|
|
584
618
|
S: this,
|
|
585
619
|
C: (f, a) => f(...a)
|
|
586
620
|
});
|
|
@@ -588,7 +622,7 @@ var Connection = class {
|
|
|
588
622
|
}
|
|
589
623
|
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
590
624
|
F: __dxlog_file,
|
|
591
|
-
L:
|
|
625
|
+
L: 414,
|
|
592
626
|
S: this,
|
|
593
627
|
A: [
|
|
594
628
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -597,7 +631,7 @@ var Connection = class {
|
|
|
597
631
|
});
|
|
598
632
|
(0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
|
|
599
633
|
F: __dxlog_file,
|
|
600
|
-
L:
|
|
634
|
+
L: 415,
|
|
601
635
|
S: this,
|
|
602
636
|
A: [
|
|
603
637
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -606,7 +640,7 @@ var Connection = class {
|
|
|
606
640
|
});
|
|
607
641
|
(0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
|
|
608
642
|
F: __dxlog_file,
|
|
609
|
-
L:
|
|
643
|
+
L: 416,
|
|
610
644
|
S: this,
|
|
611
645
|
A: [
|
|
612
646
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -630,7 +664,7 @@ var Connection = class {
|
|
|
630
664
|
msg: msg.data
|
|
631
665
|
}, {
|
|
632
666
|
F: __dxlog_file,
|
|
633
|
-
L:
|
|
667
|
+
L: 425,
|
|
634
668
|
S: this,
|
|
635
669
|
C: (f, a) => f(...a)
|
|
636
670
|
});
|
|
@@ -638,7 +672,7 @@ var Connection = class {
|
|
|
638
672
|
} else {
|
|
639
673
|
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
640
674
|
F: __dxlog_file,
|
|
641
|
-
L:
|
|
675
|
+
L: 428,
|
|
642
676
|
S: this,
|
|
643
677
|
A: [
|
|
644
678
|
"this._transport",
|
|
@@ -651,7 +685,7 @@ var Connection = class {
|
|
|
651
685
|
msg: msg.data
|
|
652
686
|
}, {
|
|
653
687
|
F: __dxlog_file,
|
|
654
|
-
L:
|
|
688
|
+
L: 429,
|
|
655
689
|
S: this,
|
|
656
690
|
C: (f, a) => f(...a)
|
|
657
691
|
});
|
|
@@ -669,13 +703,13 @@ var Connection = class {
|
|
|
669
703
|
peerId: this.ownId
|
|
670
704
|
}, {
|
|
671
705
|
F: __dxlog_file,
|
|
672
|
-
L:
|
|
706
|
+
L: 440,
|
|
673
707
|
S: this,
|
|
674
708
|
C: (f, a) => f(...a)
|
|
675
709
|
});
|
|
676
710
|
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
677
711
|
F: __dxlog_file,
|
|
678
|
-
L:
|
|
712
|
+
L: 441,
|
|
679
713
|
S: this,
|
|
680
714
|
A: [
|
|
681
715
|
"state !== this._state",
|
|
@@ -1077,9 +1111,9 @@ var Peer = class {
|
|
|
1077
1111
|
});
|
|
1078
1112
|
const sessionId = import_keys4.PublicKey.random();
|
|
1079
1113
|
(0, import_log4.log)("initiating...", {
|
|
1080
|
-
|
|
1114
|
+
ownPeerId: this.localPeerId,
|
|
1081
1115
|
topic: this.topic,
|
|
1082
|
-
|
|
1116
|
+
remotePeerId: this.id,
|
|
1083
1117
|
sessionId
|
|
1084
1118
|
}, {
|
|
1085
1119
|
F: __dxlog_file3,
|
|
@@ -1805,7 +1839,8 @@ var Swarm = class {
|
|
|
1805
1839
|
getState: () => ({
|
|
1806
1840
|
ownPeerId: this._ownPeerId,
|
|
1807
1841
|
connected: Array.from(this._peers.values()).filter((peer) => peer.connection).map((peer) => peer.id),
|
|
1808
|
-
candidates: Array.from(this._peers.values()).filter((peer) => !peer.connection && peer.advertizing && peer.availableToConnect).map((peer) => peer.id)
|
|
1842
|
+
candidates: Array.from(this._peers.values()).filter((peer) => !peer.connection && peer.advertizing && peer.availableToConnect).map((peer) => peer.id),
|
|
1843
|
+
allPeers: Array.from(this._peers.values()).map((peer) => peer.id)
|
|
1809
1844
|
}),
|
|
1810
1845
|
connect: (peer) => {
|
|
1811
1846
|
if (this._ctx.disposed) {
|
|
@@ -1817,7 +1852,7 @@ var Swarm = class {
|
|
|
1817
1852
|
} catch (err) {
|
|
1818
1853
|
(0, import_log3.log)("initiation error", err, {
|
|
1819
1854
|
F: __dxlog_file4,
|
|
1820
|
-
L:
|
|
1855
|
+
L: 335,
|
|
1821
1856
|
S: this,
|
|
1822
1857
|
C: (f, a) => f(...a)
|
|
1823
1858
|
});
|
|
@@ -1840,12 +1875,13 @@ var Swarm = class {
|
|
|
1840
1875
|
*/
|
|
1841
1876
|
async _initiateConnection(remoteId) {
|
|
1842
1877
|
const ctx = this._ctx;
|
|
1878
|
+
const peer = this._getOrCreatePeer(remoteId);
|
|
1843
1879
|
if (remoteId.toHex() < this._ownPeerId.toHex()) {
|
|
1844
1880
|
(0, import_log3.log)("initiation delay", {
|
|
1845
1881
|
remoteId
|
|
1846
1882
|
}, {
|
|
1847
1883
|
F: __dxlog_file4,
|
|
1848
|
-
L:
|
|
1884
|
+
L: 363,
|
|
1849
1885
|
S: this,
|
|
1850
1886
|
C: (f, a) => f(...a)
|
|
1851
1887
|
});
|
|
@@ -1854,7 +1890,9 @@ var Swarm = class {
|
|
|
1854
1890
|
if (ctx.disposed) {
|
|
1855
1891
|
return;
|
|
1856
1892
|
}
|
|
1857
|
-
|
|
1893
|
+
if (this._peers.get(remoteId) == null) {
|
|
1894
|
+
throw new Error("Peer left during initiation delay");
|
|
1895
|
+
}
|
|
1858
1896
|
if (peer.connection) {
|
|
1859
1897
|
return;
|
|
1860
1898
|
}
|
|
@@ -1862,7 +1900,7 @@ var Swarm = class {
|
|
|
1862
1900
|
remoteId
|
|
1863
1901
|
}, {
|
|
1864
1902
|
F: __dxlog_file4,
|
|
1865
|
-
L:
|
|
1903
|
+
L: 379,
|
|
1866
1904
|
S: this,
|
|
1867
1905
|
C: (f, a) => f(...a)
|
|
1868
1906
|
});
|
|
@@ -1872,7 +1910,7 @@ var Swarm = class {
|
|
|
1872
1910
|
remoteId
|
|
1873
1911
|
}, {
|
|
1874
1912
|
F: __dxlog_file4,
|
|
1875
|
-
L:
|
|
1913
|
+
L: 382,
|
|
1876
1914
|
S: this,
|
|
1877
1915
|
C: (f, a) => f(...a)
|
|
1878
1916
|
});
|
|
@@ -4071,9 +4109,12 @@ var TcpTransport = class {
|
|
|
4071
4109
|
this.options.stream.pipe(this._socket).pipe(this.options.stream);
|
|
4072
4110
|
}
|
|
4073
4111
|
};
|
|
4074
|
-
var createTeleportProtocolFactory = (onConnection) => {
|
|
4112
|
+
var createTeleportProtocolFactory = (onConnection, defaultParams) => {
|
|
4075
4113
|
return (params) => {
|
|
4076
|
-
const teleport = new import_teleport.Teleport(
|
|
4114
|
+
const teleport = new import_teleport.Teleport({
|
|
4115
|
+
...defaultParams,
|
|
4116
|
+
...params
|
|
4117
|
+
});
|
|
4077
4118
|
return {
|
|
4078
4119
|
stream: teleport.stream,
|
|
4079
4120
|
open: async (sessionId) => {
|
|
@@ -4118,4 +4159,4 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
4118
4159
|
createSimplePeerTransportFactory,
|
|
4119
4160
|
createTeleportProtocolFactory
|
|
4120
4161
|
});
|
|
4121
|
-
//# sourceMappingURL=chunk-
|
|
4162
|
+
//# sourceMappingURL=chunk-3ZJXMDGK.cjs.map
|