@dxos/network-manager 0.1.58-main.4cbb52d → 0.1.58-main.4e2a73a
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-CNQ55TFQ.mjs → chunk-HKHUCTRB.mjs} +40 -34
- package/dist/lib/browser/chunk-HKHUCTRB.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 +109 -109
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +321 -315
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +836 -829
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/swarm/peer.d.ts +2 -2
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm-mapper.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts +2 -2
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/tests/basic-test-suite.d.ts.map +1 -1
- package/dist/types/src/topology/star-topology.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/swarm/connection.test.ts +1 -1
- package/src/swarm/peer.ts +2 -2
- package/src/swarm/swarm-mapper.ts +4 -7
- package/src/swarm/swarm.test.ts +3 -3
- package/src/swarm/swarm.ts +3 -3
- package/src/testing/test-builder.ts +1 -1
- package/src/tests/basic-test-suite.ts +1 -1
- package/src/tests/memory-transport.test.ts +2 -2
- package/src/tests/tcp-transport.test.ts +2 -2
- package/src/tests/webrtc-transport.test.ts +1 -1
- package/src/topology/star-topology.ts +1 -4
- package/src/transport/simplepeer-transport-proxy.ts +25 -24
- package/src/transport/simplepeer-transport-service.ts +1 -4
- package/src/transport/simplepeer-transport.ts +3 -5
- package/dist/lib/browser/chunk-CNQ55TFQ.mjs.map +0 -7
|
@@ -520,29 +520,141 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
520
520
|
var import_rpc = require("@dxos/rpc");
|
|
521
521
|
var import_util11 = require("@dxos/util");
|
|
522
522
|
|
|
523
|
+
// packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
|
|
524
|
+
var import_async = require("@dxos/async");
|
|
525
|
+
var import_keys = require("@dxos/keys");
|
|
526
|
+
var import_log = require("@dxos/log");
|
|
527
|
+
var import_teleport2 = require("@dxos/teleport");
|
|
528
|
+
var import_util = require("@dxos/util");
|
|
529
|
+
|
|
530
|
+
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
531
|
+
var import_teleport = require("@dxos/teleport");
|
|
532
|
+
var createTeleportProtocolFactory = (onConnection) => {
|
|
533
|
+
return (params) => {
|
|
534
|
+
const teleport = new import_teleport.Teleport(params);
|
|
535
|
+
return {
|
|
536
|
+
stream: teleport.stream,
|
|
537
|
+
open: async () => {
|
|
538
|
+
await teleport.open();
|
|
539
|
+
await onConnection(teleport);
|
|
540
|
+
},
|
|
541
|
+
close: async () => {
|
|
542
|
+
await teleport.close();
|
|
543
|
+
},
|
|
544
|
+
abort: async () => {
|
|
545
|
+
await teleport.abort();
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
// packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
|
|
552
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts";
|
|
553
|
+
var TestWireProtocol = class {
|
|
554
|
+
constructor(peerId, _extensionFactory = () => []) {
|
|
555
|
+
this.peerId = peerId;
|
|
556
|
+
this._extensionFactory = _extensionFactory;
|
|
557
|
+
this.connections = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
558
|
+
this.streamConnections = new import_util.ComplexMap(import_keys.PublicKey.hash);
|
|
559
|
+
this.connected = new import_async.Event();
|
|
560
|
+
this.disconnected = new import_async.Event();
|
|
561
|
+
this.otherConnections = new import_util.ComplexMap(({ remotePeerId, extension }) => remotePeerId.toHex() + extension);
|
|
562
|
+
this.factory = createTeleportProtocolFactory(async (teleport) => {
|
|
563
|
+
(0, import_log.log)("create", {
|
|
564
|
+
remotePeerId: teleport.remotePeerId
|
|
565
|
+
}, {
|
|
566
|
+
F: __dxlog_file,
|
|
567
|
+
L: 38,
|
|
568
|
+
S: this,
|
|
569
|
+
C: (f, a) => f(...a)
|
|
570
|
+
});
|
|
571
|
+
const extension = new import_teleport2.TestExtension({
|
|
572
|
+
onClose: async () => {
|
|
573
|
+
this.connections.delete(teleport.remotePeerId);
|
|
574
|
+
this.disconnected.emit(teleport.remotePeerId);
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
this.connections.set(teleport.remotePeerId, extension);
|
|
578
|
+
teleport.addExtension("test", extension);
|
|
579
|
+
this.connected.emit(teleport.remotePeerId);
|
|
580
|
+
const streamExtension = new import_teleport2.TestExtensionWithStreams({
|
|
581
|
+
onClose: async () => {
|
|
582
|
+
this.streamConnections.delete(teleport.remotePeerId);
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
this.streamConnections.set(teleport.remotePeerId, streamExtension);
|
|
586
|
+
teleport.addExtension("test-stream", streamExtension);
|
|
587
|
+
for (const { name, extension: extension2 } of this._extensionFactory()) {
|
|
588
|
+
this.otherConnections.set({
|
|
589
|
+
remotePeerId: teleport.remotePeerId,
|
|
590
|
+
extension: name
|
|
591
|
+
}, extension2);
|
|
592
|
+
teleport.addExtension(name, extension2);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
async waitForConnection(peerId) {
|
|
597
|
+
if (this.connections.has(peerId)) {
|
|
598
|
+
return this.connections.get(peerId);
|
|
599
|
+
}
|
|
600
|
+
(0, import_log.log)("waitForConnection", {
|
|
601
|
+
peerId
|
|
602
|
+
}, {
|
|
603
|
+
F: __dxlog_file,
|
|
604
|
+
L: 67,
|
|
605
|
+
S: this,
|
|
606
|
+
C: (f, a) => f(...a)
|
|
607
|
+
});
|
|
608
|
+
await (0, import_async.asyncTimeout)(
|
|
609
|
+
this.connected.waitFor((connectedId) => connectedId.equals(peerId)),
|
|
610
|
+
// TODO(nf): Make this configurable.
|
|
611
|
+
1e4
|
|
612
|
+
);
|
|
613
|
+
return this.connections.get(peerId);
|
|
614
|
+
}
|
|
615
|
+
async testConnection(peerId, message) {
|
|
616
|
+
const connection = await this.waitForConnection(peerId);
|
|
617
|
+
await connection.test(message);
|
|
618
|
+
}
|
|
619
|
+
async openStream(peerId, streamTag, streamLoadInterval, streamLoadChunkSize) {
|
|
620
|
+
if (!this.streamConnections.has(peerId)) {
|
|
621
|
+
throw new Error("Connection does not exist.");
|
|
622
|
+
}
|
|
623
|
+
const connection = this.streamConnections.get(peerId);
|
|
624
|
+
return connection.addNewStream(streamLoadInterval, streamLoadChunkSize, streamTag);
|
|
625
|
+
}
|
|
626
|
+
async closeStream(peerId, streamTag) {
|
|
627
|
+
if (!this.streamConnections.has(peerId)) {
|
|
628
|
+
throw new Error("Connection does not exist.");
|
|
629
|
+
}
|
|
630
|
+
const connection = this.streamConnections.get(peerId);
|
|
631
|
+
return connection.closeStream(streamTag);
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
523
635
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
524
|
-
var
|
|
636
|
+
var import_async8 = require("@dxos/async");
|
|
525
637
|
var import_invariant6 = require("@dxos/invariant");
|
|
526
|
-
var
|
|
527
|
-
var
|
|
638
|
+
var import_keys9 = require("@dxos/keys");
|
|
639
|
+
var import_log8 = require("@dxos/log");
|
|
528
640
|
var import_messaging = require("@dxos/messaging");
|
|
529
641
|
var import_protocols6 = require("@dxos/protocols");
|
|
530
642
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
531
|
-
var
|
|
643
|
+
var import_util7 = require("@dxos/util");
|
|
532
644
|
|
|
533
645
|
// packages/core/mesh/network-manager/src/connection-log.ts
|
|
534
|
-
var
|
|
646
|
+
var import_async7 = require("@dxos/async");
|
|
535
647
|
var import_debug3 = require("@dxos/debug");
|
|
536
|
-
var
|
|
537
|
-
var
|
|
648
|
+
var import_keys8 = require("@dxos/keys");
|
|
649
|
+
var import_util6 = require("@dxos/util");
|
|
538
650
|
|
|
539
651
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
540
|
-
var
|
|
652
|
+
var import_async2 = require("@dxos/async");
|
|
541
653
|
var import_context = require("@dxos/context");
|
|
542
654
|
var import_debug = require("@dxos/debug");
|
|
543
655
|
var import_invariant = require("@dxos/invariant");
|
|
544
|
-
var
|
|
545
|
-
var
|
|
656
|
+
var import_keys2 = require("@dxos/keys");
|
|
657
|
+
var import_log2 = require("@dxos/log");
|
|
546
658
|
var import_protocols = require("@dxos/protocols");
|
|
547
659
|
function _ts_decorate(decorators, target, key, desc) {
|
|
548
660
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -554,7 +666,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
554
666
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
555
667
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
556
668
|
}
|
|
557
|
-
var
|
|
669
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
558
670
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
559
671
|
var MAX_SIGNALLING_DELAY = 300;
|
|
560
672
|
var ConnectionState;
|
|
@@ -614,21 +726,21 @@ var Connection = class {
|
|
|
614
726
|
this._state = ConnectionState.CREATED;
|
|
615
727
|
this._incomingSignalBuffer = [];
|
|
616
728
|
this._outgoingSignalBuffer = [];
|
|
617
|
-
this.stateChanged = new
|
|
729
|
+
this.stateChanged = new import_async2.Event();
|
|
618
730
|
this.errors = new import_debug.ErrorStream();
|
|
619
|
-
this._instanceId =
|
|
620
|
-
this._signalSendTask = new
|
|
731
|
+
this._instanceId = import_keys2.PublicKey.random().toHex();
|
|
732
|
+
this._signalSendTask = new import_async2.DeferredTask(this._ctx, async () => {
|
|
621
733
|
await this._flushSignalBuffer();
|
|
622
734
|
});
|
|
623
735
|
this._signallingDelay = STARTING_SIGNALLING_DELAY;
|
|
624
|
-
|
|
736
|
+
import_log2.log.trace("dxos.mesh.connection.construct", {
|
|
625
737
|
sessionId: this.sessionId,
|
|
626
738
|
topic: this.topic,
|
|
627
739
|
localPeerId: this.ownId,
|
|
628
740
|
remotePeerId: this.remoteId,
|
|
629
741
|
initiator: this.initiator
|
|
630
742
|
}, {
|
|
631
|
-
F:
|
|
743
|
+
F: __dxlog_file2,
|
|
632
744
|
L: 123,
|
|
633
745
|
S: this,
|
|
634
746
|
C: (f, a) => f(...a)
|
|
@@ -648,7 +760,7 @@ var Connection = class {
|
|
|
648
760
|
*/
|
|
649
761
|
async openConnection() {
|
|
650
762
|
(0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
651
|
-
F:
|
|
763
|
+
F: __dxlog_file2,
|
|
652
764
|
L: 148,
|
|
653
765
|
S: this,
|
|
654
766
|
A: [
|
|
@@ -656,22 +768,22 @@ var Connection = class {
|
|
|
656
768
|
"'Invalid state.'"
|
|
657
769
|
]
|
|
658
770
|
});
|
|
659
|
-
|
|
771
|
+
import_log2.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.begin({
|
|
660
772
|
id: this._instanceId
|
|
661
773
|
}), {
|
|
662
|
-
F:
|
|
774
|
+
F: __dxlog_file2,
|
|
663
775
|
L: 149,
|
|
664
776
|
S: this,
|
|
665
777
|
C: (f, a) => f(...a)
|
|
666
778
|
});
|
|
667
|
-
|
|
779
|
+
import_log2.log.trace("dxos.mesh.connection.open", {
|
|
668
780
|
sessionId: this.sessionId,
|
|
669
781
|
topic: this.topic,
|
|
670
782
|
localPeerId: this.ownId,
|
|
671
783
|
remotePeerId: this.remoteId,
|
|
672
784
|
initiator: this.initiator
|
|
673
785
|
}, {
|
|
674
|
-
F:
|
|
786
|
+
F: __dxlog_file2,
|
|
675
787
|
L: 150,
|
|
676
788
|
S: this,
|
|
677
789
|
C: (f, a) => f(...a)
|
|
@@ -681,8 +793,8 @@ var Connection = class {
|
|
|
681
793
|
this.errors.raise(err);
|
|
682
794
|
});
|
|
683
795
|
this._protocol.stream.on("close", () => {
|
|
684
|
-
(0,
|
|
685
|
-
F:
|
|
796
|
+
(0, import_log2.log)("protocol stream closed", void 0, {
|
|
797
|
+
F: __dxlog_file2,
|
|
686
798
|
L: 167,
|
|
687
799
|
S: this,
|
|
688
800
|
C: (f, a) => f(...a)
|
|
@@ -690,7 +802,7 @@ var Connection = class {
|
|
|
690
802
|
this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
691
803
|
});
|
|
692
804
|
(0, import_invariant.invariant)(!this._transport, void 0, {
|
|
693
|
-
F:
|
|
805
|
+
F: __dxlog_file2,
|
|
694
806
|
L: 171,
|
|
695
807
|
S: this,
|
|
696
808
|
A: [
|
|
@@ -709,8 +821,8 @@ var Connection = class {
|
|
|
709
821
|
});
|
|
710
822
|
this._transport.closed.once(() => {
|
|
711
823
|
this._transport = void 0;
|
|
712
|
-
(0,
|
|
713
|
-
F:
|
|
824
|
+
(0, import_log2.log)("abort triggered by transport close", void 0, {
|
|
825
|
+
F: __dxlog_file2,
|
|
714
826
|
L: 185,
|
|
715
827
|
S: this,
|
|
716
828
|
C: (f, a) => f(...a)
|
|
@@ -718,10 +830,10 @@ var Connection = class {
|
|
|
718
830
|
this.abort().catch((err) => this.errors.raise(err));
|
|
719
831
|
});
|
|
720
832
|
this._transport.errors.handle((err) => {
|
|
721
|
-
(0,
|
|
833
|
+
(0, import_log2.log)("transport error:", {
|
|
722
834
|
err
|
|
723
835
|
}, {
|
|
724
|
-
F:
|
|
836
|
+
F: __dxlog_file2,
|
|
725
837
|
L: 190,
|
|
726
838
|
S: this,
|
|
727
839
|
C: (f, a) => f(...a)
|
|
@@ -730,26 +842,26 @@ var Connection = class {
|
|
|
730
842
|
this.closeReason = err?.message;
|
|
731
843
|
}
|
|
732
844
|
if (err instanceof import_protocols.ConnectionResetError) {
|
|
733
|
-
(0,
|
|
734
|
-
F:
|
|
845
|
+
(0, import_log2.log)("aborting due to transport ConnectionResetError", void 0, {
|
|
846
|
+
F: __dxlog_file2,
|
|
735
847
|
L: 197,
|
|
736
848
|
S: this,
|
|
737
849
|
C: (f, a) => f(...a)
|
|
738
850
|
});
|
|
739
851
|
this.abort().catch((err2) => this.errors.raise(err2));
|
|
740
852
|
} else if (err instanceof import_protocols.ConnectivityError) {
|
|
741
|
-
(0,
|
|
742
|
-
F:
|
|
853
|
+
(0, import_log2.log)("aborting due to transport ConnectivityError", void 0, {
|
|
854
|
+
F: __dxlog_file2,
|
|
743
855
|
L: 200,
|
|
744
856
|
S: this,
|
|
745
857
|
C: (f, a) => f(...a)
|
|
746
858
|
});
|
|
747
859
|
this.abort().catch((err2) => this.errors.raise(err2));
|
|
748
860
|
} else if (err instanceof import_protocols.UnknownProtocolError) {
|
|
749
|
-
(0,
|
|
861
|
+
(0, import_log2.log)("unsure what to do for UnknownProtocolError", {
|
|
750
862
|
err
|
|
751
863
|
}, {
|
|
752
|
-
F:
|
|
864
|
+
F: __dxlog_file2,
|
|
753
865
|
L: 203,
|
|
754
866
|
S: this,
|
|
755
867
|
C: (f, a) => f(...a)
|
|
@@ -763,27 +875,27 @@ var Connection = class {
|
|
|
763
875
|
void this._transport.signal(signal);
|
|
764
876
|
}
|
|
765
877
|
this._incomingSignalBuffer = [];
|
|
766
|
-
|
|
878
|
+
import_log2.log.trace("dxos.mesh.connection.open-connection", import_protocols.trace.end({
|
|
767
879
|
id: this._instanceId
|
|
768
880
|
}), {
|
|
769
|
-
F:
|
|
881
|
+
F: __dxlog_file2,
|
|
770
882
|
L: 218,
|
|
771
883
|
S: this,
|
|
772
884
|
C: (f, a) => f(...a)
|
|
773
885
|
});
|
|
774
886
|
}
|
|
775
887
|
async abort(err) {
|
|
776
|
-
(0,
|
|
888
|
+
(0, import_log2.log)("aborting...", {
|
|
777
889
|
err
|
|
778
890
|
}, {
|
|
779
|
-
F:
|
|
891
|
+
F: __dxlog_file2,
|
|
780
892
|
L: 224,
|
|
781
893
|
S: this,
|
|
782
894
|
C: (f, a) => f(...a)
|
|
783
895
|
});
|
|
784
896
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
785
|
-
(0,
|
|
786
|
-
F:
|
|
897
|
+
(0, import_log2.log)(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
898
|
+
F: __dxlog_file2,
|
|
787
899
|
L: 226,
|
|
788
900
|
S: this,
|
|
789
901
|
C: (f, a) => f(...a)
|
|
@@ -796,18 +908,18 @@ var Connection = class {
|
|
|
796
908
|
}
|
|
797
909
|
await this._ctx.dispose();
|
|
798
910
|
try {
|
|
799
|
-
(0,
|
|
911
|
+
(0, import_log2.log)("aborting protocol... ", {
|
|
800
912
|
proto: this._protocol
|
|
801
913
|
}, {
|
|
802
|
-
F:
|
|
914
|
+
F: __dxlog_file2,
|
|
803
915
|
L: 239,
|
|
804
916
|
S: this,
|
|
805
917
|
C: (f, a) => f(...a)
|
|
806
918
|
});
|
|
807
919
|
await this._protocol.abort();
|
|
808
920
|
} catch (err2) {
|
|
809
|
-
|
|
810
|
-
F:
|
|
921
|
+
import_log2.log.catch(err2, void 0, {
|
|
922
|
+
F: __dxlog_file2,
|
|
811
923
|
L: 242,
|
|
812
924
|
S: this,
|
|
813
925
|
C: (f, a) => f(...a)
|
|
@@ -816,8 +928,8 @@ var Connection = class {
|
|
|
816
928
|
try {
|
|
817
929
|
await this._transport?.destroy();
|
|
818
930
|
} catch (err2) {
|
|
819
|
-
|
|
820
|
-
F:
|
|
931
|
+
import_log2.log.catch(err2, void 0, {
|
|
932
|
+
F: __dxlog_file2,
|
|
821
933
|
L: 249,
|
|
822
934
|
S: this,
|
|
823
935
|
C: (f, a) => f(...a)
|
|
@@ -826,8 +938,8 @@ var Connection = class {
|
|
|
826
938
|
try {
|
|
827
939
|
this._callbacks?.onClosed?.(err);
|
|
828
940
|
} catch (err2) {
|
|
829
|
-
|
|
830
|
-
F:
|
|
941
|
+
import_log2.log.catch(err2, void 0, {
|
|
942
|
+
F: __dxlog_file2,
|
|
831
943
|
L: 255,
|
|
832
944
|
S: this,
|
|
833
945
|
C: (f, a) => f(...a)
|
|
@@ -845,10 +957,10 @@ var Connection = class {
|
|
|
845
957
|
const lastState = this._state;
|
|
846
958
|
this._changeState(ConnectionState.CLOSING);
|
|
847
959
|
await this._ctx.dispose();
|
|
848
|
-
(0,
|
|
960
|
+
(0, import_log2.log)("closing...", {
|
|
849
961
|
peerId: this.ownId
|
|
850
962
|
}, {
|
|
851
|
-
F:
|
|
963
|
+
F: __dxlog_file2,
|
|
852
964
|
L: 277,
|
|
853
965
|
S: this,
|
|
854
966
|
C: (f, a) => f(...a)
|
|
@@ -857,8 +969,8 @@ var Connection = class {
|
|
|
857
969
|
try {
|
|
858
970
|
await this._protocol.close();
|
|
859
971
|
} catch (err2) {
|
|
860
|
-
|
|
861
|
-
F:
|
|
972
|
+
import_log2.log.catch(err2, void 0, {
|
|
973
|
+
F: __dxlog_file2,
|
|
862
974
|
L: 284,
|
|
863
975
|
S: this,
|
|
864
976
|
C: (f, a) => f(...a)
|
|
@@ -867,18 +979,18 @@ var Connection = class {
|
|
|
867
979
|
try {
|
|
868
980
|
await this._transport?.destroy();
|
|
869
981
|
} catch (err2) {
|
|
870
|
-
|
|
871
|
-
F:
|
|
982
|
+
import_log2.log.catch(err2, void 0, {
|
|
983
|
+
F: __dxlog_file2,
|
|
872
984
|
L: 291,
|
|
873
985
|
S: this,
|
|
874
986
|
C: (f, a) => f(...a)
|
|
875
987
|
});
|
|
876
988
|
}
|
|
877
989
|
}
|
|
878
|
-
(0,
|
|
990
|
+
(0, import_log2.log)("closed", {
|
|
879
991
|
peerId: this.ownId
|
|
880
992
|
}, {
|
|
881
|
-
F:
|
|
993
|
+
F: __dxlog_file2,
|
|
882
994
|
L: 295,
|
|
883
995
|
S: this,
|
|
884
996
|
C: (f, a) => f(...a)
|
|
@@ -896,7 +1008,7 @@ var Connection = class {
|
|
|
896
1008
|
}
|
|
897
1009
|
try {
|
|
898
1010
|
if (process.env.NODE_ENV !== "test") {
|
|
899
|
-
await (0, import_context.cancelWithContext)(this._ctx, (0,
|
|
1011
|
+
await (0, import_context.cancelWithContext)(this._ctx, (0, import_async2.sleep)(this._signallingDelay));
|
|
900
1012
|
this._signallingDelay = Math.min(this._signallingDelay * 2, MAX_SIGNALLING_DELAY);
|
|
901
1013
|
}
|
|
902
1014
|
const signals = [
|
|
@@ -918,10 +1030,10 @@ var Connection = class {
|
|
|
918
1030
|
if (err instanceof import_protocols.CancelledError) {
|
|
919
1031
|
return;
|
|
920
1032
|
}
|
|
921
|
-
|
|
1033
|
+
import_log2.log.warn("signal failed", {
|
|
922
1034
|
err
|
|
923
1035
|
}, {
|
|
924
|
-
F:
|
|
1036
|
+
F: __dxlog_file2,
|
|
925
1037
|
L: 332,
|
|
926
1038
|
S: this,
|
|
927
1039
|
C: (f, a) => f(...a)
|
|
@@ -934,7 +1046,7 @@ var Connection = class {
|
|
|
934
1046
|
*/
|
|
935
1047
|
async signal(msg) {
|
|
936
1048
|
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
937
|
-
F:
|
|
1049
|
+
F: __dxlog_file2,
|
|
938
1050
|
L: 341,
|
|
939
1051
|
S: this,
|
|
940
1052
|
A: [
|
|
@@ -943,8 +1055,8 @@ var Connection = class {
|
|
|
943
1055
|
]
|
|
944
1056
|
});
|
|
945
1057
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
946
|
-
(0,
|
|
947
|
-
F:
|
|
1058
|
+
(0, import_log2.log)("dropping signal for incorrect session id", void 0, {
|
|
1059
|
+
F: __dxlog_file2,
|
|
948
1060
|
L: 343,
|
|
949
1061
|
S: this,
|
|
950
1062
|
C: (f, a) => f(...a)
|
|
@@ -952,7 +1064,7 @@ var Connection = class {
|
|
|
952
1064
|
return;
|
|
953
1065
|
}
|
|
954
1066
|
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
955
|
-
F:
|
|
1067
|
+
F: __dxlog_file2,
|
|
956
1068
|
L: 346,
|
|
957
1069
|
S: this,
|
|
958
1070
|
A: [
|
|
@@ -961,7 +1073,7 @@ var Connection = class {
|
|
|
961
1073
|
]
|
|
962
1074
|
});
|
|
963
1075
|
(0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
|
|
964
|
-
F:
|
|
1076
|
+
F: __dxlog_file2,
|
|
965
1077
|
L: 347,
|
|
966
1078
|
S: this,
|
|
967
1079
|
A: [
|
|
@@ -970,7 +1082,7 @@ var Connection = class {
|
|
|
970
1082
|
]
|
|
971
1083
|
});
|
|
972
1084
|
(0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
|
|
973
|
-
F:
|
|
1085
|
+
F: __dxlog_file2,
|
|
974
1086
|
L: 348,
|
|
975
1087
|
S: this,
|
|
976
1088
|
A: [
|
|
@@ -989,12 +1101,12 @@ var Connection = class {
|
|
|
989
1101
|
ConnectionState.CREATED,
|
|
990
1102
|
ConnectionState.INITIAL
|
|
991
1103
|
].includes(this.state)) {
|
|
992
|
-
(0,
|
|
1104
|
+
(0, import_log2.log)("buffered signal", {
|
|
993
1105
|
peerId: this.ownId,
|
|
994
1106
|
remoteId: this.remoteId,
|
|
995
1107
|
msg: msg.data
|
|
996
1108
|
}, {
|
|
997
|
-
F:
|
|
1109
|
+
F: __dxlog_file2,
|
|
998
1110
|
L: 357,
|
|
999
1111
|
S: this,
|
|
1000
1112
|
C: (f, a) => f(...a)
|
|
@@ -1002,7 +1114,7 @@ var Connection = class {
|
|
|
1002
1114
|
this._incomingSignalBuffer.push(signal);
|
|
1003
1115
|
} else {
|
|
1004
1116
|
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
1005
|
-
F:
|
|
1117
|
+
F: __dxlog_file2,
|
|
1006
1118
|
L: 360,
|
|
1007
1119
|
S: this,
|
|
1008
1120
|
A: [
|
|
@@ -1010,12 +1122,12 @@ var Connection = class {
|
|
|
1010
1122
|
"'Connection not ready to accept signals.'"
|
|
1011
1123
|
]
|
|
1012
1124
|
});
|
|
1013
|
-
(0,
|
|
1125
|
+
(0, import_log2.log)("received signal", {
|
|
1014
1126
|
peerId: this.ownId,
|
|
1015
1127
|
remoteId: this.remoteId,
|
|
1016
1128
|
msg: msg.data
|
|
1017
1129
|
}, {
|
|
1018
|
-
F:
|
|
1130
|
+
F: __dxlog_file2,
|
|
1019
1131
|
L: 361,
|
|
1020
1132
|
S: this,
|
|
1021
1133
|
C: (f, a) => f(...a)
|
|
@@ -1028,18 +1140,18 @@ var Connection = class {
|
|
|
1028
1140
|
this._changeState(ConnectionState.INITIAL);
|
|
1029
1141
|
}
|
|
1030
1142
|
_changeState(state) {
|
|
1031
|
-
(0,
|
|
1143
|
+
(0, import_log2.log)("stateChanged", {
|
|
1032
1144
|
from: this._state,
|
|
1033
1145
|
to: state,
|
|
1034
1146
|
peerId: this.ownId
|
|
1035
1147
|
}, {
|
|
1036
|
-
F:
|
|
1148
|
+
F: __dxlog_file2,
|
|
1037
1149
|
L: 372,
|
|
1038
1150
|
S: this,
|
|
1039
1151
|
C: (f, a) => f(...a)
|
|
1040
1152
|
});
|
|
1041
1153
|
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
1042
|
-
F:
|
|
1154
|
+
F: __dxlog_file2,
|
|
1043
1155
|
L: 373,
|
|
1044
1156
|
S: this,
|
|
1045
1157
|
A: [
|
|
@@ -1052,295 +1164,63 @@ var Connection = class {
|
|
|
1052
1164
|
}
|
|
1053
1165
|
};
|
|
1054
1166
|
_ts_decorate([
|
|
1055
|
-
|
|
1167
|
+
import_async2.synchronized
|
|
1056
1168
|
], Connection.prototype, "abort", null);
|
|
1057
1169
|
_ts_decorate([
|
|
1058
|
-
|
|
1170
|
+
import_async2.synchronized
|
|
1059
1171
|
], Connection.prototype, "close", null);
|
|
1060
1172
|
|
|
1061
1173
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
1062
|
-
var
|
|
1174
|
+
var import_async4 = require("@dxos/async");
|
|
1063
1175
|
var import_context4 = require("@dxos/context");
|
|
1064
1176
|
var import_debug2 = require("@dxos/debug");
|
|
1065
1177
|
var import_invariant4 = require("@dxos/invariant");
|
|
1066
|
-
var
|
|
1067
|
-
var
|
|
1178
|
+
var import_keys5 = require("@dxos/keys");
|
|
1179
|
+
var import_log5 = require("@dxos/log");
|
|
1068
1180
|
var import_protocols4 = require("@dxos/protocols");
|
|
1069
|
-
var
|
|
1181
|
+
var import_util3 = require("@dxos/util");
|
|
1070
1182
|
|
|
1071
|
-
// packages/core/mesh/network-manager/src/
|
|
1183
|
+
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
1184
|
+
var import_async3 = require("@dxos/async");
|
|
1072
1185
|
var import_context2 = require("@dxos/context");
|
|
1073
1186
|
var import_invariant2 = require("@dxos/invariant");
|
|
1074
|
-
var
|
|
1075
|
-
var
|
|
1187
|
+
var import_keys3 = require("@dxos/keys");
|
|
1188
|
+
var import_log3 = require("@dxos/log");
|
|
1076
1189
|
var import_protocols2 = require("@dxos/protocols");
|
|
1077
|
-
|
|
1078
|
-
var
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1190
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1191
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1192
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1193
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1194
|
+
else
|
|
1195
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1196
|
+
if (d = decorators[i])
|
|
1197
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1198
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1199
|
+
}
|
|
1200
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
1201
|
+
var ConnectionDisplacedError = class extends import_protocols2.SystemError {
|
|
1202
|
+
constructor() {
|
|
1203
|
+
super("Connection displaced by remote initiator.");
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
1207
|
+
var Peer = class {
|
|
1208
|
+
// TODO(burdon): Convert to map?
|
|
1209
|
+
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
1210
|
+
this.id = id;
|
|
1211
|
+
this.topic = topic;
|
|
1212
|
+
this.localPeerId = localPeerId;
|
|
1213
|
+
this._signalMessaging = _signalMessaging;
|
|
1214
|
+
this._protocolProvider = _protocolProvider;
|
|
1215
|
+
this._transportFactory = _transportFactory;
|
|
1216
|
+
this._connectionLimiter = _connectionLimiter;
|
|
1217
|
+
this._callbacks = _callbacks;
|
|
1218
|
+
this._availableAfter = 0;
|
|
1219
|
+
this.availableToConnect = true;
|
|
1082
1220
|
this._ctx = new import_context2.Context();
|
|
1083
|
-
this.
|
|
1084
|
-
this.
|
|
1085
|
-
this.
|
|
1086
|
-
this._onOffer = onOffer;
|
|
1087
|
-
this._topic = topic;
|
|
1088
|
-
}
|
|
1089
|
-
async receiveMessage({ author, recipient, payload }) {
|
|
1090
|
-
if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
const message = SwarmMessage.decode(payload.value);
|
|
1094
|
-
if (!this._topic.equals(message.topic)) {
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
(0, import_log2.log)("received", {
|
|
1098
|
-
from: author,
|
|
1099
|
-
to: recipient,
|
|
1100
|
-
msg: message
|
|
1101
|
-
}, {
|
|
1102
|
-
F: __dxlog_file2,
|
|
1103
|
-
L: 69,
|
|
1104
|
-
S: this,
|
|
1105
|
-
C: (f, a) => f(...a)
|
|
1106
|
-
});
|
|
1107
|
-
if (message.data?.offer) {
|
|
1108
|
-
await this._handleOffer({
|
|
1109
|
-
author,
|
|
1110
|
-
recipient,
|
|
1111
|
-
message
|
|
1112
|
-
});
|
|
1113
|
-
} else if (message.data?.answer) {
|
|
1114
|
-
await this._resolveAnswers(message);
|
|
1115
|
-
} else if (message.data?.signal) {
|
|
1116
|
-
await this._handleSignal({
|
|
1117
|
-
author,
|
|
1118
|
-
recipient,
|
|
1119
|
-
message
|
|
1120
|
-
});
|
|
1121
|
-
} else if (message.data?.signalBatch) {
|
|
1122
|
-
await this._handleSignal({
|
|
1123
|
-
author,
|
|
1124
|
-
recipient,
|
|
1125
|
-
message
|
|
1126
|
-
});
|
|
1127
|
-
} else {
|
|
1128
|
-
import_log2.log.warn("unknown message", {
|
|
1129
|
-
message
|
|
1130
|
-
}, {
|
|
1131
|
-
F: __dxlog_file2,
|
|
1132
|
-
L: 80,
|
|
1133
|
-
S: this,
|
|
1134
|
-
C: (f, a) => f(...a)
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
async signal(message) {
|
|
1139
|
-
(0, import_invariant2.invariant)(message.data?.signal || message.data?.signalBatch, "Invalid message", {
|
|
1140
|
-
F: __dxlog_file2,
|
|
1141
|
-
L: 85,
|
|
1142
|
-
S: this,
|
|
1143
|
-
A: [
|
|
1144
|
-
"message.data?.signal || message.data?.signalBatch",
|
|
1145
|
-
"'Invalid message'"
|
|
1146
|
-
]
|
|
1147
|
-
});
|
|
1148
|
-
await this._sendReliableMessage({
|
|
1149
|
-
author: message.author,
|
|
1150
|
-
recipient: message.recipient,
|
|
1151
|
-
message
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
async offer(message) {
|
|
1155
|
-
const networkMessage = {
|
|
1156
|
-
...message,
|
|
1157
|
-
messageId: import_keys2.PublicKey.random()
|
|
1158
|
-
};
|
|
1159
|
-
return new Promise((resolve, reject) => {
|
|
1160
|
-
this._offerRecords.set(networkMessage.messageId, {
|
|
1161
|
-
resolve
|
|
1162
|
-
});
|
|
1163
|
-
this._sendReliableMessage({
|
|
1164
|
-
author: message.author,
|
|
1165
|
-
recipient: message.recipient,
|
|
1166
|
-
message: networkMessage
|
|
1167
|
-
}).catch((err) => reject(err));
|
|
1168
|
-
});
|
|
1169
|
-
}
|
|
1170
|
-
async _sendReliableMessage({ author, recipient, message }) {
|
|
1171
|
-
const networkMessage = {
|
|
1172
|
-
...message,
|
|
1173
|
-
// Setting unique message_id if it not specified yet.
|
|
1174
|
-
messageId: message.messageId ?? import_keys2.PublicKey.random()
|
|
1175
|
-
};
|
|
1176
|
-
(0, import_log2.log)("sending", {
|
|
1177
|
-
from: author,
|
|
1178
|
-
to: recipient,
|
|
1179
|
-
msg: networkMessage
|
|
1180
|
-
}, {
|
|
1181
|
-
F: __dxlog_file2,
|
|
1182
|
-
L: 123,
|
|
1183
|
-
S: this,
|
|
1184
|
-
C: (f, a) => f(...a)
|
|
1185
|
-
});
|
|
1186
|
-
await this._sendMessage({
|
|
1187
|
-
author,
|
|
1188
|
-
recipient,
|
|
1189
|
-
payload: {
|
|
1190
|
-
type_url: "dxos.mesh.swarm.SwarmMessage",
|
|
1191
|
-
value: SwarmMessage.encode(networkMessage)
|
|
1192
|
-
}
|
|
1193
|
-
});
|
|
1194
|
-
}
|
|
1195
|
-
async _resolveAnswers(message) {
|
|
1196
|
-
(0, import_invariant2.invariant)(message.data?.answer?.offerMessageId, "No offerMessageId", {
|
|
1197
|
-
F: __dxlog_file2,
|
|
1198
|
-
L: 135,
|
|
1199
|
-
S: this,
|
|
1200
|
-
A: [
|
|
1201
|
-
"message.data?.answer?.offerMessageId",
|
|
1202
|
-
"'No offerMessageId'"
|
|
1203
|
-
]
|
|
1204
|
-
});
|
|
1205
|
-
const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
|
|
1206
|
-
if (offerRecord) {
|
|
1207
|
-
this._offerRecords.delete(message.data.answer.offerMessageId);
|
|
1208
|
-
(0, import_invariant2.invariant)(message.data?.answer, "No answer", {
|
|
1209
|
-
F: __dxlog_file2,
|
|
1210
|
-
L: 139,
|
|
1211
|
-
S: this,
|
|
1212
|
-
A: [
|
|
1213
|
-
"message.data?.answer",
|
|
1214
|
-
"'No answer'"
|
|
1215
|
-
]
|
|
1216
|
-
});
|
|
1217
|
-
(0, import_log2.log)("resolving", {
|
|
1218
|
-
answer: message.data.answer
|
|
1219
|
-
}, {
|
|
1220
|
-
F: __dxlog_file2,
|
|
1221
|
-
L: 140,
|
|
1222
|
-
S: this,
|
|
1223
|
-
C: (f, a) => f(...a)
|
|
1224
|
-
});
|
|
1225
|
-
offerRecord.resolve(message.data.answer);
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
async _handleOffer({ author, recipient, message }) {
|
|
1229
|
-
(0, import_invariant2.invariant)(message.data.offer, "No offer", {
|
|
1230
|
-
F: __dxlog_file2,
|
|
1231
|
-
L: 154,
|
|
1232
|
-
S: this,
|
|
1233
|
-
A: [
|
|
1234
|
-
"message.data.offer",
|
|
1235
|
-
"'No offer'"
|
|
1236
|
-
]
|
|
1237
|
-
});
|
|
1238
|
-
const offerMessage = {
|
|
1239
|
-
author,
|
|
1240
|
-
recipient,
|
|
1241
|
-
...message,
|
|
1242
|
-
data: {
|
|
1243
|
-
offer: message.data.offer
|
|
1244
|
-
}
|
|
1245
|
-
};
|
|
1246
|
-
const answer = await this._onOffer(offerMessage);
|
|
1247
|
-
answer.offerMessageId = message.messageId;
|
|
1248
|
-
try {
|
|
1249
|
-
await this._sendReliableMessage({
|
|
1250
|
-
author: recipient,
|
|
1251
|
-
recipient: author,
|
|
1252
|
-
message: {
|
|
1253
|
-
topic: message.topic,
|
|
1254
|
-
sessionId: message.sessionId,
|
|
1255
|
-
data: {
|
|
1256
|
-
answer
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1260
|
-
} catch (err) {
|
|
1261
|
-
import_log2.log.warn("error sending answer", {
|
|
1262
|
-
err
|
|
1263
|
-
}, {
|
|
1264
|
-
F: __dxlog_file2,
|
|
1265
|
-
L: 174,
|
|
1266
|
-
S: this,
|
|
1267
|
-
C: (f, a) => f(...a)
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
async _handleSignal({ author, recipient, message }) {
|
|
1272
|
-
(0, import_invariant2.invariant)(message.messageId, void 0, {
|
|
1273
|
-
F: __dxlog_file2,
|
|
1274
|
-
L: 187,
|
|
1275
|
-
S: this,
|
|
1276
|
-
A: [
|
|
1277
|
-
"message.messageId",
|
|
1278
|
-
""
|
|
1279
|
-
]
|
|
1280
|
-
});
|
|
1281
|
-
(0, import_invariant2.invariant)(message.data.signal || message.data.signalBatch, "Invalid message", {
|
|
1282
|
-
F: __dxlog_file2,
|
|
1283
|
-
L: 188,
|
|
1284
|
-
S: this,
|
|
1285
|
-
A: [
|
|
1286
|
-
"message.data.signal || message.data.signalBatch",
|
|
1287
|
-
"'Invalid message'"
|
|
1288
|
-
]
|
|
1289
|
-
});
|
|
1290
|
-
const signalMessage = {
|
|
1291
|
-
author,
|
|
1292
|
-
recipient,
|
|
1293
|
-
...message,
|
|
1294
|
-
data: {
|
|
1295
|
-
signal: message.data.signal,
|
|
1296
|
-
signalBatch: message.data.signalBatch
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
await this._onSignal(signalMessage);
|
|
1300
|
-
}
|
|
1301
|
-
};
|
|
1302
|
-
|
|
1303
|
-
// packages/core/mesh/network-manager/src/swarm/peer.ts
|
|
1304
|
-
var import_async2 = require("@dxos/async");
|
|
1305
|
-
var import_context3 = require("@dxos/context");
|
|
1306
|
-
var import_invariant3 = require("@dxos/invariant");
|
|
1307
|
-
var import_keys3 = require("@dxos/keys");
|
|
1308
|
-
var import_log3 = require("@dxos/log");
|
|
1309
|
-
var import_protocols3 = require("@dxos/protocols");
|
|
1310
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
1311
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1312
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1313
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
1314
|
-
else
|
|
1315
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1316
|
-
if (d = decorators[i])
|
|
1317
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1318
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1319
|
-
}
|
|
1320
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
1321
|
-
var ConnectionDisplacedError = class extends import_protocols3.SystemError {
|
|
1322
|
-
constructor() {
|
|
1323
|
-
super("Connection displaced by remote initiator.");
|
|
1324
|
-
}
|
|
1325
|
-
};
|
|
1326
|
-
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
1327
|
-
var Peer = class {
|
|
1328
|
-
// TODO(burdon): Convert to map?
|
|
1329
|
-
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
1330
|
-
this.id = id;
|
|
1331
|
-
this.topic = topic;
|
|
1332
|
-
this.localPeerId = localPeerId;
|
|
1333
|
-
this._signalMessaging = _signalMessaging;
|
|
1334
|
-
this._protocolProvider = _protocolProvider;
|
|
1335
|
-
this._transportFactory = _transportFactory;
|
|
1336
|
-
this._connectionLimiter = _connectionLimiter;
|
|
1337
|
-
this._callbacks = _callbacks;
|
|
1338
|
-
this._availableAfter = 0;
|
|
1339
|
-
this.availableToConnect = true;
|
|
1340
|
-
this._ctx = new import_context3.Context();
|
|
1341
|
-
this.advertizing = false;
|
|
1342
|
-
this.initiating = false;
|
|
1343
|
-
this.connectionDisplaced = new import_async2.Event();
|
|
1221
|
+
this.advertizing = false;
|
|
1222
|
+
this.initiating = false;
|
|
1223
|
+
this.connectionDisplaced = new import_async3.Event();
|
|
1344
1224
|
}
|
|
1345
1225
|
/**
|
|
1346
1226
|
* Respond to remote offer.
|
|
@@ -1371,7 +1251,7 @@ var Peer = class {
|
|
|
1371
1251
|
}
|
|
1372
1252
|
if (await this._callbacks.onOffer(remoteId)) {
|
|
1373
1253
|
if (!this.connection) {
|
|
1374
|
-
(0,
|
|
1254
|
+
(0, import_invariant2.invariant)(message.sessionId, void 0, {
|
|
1375
1255
|
F: __dxlog_file3,
|
|
1376
1256
|
L: 137,
|
|
1377
1257
|
S: this,
|
|
@@ -1386,7 +1266,7 @@ var Peer = class {
|
|
|
1386
1266
|
connection.initiate();
|
|
1387
1267
|
await connection.openConnection();
|
|
1388
1268
|
} catch (err) {
|
|
1389
|
-
if (!(err instanceof
|
|
1269
|
+
if (!(err instanceof import_protocols2.CancelledError)) {
|
|
1390
1270
|
import_log3.log.warn("connection error", {
|
|
1391
1271
|
topic: this.topic,
|
|
1392
1272
|
peerId: this.localPeerId,
|
|
@@ -1414,7 +1294,7 @@ var Peer = class {
|
|
|
1414
1294
|
* Initiate a connection to the remote peer.
|
|
1415
1295
|
*/
|
|
1416
1296
|
async initiateConnection() {
|
|
1417
|
-
(0,
|
|
1297
|
+
(0, import_invariant2.invariant)(!this.initiating, "Initiation in progress.", {
|
|
1418
1298
|
F: __dxlog_file3,
|
|
1419
1299
|
L: 164,
|
|
1420
1300
|
S: this,
|
|
@@ -1423,7 +1303,7 @@ var Peer = class {
|
|
|
1423
1303
|
"'Initiation in progress.'"
|
|
1424
1304
|
]
|
|
1425
1305
|
});
|
|
1426
|
-
(0,
|
|
1306
|
+
(0, import_invariant2.invariant)(!this.connection, "Already connected.", {
|
|
1427
1307
|
F: __dxlog_file3,
|
|
1428
1308
|
L: 165,
|
|
1429
1309
|
S: this,
|
|
@@ -1496,7 +1376,7 @@ var Peer = class {
|
|
|
1496
1376
|
S: this,
|
|
1497
1377
|
C: (f, a) => f(...a)
|
|
1498
1378
|
});
|
|
1499
|
-
if (err instanceof
|
|
1379
|
+
if (err instanceof import_protocols2.TimeoutError) {
|
|
1500
1380
|
await connection.abort(err);
|
|
1501
1381
|
}
|
|
1502
1382
|
await this.closeConnection(err);
|
|
@@ -1522,7 +1402,7 @@ var Peer = class {
|
|
|
1522
1402
|
S: this,
|
|
1523
1403
|
C: (f, a) => f(...a)
|
|
1524
1404
|
});
|
|
1525
|
-
(0,
|
|
1405
|
+
(0, import_invariant2.invariant)(!this.connection, "Already connected.", {
|
|
1526
1406
|
F: __dxlog_file3,
|
|
1527
1407
|
L: 220,
|
|
1528
1408
|
S: this,
|
|
@@ -1578,7 +1458,7 @@ var Peer = class {
|
|
|
1578
1458
|
C: (f, a) => f(...a)
|
|
1579
1459
|
});
|
|
1580
1460
|
this._connectionLimiter.doneConnecting(sessionId);
|
|
1581
|
-
(0,
|
|
1461
|
+
(0, import_invariant2.invariant)(this.connection === connection, "Connection mismatch (race condition).", {
|
|
1582
1462
|
F: __dxlog_file3,
|
|
1583
1463
|
L: 253,
|
|
1584
1464
|
S: this,
|
|
@@ -1609,7 +1489,7 @@ var Peer = class {
|
|
|
1609
1489
|
this._availableAfter = increaseInterval(this._availableAfter);
|
|
1610
1490
|
}
|
|
1611
1491
|
this._callbacks.onDisconnected();
|
|
1612
|
-
(0,
|
|
1492
|
+
(0, import_async3.scheduleTask)(this._connectionCtx, () => {
|
|
1613
1493
|
this.availableToConnect = true;
|
|
1614
1494
|
this._callbacks.onPeerAvailable();
|
|
1615
1495
|
}, this._availableAfter);
|
|
@@ -1649,76 +1529,308 @@ var Peer = class {
|
|
|
1649
1529
|
});
|
|
1650
1530
|
void this.closeConnection(err);
|
|
1651
1531
|
});
|
|
1652
|
-
this.connection = connection;
|
|
1653
|
-
return connection;
|
|
1532
|
+
this.connection = connection;
|
|
1533
|
+
return connection;
|
|
1534
|
+
}
|
|
1535
|
+
async closeConnection(err) {
|
|
1536
|
+
if (!this.connection) {
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
const connection = this.connection;
|
|
1540
|
+
(0, import_log3.log)("closing...", {
|
|
1541
|
+
peerId: this.id,
|
|
1542
|
+
sessionId: connection.sessionId
|
|
1543
|
+
}, {
|
|
1544
|
+
F: __dxlog_file3,
|
|
1545
|
+
L: 321,
|
|
1546
|
+
S: this,
|
|
1547
|
+
C: (f, a) => f(...a)
|
|
1548
|
+
});
|
|
1549
|
+
await connection.close(err);
|
|
1550
|
+
(0, import_log3.log)("closed", {
|
|
1551
|
+
peerId: this.id,
|
|
1552
|
+
sessionId: connection.sessionId
|
|
1553
|
+
}, {
|
|
1554
|
+
F: __dxlog_file3,
|
|
1555
|
+
L: 327,
|
|
1556
|
+
S: this,
|
|
1557
|
+
C: (f, a) => f(...a)
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
async onSignal(message) {
|
|
1561
|
+
if (!this.connection) {
|
|
1562
|
+
(0, import_log3.log)("dropping signal message for non-existent connection", {
|
|
1563
|
+
message
|
|
1564
|
+
}, {
|
|
1565
|
+
F: __dxlog_file3,
|
|
1566
|
+
L: 332,
|
|
1567
|
+
S: this,
|
|
1568
|
+
C: (f, a) => f(...a)
|
|
1569
|
+
});
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
await this.connection.signal(message);
|
|
1573
|
+
}
|
|
1574
|
+
async destroy() {
|
|
1575
|
+
await this._ctx.dispose();
|
|
1576
|
+
(0, import_log3.log)("Destroying peer", {
|
|
1577
|
+
peerId: this.id,
|
|
1578
|
+
topic: this.topic
|
|
1579
|
+
}, {
|
|
1580
|
+
F: __dxlog_file3,
|
|
1581
|
+
L: 342,
|
|
1582
|
+
S: this,
|
|
1583
|
+
C: (f, a) => f(...a)
|
|
1584
|
+
});
|
|
1585
|
+
await this?.connection?.close();
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
_ts_decorate2([
|
|
1589
|
+
import_async3.synchronized
|
|
1590
|
+
], Peer.prototype, "destroy", null);
|
|
1591
|
+
var increaseInterval = (interval) => {
|
|
1592
|
+
if (interval === 0) {
|
|
1593
|
+
return 50;
|
|
1594
|
+
} else if (interval < 500) {
|
|
1595
|
+
return 500;
|
|
1596
|
+
} else if (interval < 1e3) {
|
|
1597
|
+
return 1e3;
|
|
1598
|
+
} else if (interval < 5e3) {
|
|
1599
|
+
return 5e3;
|
|
1600
|
+
}
|
|
1601
|
+
return 1e4;
|
|
1602
|
+
};
|
|
1603
|
+
|
|
1604
|
+
// packages/core/mesh/network-manager/src/signal/swarm-messenger.ts
|
|
1605
|
+
var import_context3 = require("@dxos/context");
|
|
1606
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
1607
|
+
var import_keys4 = require("@dxos/keys");
|
|
1608
|
+
var import_log4 = require("@dxos/log");
|
|
1609
|
+
var import_protocols3 = require("@dxos/protocols");
|
|
1610
|
+
var import_util2 = require("@dxos/util");
|
|
1611
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
1612
|
+
var SwarmMessage = import_protocols3.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
1613
|
+
var SwarmMessenger = class {
|
|
1614
|
+
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
1615
|
+
this._ctx = new import_context3.Context();
|
|
1616
|
+
this._offerRecords = new import_util2.ComplexMap((key) => key.toHex());
|
|
1617
|
+
this._sendMessage = sendMessage;
|
|
1618
|
+
this._onSignal = onSignal;
|
|
1619
|
+
this._onOffer = onOffer;
|
|
1620
|
+
this._topic = topic;
|
|
1621
|
+
}
|
|
1622
|
+
async receiveMessage({ author, recipient, payload }) {
|
|
1623
|
+
if (payload.type_url !== "dxos.mesh.swarm.SwarmMessage") {
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
const message = SwarmMessage.decode(payload.value);
|
|
1627
|
+
if (!this._topic.equals(message.topic)) {
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
(0, import_log4.log)("received", {
|
|
1631
|
+
from: author,
|
|
1632
|
+
to: recipient,
|
|
1633
|
+
msg: message
|
|
1634
|
+
}, {
|
|
1635
|
+
F: __dxlog_file4,
|
|
1636
|
+
L: 69,
|
|
1637
|
+
S: this,
|
|
1638
|
+
C: (f, a) => f(...a)
|
|
1639
|
+
});
|
|
1640
|
+
if (message.data?.offer) {
|
|
1641
|
+
await this._handleOffer({
|
|
1642
|
+
author,
|
|
1643
|
+
recipient,
|
|
1644
|
+
message
|
|
1645
|
+
});
|
|
1646
|
+
} else if (message.data?.answer) {
|
|
1647
|
+
await this._resolveAnswers(message);
|
|
1648
|
+
} else if (message.data?.signal) {
|
|
1649
|
+
await this._handleSignal({
|
|
1650
|
+
author,
|
|
1651
|
+
recipient,
|
|
1652
|
+
message
|
|
1653
|
+
});
|
|
1654
|
+
} else if (message.data?.signalBatch) {
|
|
1655
|
+
await this._handleSignal({
|
|
1656
|
+
author,
|
|
1657
|
+
recipient,
|
|
1658
|
+
message
|
|
1659
|
+
});
|
|
1660
|
+
} else {
|
|
1661
|
+
import_log4.log.warn("unknown message", {
|
|
1662
|
+
message
|
|
1663
|
+
}, {
|
|
1664
|
+
F: __dxlog_file4,
|
|
1665
|
+
L: 80,
|
|
1666
|
+
S: this,
|
|
1667
|
+
C: (f, a) => f(...a)
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
async signal(message) {
|
|
1672
|
+
(0, import_invariant3.invariant)(message.data?.signal || message.data?.signalBatch, "Invalid message", {
|
|
1673
|
+
F: __dxlog_file4,
|
|
1674
|
+
L: 85,
|
|
1675
|
+
S: this,
|
|
1676
|
+
A: [
|
|
1677
|
+
"message.data?.signal || message.data?.signalBatch",
|
|
1678
|
+
"'Invalid message'"
|
|
1679
|
+
]
|
|
1680
|
+
});
|
|
1681
|
+
await this._sendReliableMessage({
|
|
1682
|
+
author: message.author,
|
|
1683
|
+
recipient: message.recipient,
|
|
1684
|
+
message
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
async offer(message) {
|
|
1688
|
+
const networkMessage = {
|
|
1689
|
+
...message,
|
|
1690
|
+
messageId: import_keys4.PublicKey.random()
|
|
1691
|
+
};
|
|
1692
|
+
return new Promise((resolve, reject) => {
|
|
1693
|
+
this._offerRecords.set(networkMessage.messageId, {
|
|
1694
|
+
resolve
|
|
1695
|
+
});
|
|
1696
|
+
this._sendReliableMessage({
|
|
1697
|
+
author: message.author,
|
|
1698
|
+
recipient: message.recipient,
|
|
1699
|
+
message: networkMessage
|
|
1700
|
+
}).catch((err) => reject(err));
|
|
1701
|
+
});
|
|
1654
1702
|
}
|
|
1655
|
-
async
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1703
|
+
async _sendReliableMessage({ author, recipient, message }) {
|
|
1704
|
+
const networkMessage = {
|
|
1705
|
+
...message,
|
|
1706
|
+
// Setting unique message_id if it not specified yet.
|
|
1707
|
+
messageId: message.messageId ?? import_keys4.PublicKey.random()
|
|
1708
|
+
};
|
|
1709
|
+
(0, import_log4.log)("sending", {
|
|
1710
|
+
from: author,
|
|
1711
|
+
to: recipient,
|
|
1712
|
+
msg: networkMessage
|
|
1663
1713
|
}, {
|
|
1664
|
-
F:
|
|
1665
|
-
L:
|
|
1714
|
+
F: __dxlog_file4,
|
|
1715
|
+
L: 123,
|
|
1666
1716
|
S: this,
|
|
1667
1717
|
C: (f, a) => f(...a)
|
|
1668
1718
|
});
|
|
1669
|
-
await
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
S: this,
|
|
1677
|
-
C: (f, a) => f(...a)
|
|
1719
|
+
await this._sendMessage({
|
|
1720
|
+
author,
|
|
1721
|
+
recipient,
|
|
1722
|
+
payload: {
|
|
1723
|
+
type_url: "dxos.mesh.swarm.SwarmMessage",
|
|
1724
|
+
value: SwarmMessage.encode(networkMessage)
|
|
1725
|
+
}
|
|
1678
1726
|
});
|
|
1679
1727
|
}
|
|
1680
|
-
async
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1728
|
+
async _resolveAnswers(message) {
|
|
1729
|
+
(0, import_invariant3.invariant)(message.data?.answer?.offerMessageId, "No offerMessageId", {
|
|
1730
|
+
F: __dxlog_file4,
|
|
1731
|
+
L: 135,
|
|
1732
|
+
S: this,
|
|
1733
|
+
A: [
|
|
1734
|
+
"message.data?.answer?.offerMessageId",
|
|
1735
|
+
"'No offerMessageId'"
|
|
1736
|
+
]
|
|
1737
|
+
});
|
|
1738
|
+
const offerRecord = this._offerRecords.get(message.data.answer.offerMessageId);
|
|
1739
|
+
if (offerRecord) {
|
|
1740
|
+
this._offerRecords.delete(message.data.answer.offerMessageId);
|
|
1741
|
+
(0, import_invariant3.invariant)(message.data?.answer, "No answer", {
|
|
1742
|
+
F: __dxlog_file4,
|
|
1743
|
+
L: 139,
|
|
1744
|
+
S: this,
|
|
1745
|
+
A: [
|
|
1746
|
+
"message.data?.answer",
|
|
1747
|
+
"'No answer'"
|
|
1748
|
+
]
|
|
1749
|
+
});
|
|
1750
|
+
(0, import_log4.log)("resolving", {
|
|
1751
|
+
answer: message.data.answer
|
|
1684
1752
|
}, {
|
|
1685
|
-
F:
|
|
1686
|
-
L:
|
|
1753
|
+
F: __dxlog_file4,
|
|
1754
|
+
L: 140,
|
|
1687
1755
|
S: this,
|
|
1688
1756
|
C: (f, a) => f(...a)
|
|
1689
1757
|
});
|
|
1690
|
-
|
|
1758
|
+
offerRecord.resolve(message.data.answer);
|
|
1691
1759
|
}
|
|
1692
|
-
await this.connection.signal(message);
|
|
1693
1760
|
}
|
|
1694
|
-
async
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
topic: this.topic
|
|
1699
|
-
}, {
|
|
1700
|
-
F: __dxlog_file3,
|
|
1701
|
-
L: 342,
|
|
1761
|
+
async _handleOffer({ author, recipient, message }) {
|
|
1762
|
+
(0, import_invariant3.invariant)(message.data.offer, "No offer", {
|
|
1763
|
+
F: __dxlog_file4,
|
|
1764
|
+
L: 154,
|
|
1702
1765
|
S: this,
|
|
1703
|
-
|
|
1766
|
+
A: [
|
|
1767
|
+
"message.data.offer",
|
|
1768
|
+
"'No offer'"
|
|
1769
|
+
]
|
|
1704
1770
|
});
|
|
1705
|
-
|
|
1771
|
+
const offerMessage = {
|
|
1772
|
+
author,
|
|
1773
|
+
recipient,
|
|
1774
|
+
...message,
|
|
1775
|
+
data: {
|
|
1776
|
+
offer: message.data.offer
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
const answer = await this._onOffer(offerMessage);
|
|
1780
|
+
answer.offerMessageId = message.messageId;
|
|
1781
|
+
try {
|
|
1782
|
+
await this._sendReliableMessage({
|
|
1783
|
+
author: recipient,
|
|
1784
|
+
recipient: author,
|
|
1785
|
+
message: {
|
|
1786
|
+
topic: message.topic,
|
|
1787
|
+
sessionId: message.sessionId,
|
|
1788
|
+
data: {
|
|
1789
|
+
answer
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
} catch (err) {
|
|
1794
|
+
import_log4.log.warn("error sending answer", {
|
|
1795
|
+
err
|
|
1796
|
+
}, {
|
|
1797
|
+
F: __dxlog_file4,
|
|
1798
|
+
L: 174,
|
|
1799
|
+
S: this,
|
|
1800
|
+
C: (f, a) => f(...a)
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1706
1803
|
}
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1804
|
+
async _handleSignal({ author, recipient, message }) {
|
|
1805
|
+
(0, import_invariant3.invariant)(message.messageId, void 0, {
|
|
1806
|
+
F: __dxlog_file4,
|
|
1807
|
+
L: 187,
|
|
1808
|
+
S: this,
|
|
1809
|
+
A: [
|
|
1810
|
+
"message.messageId",
|
|
1811
|
+
""
|
|
1812
|
+
]
|
|
1813
|
+
});
|
|
1814
|
+
(0, import_invariant3.invariant)(message.data.signal || message.data.signalBatch, "Invalid message", {
|
|
1815
|
+
F: __dxlog_file4,
|
|
1816
|
+
L: 188,
|
|
1817
|
+
S: this,
|
|
1818
|
+
A: [
|
|
1819
|
+
"message.data.signal || message.data.signalBatch",
|
|
1820
|
+
"'Invalid message'"
|
|
1821
|
+
]
|
|
1822
|
+
});
|
|
1823
|
+
const signalMessage = {
|
|
1824
|
+
author,
|
|
1825
|
+
recipient,
|
|
1826
|
+
...message,
|
|
1827
|
+
data: {
|
|
1828
|
+
signal: message.data.signal,
|
|
1829
|
+
signalBatch: message.data.signalBatch
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
await this._onSignal(signalMessage);
|
|
1720
1833
|
}
|
|
1721
|
-
return 1e4;
|
|
1722
1834
|
};
|
|
1723
1835
|
|
|
1724
1836
|
// packages/core/mesh/network-manager/src/swarm/swarm.ts
|
|
@@ -1732,7 +1844,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1732
1844
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1733
1845
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1734
1846
|
}
|
|
1735
|
-
var
|
|
1847
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1736
1848
|
var INITIATION_DELAY = 100;
|
|
1737
1849
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1738
1850
|
var Swarm = class {
|
|
@@ -1750,28 +1862,28 @@ var Swarm = class {
|
|
|
1750
1862
|
this._initiationDelay = _initiationDelay;
|
|
1751
1863
|
this._ctx = new import_context4.Context();
|
|
1752
1864
|
this._listeningHandle = void 0;
|
|
1753
|
-
this._peers = new
|
|
1754
|
-
this._instanceId =
|
|
1755
|
-
this.connectionAdded = new
|
|
1756
|
-
this.disconnected = new
|
|
1757
|
-
this.connected = new
|
|
1865
|
+
this._peers = new import_util3.ComplexMap(import_keys5.PublicKey.hash);
|
|
1866
|
+
this._instanceId = import_keys5.PublicKey.random().toHex();
|
|
1867
|
+
this.connectionAdded = new import_async4.Event();
|
|
1868
|
+
this.disconnected = new import_async4.Event();
|
|
1869
|
+
this.connected = new import_async4.Event();
|
|
1758
1870
|
this.errors = new import_debug2.ErrorStream();
|
|
1759
|
-
|
|
1871
|
+
import_log5.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.begin({
|
|
1760
1872
|
id: this._instanceId,
|
|
1761
1873
|
data: {
|
|
1762
1874
|
topic: this._topic.toHex(),
|
|
1763
1875
|
peerId: this._ownPeerId.toHex()
|
|
1764
1876
|
}
|
|
1765
1877
|
}), {
|
|
1766
|
-
F:
|
|
1878
|
+
F: __dxlog_file5,
|
|
1767
1879
|
L: 88,
|
|
1768
1880
|
S: this,
|
|
1769
1881
|
C: (f, a) => f(...a)
|
|
1770
1882
|
});
|
|
1771
|
-
(0,
|
|
1883
|
+
(0, import_log5.log)("creating swarm", {
|
|
1772
1884
|
peerId: _ownPeerId
|
|
1773
1885
|
}, {
|
|
1774
|
-
F:
|
|
1886
|
+
F: __dxlog_file5,
|
|
1775
1887
|
L: 92,
|
|
1776
1888
|
S: this,
|
|
1777
1889
|
C: (f, a) => f(...a)
|
|
@@ -1783,17 +1895,17 @@ var Swarm = class {
|
|
|
1783
1895
|
onOffer: async (msg) => await this.onOffer(msg),
|
|
1784
1896
|
topic: this._topic
|
|
1785
1897
|
});
|
|
1786
|
-
|
|
1898
|
+
import_log5.log.trace("dxos.mesh.swarm.constructor", import_protocols4.trace.end({
|
|
1787
1899
|
id: this._instanceId
|
|
1788
1900
|
}), {
|
|
1789
|
-
F:
|
|
1901
|
+
F: __dxlog_file5,
|
|
1790
1902
|
L: 101,
|
|
1791
1903
|
S: this,
|
|
1792
1904
|
C: (f, a) => f(...a)
|
|
1793
1905
|
});
|
|
1794
1906
|
}
|
|
1795
1907
|
get connections() {
|
|
1796
|
-
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(
|
|
1908
|
+
return Array.from(this._peers.values()).map((peer) => peer.connection).filter(import_util3.isNotNullOrUndefined);
|
|
1797
1909
|
}
|
|
1798
1910
|
get ownPeerId() {
|
|
1799
1911
|
return this._ownPeerId;
|
|
@@ -1809,7 +1921,7 @@ var Swarm = class {
|
|
|
1809
1921
|
}
|
|
1810
1922
|
async open() {
|
|
1811
1923
|
(0, import_invariant4.invariant)(!this._listeningHandle, void 0, {
|
|
1812
|
-
F:
|
|
1924
|
+
F: __dxlog_file5,
|
|
1813
1925
|
L: 128,
|
|
1814
1926
|
S: this,
|
|
1815
1927
|
A: [
|
|
@@ -1821,10 +1933,10 @@ var Swarm = class {
|
|
|
1821
1933
|
peerId: this._ownPeerId,
|
|
1822
1934
|
payloadType: "dxos.mesh.swarm.SwarmMessage",
|
|
1823
1935
|
onMessage: async (message) => {
|
|
1824
|
-
await this._swarmMessenger.receiveMessage(message).catch((err) =>
|
|
1936
|
+
await this._swarmMessenger.receiveMessage(message).catch((err) => import_log5.log.warn("Error while receiving message", {
|
|
1825
1937
|
err
|
|
1826
1938
|
}, {
|
|
1827
|
-
F:
|
|
1939
|
+
F: __dxlog_file5,
|
|
1828
1940
|
L: 135,
|
|
1829
1941
|
S: this,
|
|
1830
1942
|
C: (f, a) => f(...a)
|
|
@@ -1833,8 +1945,8 @@ var Swarm = class {
|
|
|
1833
1945
|
});
|
|
1834
1946
|
}
|
|
1835
1947
|
async destroy() {
|
|
1836
|
-
(0,
|
|
1837
|
-
F:
|
|
1948
|
+
(0, import_log5.log)("destroying...", void 0, {
|
|
1949
|
+
F: __dxlog_file5,
|
|
1838
1950
|
L: 141,
|
|
1839
1951
|
S: this,
|
|
1840
1952
|
C: (f, a) => f(...a)
|
|
@@ -1844,8 +1956,8 @@ var Swarm = class {
|
|
|
1844
1956
|
await this._ctx.dispose();
|
|
1845
1957
|
await this._topology.destroy();
|
|
1846
1958
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
1847
|
-
(0,
|
|
1848
|
-
F:
|
|
1959
|
+
(0, import_log5.log)("destroyed", void 0, {
|
|
1960
|
+
F: __dxlog_file5,
|
|
1849
1961
|
L: 148,
|
|
1850
1962
|
S: this,
|
|
1851
1963
|
C: (f, a) => f(...a)
|
|
@@ -1853,7 +1965,7 @@ var Swarm = class {
|
|
|
1853
1965
|
}
|
|
1854
1966
|
async setTopology(topology) {
|
|
1855
1967
|
(0, import_invariant4.invariant)(!this._ctx.disposed, "Swarm is offline", {
|
|
1856
|
-
F:
|
|
1968
|
+
F: __dxlog_file5,
|
|
1857
1969
|
L: 152,
|
|
1858
1970
|
S: this,
|
|
1859
1971
|
A: [
|
|
@@ -1864,11 +1976,11 @@ var Swarm = class {
|
|
|
1864
1976
|
if (topology === this._topology) {
|
|
1865
1977
|
return;
|
|
1866
1978
|
}
|
|
1867
|
-
(0,
|
|
1979
|
+
(0, import_log5.log)("setting topology", {
|
|
1868
1980
|
previous: getClassName(this._topology),
|
|
1869
1981
|
topology: getClassName(topology)
|
|
1870
1982
|
}, {
|
|
1871
|
-
F:
|
|
1983
|
+
F: __dxlog_file5,
|
|
1872
1984
|
L: 156,
|
|
1873
1985
|
S: this,
|
|
1874
1986
|
C: (f, a) => f(...a)
|
|
@@ -1879,17 +1991,17 @@ var Swarm = class {
|
|
|
1879
1991
|
this._topology.update();
|
|
1880
1992
|
}
|
|
1881
1993
|
onSwarmEvent(swarmEvent) {
|
|
1882
|
-
(0,
|
|
1994
|
+
(0, import_log5.log)("swarm event", {
|
|
1883
1995
|
swarmEvent
|
|
1884
1996
|
}, {
|
|
1885
|
-
F:
|
|
1997
|
+
F: __dxlog_file5,
|
|
1886
1998
|
L: 169,
|
|
1887
1999
|
S: this,
|
|
1888
2000
|
C: (f, a) => f(...a)
|
|
1889
2001
|
});
|
|
1890
2002
|
if (this._ctx.disposed) {
|
|
1891
|
-
(0,
|
|
1892
|
-
F:
|
|
2003
|
+
(0, import_log5.log)("swarm event ignored for disposed swarm", void 0, {
|
|
2004
|
+
F: __dxlog_file5,
|
|
1893
2005
|
L: 172,
|
|
1894
2006
|
S: this,
|
|
1895
2007
|
C: (f, a) => f(...a)
|
|
@@ -1897,11 +2009,11 @@ var Swarm = class {
|
|
|
1897
2009
|
return;
|
|
1898
2010
|
}
|
|
1899
2011
|
if (swarmEvent.peerAvailable) {
|
|
1900
|
-
const peerId =
|
|
1901
|
-
(0,
|
|
2012
|
+
const peerId = import_keys5.PublicKey.from(swarmEvent.peerAvailable.peer);
|
|
2013
|
+
(0, import_log5.log)("new peer", {
|
|
1902
2014
|
peerId
|
|
1903
2015
|
}, {
|
|
1904
|
-
F:
|
|
2016
|
+
F: __dxlog_file5,
|
|
1905
2017
|
L: 178,
|
|
1906
2018
|
S: this,
|
|
1907
2019
|
C: (f, a) => f(...a)
|
|
@@ -1911,12 +2023,12 @@ var Swarm = class {
|
|
|
1911
2023
|
peer.advertizing = true;
|
|
1912
2024
|
}
|
|
1913
2025
|
} else if (swarmEvent.peerLeft) {
|
|
1914
|
-
const peer = this._peers.get(
|
|
2026
|
+
const peer = this._peers.get(import_keys5.PublicKey.from(swarmEvent.peerLeft.peer));
|
|
1915
2027
|
if (peer) {
|
|
1916
2028
|
peer.advertizing = false;
|
|
1917
2029
|
if (peer.connection?.state !== ConnectionState.CONNECTED) {
|
|
1918
|
-
void this._destroyPeer(peer.id).catch((err) =>
|
|
1919
|
-
F:
|
|
2030
|
+
void this._destroyPeer(peer.id).catch((err) => import_log5.log.catch(err, void 0, {
|
|
2031
|
+
F: __dxlog_file5,
|
|
1920
2032
|
L: 189,
|
|
1921
2033
|
S: this,
|
|
1922
2034
|
C: (f, a) => f(...a)
|
|
@@ -1927,17 +2039,17 @@ var Swarm = class {
|
|
|
1927
2039
|
this._topology.update();
|
|
1928
2040
|
}
|
|
1929
2041
|
async onOffer(message) {
|
|
1930
|
-
(0,
|
|
2042
|
+
(0, import_log5.log)("offer", {
|
|
1931
2043
|
message
|
|
1932
2044
|
}, {
|
|
1933
|
-
F:
|
|
2045
|
+
F: __dxlog_file5,
|
|
1934
2046
|
L: 199,
|
|
1935
2047
|
S: this,
|
|
1936
2048
|
C: (f, a) => f(...a)
|
|
1937
2049
|
});
|
|
1938
2050
|
if (this._ctx.disposed) {
|
|
1939
|
-
(0,
|
|
1940
|
-
F:
|
|
2051
|
+
(0, import_log5.log)("ignored for disposed swarm", void 0, {
|
|
2052
|
+
F: __dxlog_file5,
|
|
1941
2053
|
L: 201,
|
|
1942
2054
|
S: this,
|
|
1943
2055
|
C: (f, a) => f(...a)
|
|
@@ -1947,7 +2059,7 @@ var Swarm = class {
|
|
|
1947
2059
|
};
|
|
1948
2060
|
}
|
|
1949
2061
|
(0, import_invariant4.invariant)(message.author, void 0, {
|
|
1950
|
-
F:
|
|
2062
|
+
F: __dxlog_file5,
|
|
1951
2063
|
L: 206,
|
|
1952
2064
|
S: this,
|
|
1953
2065
|
A: [
|
|
@@ -1956,10 +2068,10 @@ var Swarm = class {
|
|
|
1956
2068
|
]
|
|
1957
2069
|
});
|
|
1958
2070
|
if (!message.recipient?.equals(this._ownPeerId)) {
|
|
1959
|
-
(0,
|
|
2071
|
+
(0, import_log5.log)("rejecting offer with incorrect peerId", {
|
|
1960
2072
|
message
|
|
1961
2073
|
}, {
|
|
1962
|
-
F:
|
|
2074
|
+
F: __dxlog_file5,
|
|
1963
2075
|
L: 208,
|
|
1964
2076
|
S: this,
|
|
1965
2077
|
C: (f, a) => f(...a)
|
|
@@ -1969,10 +2081,10 @@ var Swarm = class {
|
|
|
1969
2081
|
};
|
|
1970
2082
|
}
|
|
1971
2083
|
if (!message.topic?.equals(this._topic)) {
|
|
1972
|
-
(0,
|
|
2084
|
+
(0, import_log5.log)("rejecting offer with incorrect topic", {
|
|
1973
2085
|
message
|
|
1974
2086
|
}, {
|
|
1975
|
-
F:
|
|
2087
|
+
F: __dxlog_file5,
|
|
1976
2088
|
L: 212,
|
|
1977
2089
|
S: this,
|
|
1978
2090
|
C: (f, a) => f(...a)
|
|
@@ -1987,17 +2099,17 @@ var Swarm = class {
|
|
|
1987
2099
|
return answer;
|
|
1988
2100
|
}
|
|
1989
2101
|
async onSignal(message) {
|
|
1990
|
-
(0,
|
|
2102
|
+
(0, import_log5.log)("signal", {
|
|
1991
2103
|
message
|
|
1992
2104
|
}, {
|
|
1993
|
-
F:
|
|
2105
|
+
F: __dxlog_file5,
|
|
1994
2106
|
L: 223,
|
|
1995
2107
|
S: this,
|
|
1996
2108
|
C: (f, a) => f(...a)
|
|
1997
2109
|
});
|
|
1998
2110
|
if (this._ctx.disposed) {
|
|
1999
|
-
|
|
2000
|
-
F:
|
|
2111
|
+
import_log5.log.info("ignored for offline swarm", void 0, {
|
|
2112
|
+
F: __dxlog_file5,
|
|
2001
2113
|
L: 225,
|
|
2002
2114
|
S: this,
|
|
2003
2115
|
C: (f, a) => f(...a)
|
|
@@ -2005,7 +2117,7 @@ var Swarm = class {
|
|
|
2005
2117
|
return;
|
|
2006
2118
|
}
|
|
2007
2119
|
(0, import_invariant4.invariant)(message.recipient?.equals(this._ownPeerId), `Invalid signal peer id expected=${this.ownPeerId}, actual=${message.recipient}`, {
|
|
2008
|
-
F:
|
|
2120
|
+
F: __dxlog_file5,
|
|
2009
2121
|
L: 228,
|
|
2010
2122
|
S: this,
|
|
2011
2123
|
A: [
|
|
@@ -2014,7 +2126,7 @@ var Swarm = class {
|
|
|
2014
2126
|
]
|
|
2015
2127
|
});
|
|
2016
2128
|
(0, import_invariant4.invariant)(message.topic?.equals(this._topic), void 0, {
|
|
2017
|
-
F:
|
|
2129
|
+
F: __dxlog_file5,
|
|
2018
2130
|
L: 232,
|
|
2019
2131
|
S: this,
|
|
2020
2132
|
A: [
|
|
@@ -2023,7 +2135,7 @@ var Swarm = class {
|
|
|
2023
2135
|
]
|
|
2024
2136
|
});
|
|
2025
2137
|
(0, import_invariant4.invariant)(message.author, void 0, {
|
|
2026
|
-
F:
|
|
2138
|
+
F: __dxlog_file5,
|
|
2027
2139
|
L: 233,
|
|
2028
2140
|
S: this,
|
|
2029
2141
|
A: [
|
|
@@ -2083,7 +2195,7 @@ var Swarm = class {
|
|
|
2083
2195
|
}
|
|
2084
2196
|
async _destroyPeer(peerId) {
|
|
2085
2197
|
(0, import_invariant4.invariant)(this._peers.has(peerId), void 0, {
|
|
2086
|
-
F:
|
|
2198
|
+
F: __dxlog_file5,
|
|
2087
2199
|
L: 303,
|
|
2088
2200
|
S: this,
|
|
2089
2201
|
A: [
|
|
@@ -2105,12 +2217,12 @@ var Swarm = class {
|
|
|
2105
2217
|
if (this._ctx.disposed) {
|
|
2106
2218
|
return;
|
|
2107
2219
|
}
|
|
2108
|
-
(0,
|
|
2220
|
+
(0, import_async4.scheduleTask)(this._ctx, async () => {
|
|
2109
2221
|
try {
|
|
2110
2222
|
await this._initiateConnection(peer);
|
|
2111
2223
|
} catch (err) {
|
|
2112
|
-
(0,
|
|
2113
|
-
F:
|
|
2224
|
+
(0, import_log5.log)("initiation error", err, {
|
|
2225
|
+
F: __dxlog_file5,
|
|
2114
2226
|
L: 329,
|
|
2115
2227
|
S: this,
|
|
2116
2228
|
C: (f, a) => f(...a)
|
|
@@ -2122,7 +2234,7 @@ var Swarm = class {
|
|
|
2122
2234
|
if (this._ctx.disposed) {
|
|
2123
2235
|
return;
|
|
2124
2236
|
}
|
|
2125
|
-
(0,
|
|
2237
|
+
(0, import_async4.scheduleTask)(this._ctx, async () => {
|
|
2126
2238
|
await this._closeConnection(peer);
|
|
2127
2239
|
this._topology.update();
|
|
2128
2240
|
});
|
|
@@ -2135,15 +2247,15 @@ var Swarm = class {
|
|
|
2135
2247
|
async _initiateConnection(remoteId) {
|
|
2136
2248
|
const ctx = this._ctx;
|
|
2137
2249
|
if (remoteId.toHex() < this._ownPeerId.toHex()) {
|
|
2138
|
-
(0,
|
|
2250
|
+
(0, import_log5.log)("initiation delay", {
|
|
2139
2251
|
remoteId
|
|
2140
2252
|
}, {
|
|
2141
|
-
F:
|
|
2253
|
+
F: __dxlog_file5,
|
|
2142
2254
|
L: 356,
|
|
2143
2255
|
S: this,
|
|
2144
2256
|
C: (f, a) => f(...a)
|
|
2145
2257
|
});
|
|
2146
|
-
await (0,
|
|
2258
|
+
await (0, import_async4.sleep)(this._initiationDelay);
|
|
2147
2259
|
}
|
|
2148
2260
|
if (ctx.disposed) {
|
|
2149
2261
|
return;
|
|
@@ -2152,20 +2264,20 @@ var Swarm = class {
|
|
|
2152
2264
|
if (peer.connection) {
|
|
2153
2265
|
return;
|
|
2154
2266
|
}
|
|
2155
|
-
(0,
|
|
2267
|
+
(0, import_log5.log)("initiating connection...", {
|
|
2156
2268
|
remoteId
|
|
2157
2269
|
}, {
|
|
2158
|
-
F:
|
|
2270
|
+
F: __dxlog_file5,
|
|
2159
2271
|
L: 370,
|
|
2160
2272
|
S: this,
|
|
2161
2273
|
C: (f, a) => f(...a)
|
|
2162
2274
|
});
|
|
2163
2275
|
await peer.initiateConnection();
|
|
2164
2276
|
this._topology.update();
|
|
2165
|
-
(0,
|
|
2277
|
+
(0, import_log5.log)("initiated", {
|
|
2166
2278
|
remoteId
|
|
2167
2279
|
}, {
|
|
2168
|
-
F:
|
|
2280
|
+
F: __dxlog_file5,
|
|
2169
2281
|
L: 373,
|
|
2170
2282
|
S: this,
|
|
2171
2283
|
C: (f, a) => f(...a)
|
|
@@ -2180,44 +2292,43 @@ var Swarm = class {
|
|
|
2180
2292
|
}
|
|
2181
2293
|
};
|
|
2182
2294
|
_ts_decorate3([
|
|
2183
|
-
|
|
2295
|
+
import_log5.logInfo
|
|
2184
2296
|
], Swarm.prototype, "_instanceId", void 0);
|
|
2185
2297
|
_ts_decorate3([
|
|
2186
|
-
|
|
2298
|
+
import_log5.logInfo
|
|
2187
2299
|
], Swarm.prototype, "ownPeerId", null);
|
|
2188
2300
|
_ts_decorate3([
|
|
2189
|
-
|
|
2301
|
+
import_log5.logInfo
|
|
2190
2302
|
], Swarm.prototype, "topic", null);
|
|
2191
2303
|
_ts_decorate3([
|
|
2192
|
-
|
|
2304
|
+
import_async4.synchronized
|
|
2193
2305
|
], Swarm.prototype, "onSwarmEvent", null);
|
|
2194
2306
|
_ts_decorate3([
|
|
2195
|
-
|
|
2307
|
+
import_async4.synchronized
|
|
2196
2308
|
], Swarm.prototype, "onOffer", null);
|
|
2197
2309
|
_ts_decorate3([
|
|
2198
|
-
|
|
2310
|
+
import_async4.synchronized
|
|
2199
2311
|
], Swarm.prototype, "goOffline", null);
|
|
2200
2312
|
_ts_decorate3([
|
|
2201
|
-
|
|
2313
|
+
import_async4.synchronized
|
|
2202
2314
|
], Swarm.prototype, "goOnline", null);
|
|
2203
2315
|
|
|
2204
2316
|
// packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts
|
|
2205
|
-
var
|
|
2206
|
-
var
|
|
2207
|
-
var
|
|
2208
|
-
var
|
|
2209
|
-
var
|
|
2317
|
+
var import_async5 = require("@dxos/async");
|
|
2318
|
+
var import_keys6 = require("@dxos/keys");
|
|
2319
|
+
var import_log6 = require("@dxos/log");
|
|
2320
|
+
var import_util4 = require("@dxos/util");
|
|
2321
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
2210
2322
|
var SwarmMapper = class {
|
|
2211
2323
|
get peers() {
|
|
2212
2324
|
return Array.from(this._peers.values());
|
|
2213
2325
|
}
|
|
2214
|
-
// prettier-ignore
|
|
2215
2326
|
constructor(_swarm) {
|
|
2216
2327
|
this._swarm = _swarm;
|
|
2217
|
-
this._subscriptions = new
|
|
2218
|
-
this._connectionSubscriptions = new
|
|
2219
|
-
this._peers = new
|
|
2220
|
-
this.mapUpdated = new
|
|
2328
|
+
this._subscriptions = new import_async5.EventSubscriptions();
|
|
2329
|
+
this._connectionSubscriptions = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
2330
|
+
this._peers = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
2331
|
+
this.mapUpdated = new import_async5.Event();
|
|
2221
2332
|
this._subscriptions.add(_swarm.connectionAdded.on((connection) => {
|
|
2222
2333
|
this._update();
|
|
2223
2334
|
this._connectionSubscriptions.set(connection.remoteId, connection.stateChanged.on(() => {
|
|
@@ -2232,9 +2343,9 @@ var SwarmMapper = class {
|
|
|
2232
2343
|
this._update();
|
|
2233
2344
|
}
|
|
2234
2345
|
_update() {
|
|
2235
|
-
(0,
|
|
2236
|
-
F:
|
|
2237
|
-
L:
|
|
2346
|
+
(0, import_log6.log)("updating swarm", void 0, {
|
|
2347
|
+
F: __dxlog_file6,
|
|
2348
|
+
L: 72,
|
|
2238
2349
|
S: this,
|
|
2239
2350
|
C: (f, a) => f(...a)
|
|
2240
2351
|
});
|
|
@@ -2253,12 +2364,12 @@ var SwarmMapper = class {
|
|
|
2253
2364
|
]
|
|
2254
2365
|
});
|
|
2255
2366
|
}
|
|
2256
|
-
(0,
|
|
2367
|
+
(0, import_log6.log)("graph changed", {
|
|
2257
2368
|
directConnections: this._swarm.connections.length,
|
|
2258
2369
|
totalPeersInSwarm: this._peers.size
|
|
2259
2370
|
}, {
|
|
2260
|
-
F:
|
|
2261
|
-
L:
|
|
2371
|
+
F: __dxlog_file6,
|
|
2372
|
+
L: 113,
|
|
2262
2373
|
S: this,
|
|
2263
2374
|
C: (f, a) => f(...a)
|
|
2264
2375
|
});
|
|
@@ -2272,14 +2383,14 @@ var SwarmMapper = class {
|
|
|
2272
2383
|
};
|
|
2273
2384
|
|
|
2274
2385
|
// packages/core/mesh/network-manager/src/swarm/connection-limiter.ts
|
|
2275
|
-
var
|
|
2386
|
+
var import_async6 = require("@dxos/async");
|
|
2276
2387
|
var import_context5 = require("@dxos/context");
|
|
2277
2388
|
var import_invariant5 = require("@dxos/invariant");
|
|
2278
|
-
var
|
|
2279
|
-
var
|
|
2389
|
+
var import_keys7 = require("@dxos/keys");
|
|
2390
|
+
var import_log7 = require("@dxos/log");
|
|
2280
2391
|
var import_protocols5 = require("@dxos/protocols");
|
|
2281
|
-
var
|
|
2282
|
-
var
|
|
2392
|
+
var import_util5 = require("@dxos/util");
|
|
2393
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
2283
2394
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
2284
2395
|
var ConnectionLimiter = class {
|
|
2285
2396
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -2287,8 +2398,8 @@ var ConnectionLimiter = class {
|
|
|
2287
2398
|
/**
|
|
2288
2399
|
* Queue of promises to resolve when initiating connections amount is below the limit.
|
|
2289
2400
|
*/
|
|
2290
|
-
this._waitingPromises = new
|
|
2291
|
-
this.resolveWaitingPromises = new
|
|
2401
|
+
this._waitingPromises = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
|
|
2402
|
+
this.resolveWaitingPromises = new import_async6.DeferredTask(this._ctx, async () => {
|
|
2292
2403
|
Array.from(this._waitingPromises.values()).slice(0, this._maxConcurrentInitConnections).forEach(({ resolve }) => {
|
|
2293
2404
|
resolve();
|
|
2294
2405
|
});
|
|
@@ -2300,7 +2411,7 @@ var ConnectionLimiter = class {
|
|
|
2300
2411
|
*/
|
|
2301
2412
|
async connecting(sessionId) {
|
|
2302
2413
|
(0, import_invariant5.invariant)(!this._waitingPromises.has(sessionId), "Peer is already waiting for connection", {
|
|
2303
|
-
F:
|
|
2414
|
+
F: __dxlog_file7,
|
|
2304
2415
|
L: 48,
|
|
2305
2416
|
S: this,
|
|
2306
2417
|
A: [
|
|
@@ -2308,10 +2419,10 @@ var ConnectionLimiter = class {
|
|
|
2308
2419
|
"'Peer is already waiting for connection'"
|
|
2309
2420
|
]
|
|
2310
2421
|
});
|
|
2311
|
-
(0,
|
|
2422
|
+
(0, import_log7.log)("waiting", {
|
|
2312
2423
|
sessionId
|
|
2313
2424
|
}, {
|
|
2314
|
-
F:
|
|
2425
|
+
F: __dxlog_file7,
|
|
2315
2426
|
L: 49,
|
|
2316
2427
|
S: this,
|
|
2317
2428
|
C: (f, a) => f(...a)
|
|
@@ -2323,10 +2434,10 @@ var ConnectionLimiter = class {
|
|
|
2323
2434
|
});
|
|
2324
2435
|
this.resolveWaitingPromises.schedule();
|
|
2325
2436
|
});
|
|
2326
|
-
(0,
|
|
2437
|
+
(0, import_log7.log)("allow", {
|
|
2327
2438
|
sessionId
|
|
2328
2439
|
}, {
|
|
2329
|
-
F:
|
|
2440
|
+
F: __dxlog_file7,
|
|
2330
2441
|
L: 57,
|
|
2331
2442
|
S: this,
|
|
2332
2443
|
C: (f, a) => f(...a)
|
|
@@ -2336,10 +2447,10 @@ var ConnectionLimiter = class {
|
|
|
2336
2447
|
* Rejects promise returned by `connecting` method.
|
|
2337
2448
|
*/
|
|
2338
2449
|
doneConnecting(sessionId) {
|
|
2339
|
-
(0,
|
|
2450
|
+
(0, import_log7.log)("done", {
|
|
2340
2451
|
sessionId
|
|
2341
2452
|
}, {
|
|
2342
|
-
F:
|
|
2453
|
+
F: __dxlog_file7,
|
|
2343
2454
|
L: 64,
|
|
2344
2455
|
S: this,
|
|
2345
2456
|
C: (f, a) => f(...a)
|
|
@@ -2367,8 +2478,8 @@ var ConnectionLog = class {
|
|
|
2367
2478
|
/**
|
|
2368
2479
|
* SwarmId => info
|
|
2369
2480
|
*/
|
|
2370
|
-
this._swarms = new
|
|
2371
|
-
this.update = new
|
|
2481
|
+
this._swarms = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
2482
|
+
this.update = new import_async7.Event();
|
|
2372
2483
|
}
|
|
2373
2484
|
getSwarmInfo(swarmId) {
|
|
2374
2485
|
return this._swarms.get(swarmId) ?? (0, import_debug3.raise)(new Error(`Swarm not found: ${swarmId}`));
|
|
@@ -2378,13 +2489,13 @@ var ConnectionLog = class {
|
|
|
2378
2489
|
}
|
|
2379
2490
|
joinedSwarm(swarm) {
|
|
2380
2491
|
const info = {
|
|
2381
|
-
id:
|
|
2492
|
+
id: import_keys8.PublicKey.from(swarm._instanceId),
|
|
2382
2493
|
topic: swarm.topic,
|
|
2383
2494
|
isActive: true,
|
|
2384
2495
|
label: swarm.label,
|
|
2385
2496
|
connections: []
|
|
2386
2497
|
};
|
|
2387
|
-
this._swarms.set(
|
|
2498
|
+
this._swarms.set(import_keys8.PublicKey.from(swarm._instanceId), info);
|
|
2388
2499
|
this.update.emit();
|
|
2389
2500
|
swarm.connectionAdded.on((connection) => {
|
|
2390
2501
|
const connectionInfo = {
|
|
@@ -2414,24 +2525,24 @@ var ConnectionLog = class {
|
|
|
2414
2525
|
});
|
|
2415
2526
|
}
|
|
2416
2527
|
leftSwarm(swarm) {
|
|
2417
|
-
this.getSwarmInfo(
|
|
2528
|
+
this.getSwarmInfo(import_keys8.PublicKey.from(swarm._instanceId)).isActive = false;
|
|
2418
2529
|
this.update.emit();
|
|
2419
2530
|
}
|
|
2420
2531
|
};
|
|
2421
2532
|
|
|
2422
2533
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
2423
|
-
var
|
|
2534
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2424
2535
|
var NetworkManager = class {
|
|
2425
2536
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
2426
2537
|
/**
|
|
2427
2538
|
* @internal
|
|
2428
2539
|
*/
|
|
2429
|
-
this._swarms = new
|
|
2430
|
-
this._mappers = new
|
|
2540
|
+
this._swarms = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
|
|
2541
|
+
this._mappers = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
|
|
2431
2542
|
this._connectionState = import_services.ConnectionState.ONLINE;
|
|
2432
|
-
this.connectionStateChanged = new
|
|
2433
|
-
this.topicsUpdated = new
|
|
2434
|
-
this._instanceId =
|
|
2543
|
+
this.connectionStateChanged = new import_async8.Event();
|
|
2544
|
+
this.topicsUpdated = new import_async8.Event();
|
|
2545
|
+
this._instanceId = import_keys9.PublicKey.random().toHex();
|
|
2435
2546
|
this._transportFactory = transportFactory;
|
|
2436
2547
|
this._signalManager = signalManager;
|
|
2437
2548
|
this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => this._swarms.get(topic)?.onSwarmEvent(event));
|
|
@@ -2465,20 +2576,20 @@ var NetworkManager = class {
|
|
|
2465
2576
|
return this._swarms.get(topic);
|
|
2466
2577
|
}
|
|
2467
2578
|
async open() {
|
|
2468
|
-
|
|
2579
|
+
import_log8.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.begin({
|
|
2469
2580
|
id: this._instanceId
|
|
2470
2581
|
}), {
|
|
2471
|
-
F:
|
|
2582
|
+
F: __dxlog_file8,
|
|
2472
2583
|
L: 130,
|
|
2473
2584
|
S: this,
|
|
2474
2585
|
C: (f, a) => f(...a)
|
|
2475
2586
|
});
|
|
2476
2587
|
await this._messenger.open();
|
|
2477
2588
|
await this._signalManager.open();
|
|
2478
|
-
|
|
2589
|
+
import_log8.log.trace("dxos.mesh.network-manager.open", import_protocols6.trace.end({
|
|
2479
2590
|
id: this._instanceId
|
|
2480
2591
|
}), {
|
|
2481
|
-
F:
|
|
2592
|
+
F: __dxlog_file8,
|
|
2482
2593
|
L: 133,
|
|
2483
2594
|
S: this,
|
|
2484
2595
|
C: (f, a) => f(...a)
|
|
@@ -2487,8 +2598,8 @@ var NetworkManager = class {
|
|
|
2487
2598
|
async close() {
|
|
2488
2599
|
for (const topic of this._swarms.keys()) {
|
|
2489
2600
|
await this.leaveSwarm(topic).catch((err) => {
|
|
2490
|
-
(0,
|
|
2491
|
-
F:
|
|
2601
|
+
(0, import_log8.log)(err, void 0, {
|
|
2602
|
+
F: __dxlog_file8,
|
|
2492
2603
|
L: 139,
|
|
2493
2604
|
S: this,
|
|
2494
2605
|
C: (f, a) => f(...a)
|
|
@@ -2502,8 +2613,8 @@ var NetworkManager = class {
|
|
|
2502
2613
|
* Join the swarm.
|
|
2503
2614
|
*/
|
|
2504
2615
|
async joinSwarm({ topic, peerId, topology, protocolProvider: protocol, label }) {
|
|
2505
|
-
(0, import_invariant6.invariant)(
|
|
2506
|
-
F:
|
|
2616
|
+
(0, import_invariant6.invariant)(import_keys9.PublicKey.isPublicKey(topic), void 0, {
|
|
2617
|
+
F: __dxlog_file8,
|
|
2507
2618
|
L: 157,
|
|
2508
2619
|
S: this,
|
|
2509
2620
|
A: [
|
|
@@ -2511,8 +2622,8 @@ var NetworkManager = class {
|
|
|
2511
2622
|
""
|
|
2512
2623
|
]
|
|
2513
2624
|
});
|
|
2514
|
-
(0, import_invariant6.invariant)(
|
|
2515
|
-
F:
|
|
2625
|
+
(0, import_invariant6.invariant)(import_keys9.PublicKey.isPublicKey(peerId), void 0, {
|
|
2626
|
+
F: __dxlog_file8,
|
|
2516
2627
|
L: 158,
|
|
2517
2628
|
S: this,
|
|
2518
2629
|
A: [
|
|
@@ -2521,7 +2632,7 @@ var NetworkManager = class {
|
|
|
2521
2632
|
]
|
|
2522
2633
|
});
|
|
2523
2634
|
(0, import_invariant6.invariant)(topology, void 0, {
|
|
2524
|
-
F:
|
|
2635
|
+
F: __dxlog_file8,
|
|
2525
2636
|
L: 159,
|
|
2526
2637
|
S: this,
|
|
2527
2638
|
A: [
|
|
@@ -2530,7 +2641,7 @@ var NetworkManager = class {
|
|
|
2530
2641
|
]
|
|
2531
2642
|
});
|
|
2532
2643
|
(0, import_invariant6.invariant)(typeof protocol === "function", void 0, {
|
|
2533
|
-
F:
|
|
2644
|
+
F: __dxlog_file8,
|
|
2534
2645
|
L: 160,
|
|
2535
2646
|
S: this,
|
|
2536
2647
|
A: [
|
|
@@ -2539,24 +2650,24 @@ var NetworkManager = class {
|
|
|
2539
2650
|
]
|
|
2540
2651
|
});
|
|
2541
2652
|
if (this._swarms.has(topic)) {
|
|
2542
|
-
throw new Error(`Already connected to swarm: ${
|
|
2653
|
+
throw new Error(`Already connected to swarm: ${import_keys9.PublicKey.from(topic)}`);
|
|
2543
2654
|
}
|
|
2544
|
-
(0,
|
|
2545
|
-
topic:
|
|
2655
|
+
(0, import_log8.log)("joining", {
|
|
2656
|
+
topic: import_keys9.PublicKey.from(topic),
|
|
2546
2657
|
peerId,
|
|
2547
2658
|
topology: topology.toString()
|
|
2548
2659
|
}, {
|
|
2549
|
-
F:
|
|
2660
|
+
F: __dxlog_file8,
|
|
2550
2661
|
L: 165,
|
|
2551
2662
|
S: this,
|
|
2552
2663
|
C: (f, a) => f(...a)
|
|
2553
2664
|
});
|
|
2554
2665
|
const swarm = new Swarm(topic, peerId, topology, protocol, this._messenger, this._transportFactory, label, this._connectionLimiter);
|
|
2555
2666
|
swarm.errors.handle((error) => {
|
|
2556
|
-
(0,
|
|
2667
|
+
(0, import_log8.log)("swarm error", {
|
|
2557
2668
|
error
|
|
2558
2669
|
}, {
|
|
2559
|
-
F:
|
|
2670
|
+
F: __dxlog_file8,
|
|
2560
2671
|
L: 178,
|
|
2561
2672
|
S: this,
|
|
2562
2673
|
C: (f, a) => f(...a)
|
|
@@ -2568,19 +2679,19 @@ var NetworkManager = class {
|
|
|
2568
2679
|
this._signalConnection.join({
|
|
2569
2680
|
topic,
|
|
2570
2681
|
peerId
|
|
2571
|
-
}).catch((error) =>
|
|
2572
|
-
F:
|
|
2682
|
+
}).catch((error) => import_log8.log.catch(error, void 0, {
|
|
2683
|
+
F: __dxlog_file8,
|
|
2573
2684
|
L: 187,
|
|
2574
2685
|
S: this,
|
|
2575
2686
|
C: (f, a) => f(...a)
|
|
2576
2687
|
}));
|
|
2577
2688
|
this.topicsUpdated.emit();
|
|
2578
2689
|
this._connectionLog?.joinedSwarm(swarm);
|
|
2579
|
-
(0,
|
|
2580
|
-
topic:
|
|
2690
|
+
(0, import_log8.log)("joined", {
|
|
2691
|
+
topic: import_keys9.PublicKey.from(topic),
|
|
2581
2692
|
count: this._swarms.size
|
|
2582
2693
|
}, {
|
|
2583
|
-
F:
|
|
2694
|
+
F: __dxlog_file8,
|
|
2584
2695
|
L: 191,
|
|
2585
2696
|
S: this,
|
|
2586
2697
|
C: (f, a) => f(...a)
|
|
@@ -2596,10 +2707,10 @@ var NetworkManager = class {
|
|
|
2596
2707
|
if (!this._swarms.has(topic)) {
|
|
2597
2708
|
return;
|
|
2598
2709
|
}
|
|
2599
|
-
(0,
|
|
2600
|
-
topic:
|
|
2710
|
+
(0, import_log8.log)("leaving", {
|
|
2711
|
+
topic: import_keys9.PublicKey.from(topic)
|
|
2601
2712
|
}, {
|
|
2602
|
-
F:
|
|
2713
|
+
F: __dxlog_file8,
|
|
2603
2714
|
L: 207,
|
|
2604
2715
|
S: this,
|
|
2605
2716
|
C: (f, a) => f(...a)
|
|
@@ -2616,11 +2727,11 @@ var NetworkManager = class {
|
|
|
2616
2727
|
await swarm.destroy();
|
|
2617
2728
|
this._swarms.delete(topic);
|
|
2618
2729
|
await this.topicsUpdated.emit();
|
|
2619
|
-
(0,
|
|
2620
|
-
topic:
|
|
2730
|
+
(0, import_log8.log)("left", {
|
|
2731
|
+
topic: import_keys9.PublicKey.from(topic),
|
|
2621
2732
|
count: this._swarms.size
|
|
2622
2733
|
}, {
|
|
2623
|
-
F:
|
|
2734
|
+
F: __dxlog_file8,
|
|
2624
2735
|
L: 221,
|
|
2625
2736
|
S: this,
|
|
2626
2737
|
C: (f, a) => f(...a)
|
|
@@ -2656,14 +2767,14 @@ var NetworkManager = class {
|
|
|
2656
2767
|
|
|
2657
2768
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2658
2769
|
var import_invariant7 = require("@dxos/invariant");
|
|
2659
|
-
var
|
|
2770
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2660
2771
|
var FullyConnectedTopology = class {
|
|
2661
2772
|
toString() {
|
|
2662
2773
|
return "FullyConnectedTopology";
|
|
2663
2774
|
}
|
|
2664
2775
|
init(controller) {
|
|
2665
2776
|
(0, import_invariant7.invariant)(!this._controller, "Already initialized", {
|
|
2666
|
-
F:
|
|
2777
|
+
F: __dxlog_file9,
|
|
2667
2778
|
L: 18,
|
|
2668
2779
|
S: this,
|
|
2669
2780
|
A: [
|
|
@@ -2675,7 +2786,7 @@ var FullyConnectedTopology = class {
|
|
|
2675
2786
|
}
|
|
2676
2787
|
update() {
|
|
2677
2788
|
(0, import_invariant7.invariant)(this._controller, "Not initialized", {
|
|
2678
|
-
F:
|
|
2789
|
+
F: __dxlog_file9,
|
|
2679
2790
|
L: 23,
|
|
2680
2791
|
S: this,
|
|
2681
2792
|
A: [
|
|
@@ -2698,20 +2809,20 @@ var FullyConnectedTopology = class {
|
|
|
2698
2809
|
// packages/core/mesh/network-manager/src/topology/mmst-topology.ts
|
|
2699
2810
|
var import_xor_distance = __toESM(require("xor-distance"));
|
|
2700
2811
|
var import_invariant8 = require("@dxos/invariant");
|
|
2701
|
-
var
|
|
2812
|
+
var import_log9 = require("@dxos/log");
|
|
2702
2813
|
|
|
2703
2814
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2704
2815
|
var import_invariant9 = require("@dxos/invariant");
|
|
2705
|
-
var
|
|
2816
|
+
var import_log10 = require("@dxos/log");
|
|
2706
2817
|
|
|
2707
2818
|
// packages/core/mesh/network-manager/src/transport/memory-transport.ts
|
|
2708
2819
|
var import_node_stream = require("node:stream");
|
|
2709
|
-
var
|
|
2820
|
+
var import_async9 = require("@dxos/async");
|
|
2710
2821
|
var import_debug4 = require("@dxos/debug");
|
|
2711
2822
|
var import_invariant10 = require("@dxos/invariant");
|
|
2712
|
-
var
|
|
2713
|
-
var
|
|
2714
|
-
var
|
|
2823
|
+
var import_keys10 = require("@dxos/keys");
|
|
2824
|
+
var import_log11 = require("@dxos/log");
|
|
2825
|
+
var import_util8 = require("@dxos/util");
|
|
2715
2826
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2716
2827
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2717
2828
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2722,7 +2833,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2722
2833
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2723
2834
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2724
2835
|
}
|
|
2725
|
-
var
|
|
2836
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2726
2837
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2727
2838
|
var createStreamDelay = (delay) => {
|
|
2728
2839
|
return new import_node_stream.Transform({
|
|
@@ -2738,26 +2849,26 @@ var MemoryTransportFactory = {
|
|
|
2738
2849
|
var MemoryTransport = class _MemoryTransport {
|
|
2739
2850
|
static {
|
|
2740
2851
|
// TODO(burdon): Remove static properties (inject context into constructor).
|
|
2741
|
-
this._connections = new
|
|
2852
|
+
this._connections = new import_util8.ComplexMap(import_keys10.PublicKey.hash);
|
|
2742
2853
|
}
|
|
2743
2854
|
constructor(options) {
|
|
2744
2855
|
this.options = options;
|
|
2745
|
-
this.closed = new
|
|
2746
|
-
this.connected = new
|
|
2856
|
+
this.closed = new import_async9.Event();
|
|
2857
|
+
this.connected = new import_async9.Event();
|
|
2747
2858
|
this.errors = new import_debug4.ErrorStream();
|
|
2748
|
-
this._instanceId =
|
|
2749
|
-
this._remote = new
|
|
2859
|
+
this._instanceId = import_keys10.PublicKey.random();
|
|
2860
|
+
this._remote = new import_async9.Trigger();
|
|
2750
2861
|
this._outgoingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2751
2862
|
this._incomingDelay = createStreamDelay(MEMORY_TRANSPORT_DELAY);
|
|
2752
2863
|
this._destroyed = false;
|
|
2753
|
-
(0,
|
|
2754
|
-
F:
|
|
2864
|
+
(0, import_log11.log)("creating", void 0, {
|
|
2865
|
+
F: __dxlog_file10,
|
|
2755
2866
|
L: 64,
|
|
2756
2867
|
S: this,
|
|
2757
2868
|
C: (f, a) => f(...a)
|
|
2758
2869
|
});
|
|
2759
2870
|
(0, import_invariant10.invariant)(!_MemoryTransport._connections.has(this._instanceId), "Duplicate memory connection", {
|
|
2760
|
-
F:
|
|
2871
|
+
F: __dxlog_file10,
|
|
2761
2872
|
L: 66,
|
|
2762
2873
|
S: this,
|
|
2763
2874
|
A: [
|
|
@@ -2768,8 +2879,8 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2768
2879
|
_MemoryTransport._connections.set(this._instanceId, this);
|
|
2769
2880
|
if (this.options.initiator) {
|
|
2770
2881
|
setTimeout(async () => {
|
|
2771
|
-
(0,
|
|
2772
|
-
F:
|
|
2882
|
+
(0, import_log11.log)("sending signal", void 0, {
|
|
2883
|
+
F: __dxlog_file10,
|
|
2773
2884
|
L: 73,
|
|
2774
2885
|
S: this,
|
|
2775
2886
|
C: (f, a) => f(...a)
|
|
@@ -2799,7 +2910,7 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2799
2910
|
return;
|
|
2800
2911
|
}
|
|
2801
2912
|
(0, import_invariant10.invariant)(!this._remoteConnection._remoteConnection, `Remote already connected: ${this._remoteInstanceId}`, {
|
|
2802
|
-
F:
|
|
2913
|
+
F: __dxlog_file10,
|
|
2803
2914
|
L: 99,
|
|
2804
2915
|
S: this,
|
|
2805
2916
|
A: [
|
|
@@ -2809,8 +2920,8 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2809
2920
|
});
|
|
2810
2921
|
this._remoteConnection._remoteConnection = this;
|
|
2811
2922
|
this._remoteConnection._remoteInstanceId = this._instanceId;
|
|
2812
|
-
(0,
|
|
2813
|
-
F:
|
|
2923
|
+
(0, import_log11.log)("connected", void 0, {
|
|
2924
|
+
F: __dxlog_file10,
|
|
2814
2925
|
L: 103,
|
|
2815
2926
|
S: this,
|
|
2816
2927
|
C: (f, a) => f(...a)
|
|
@@ -2827,8 +2938,8 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2827
2938
|
}
|
|
2828
2939
|
}
|
|
2829
2940
|
async destroy() {
|
|
2830
|
-
(0,
|
|
2831
|
-
F:
|
|
2941
|
+
(0, import_log11.log)("closing", void 0, {
|
|
2942
|
+
F: __dxlog_file10,
|
|
2832
2943
|
L: 124,
|
|
2833
2944
|
S: this,
|
|
2834
2945
|
C: (f, a) => f(...a)
|
|
@@ -2836,8 +2947,8 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2836
2947
|
this._destroyed = true;
|
|
2837
2948
|
_MemoryTransport._connections.delete(this._instanceId);
|
|
2838
2949
|
if (this._remoteConnection) {
|
|
2839
|
-
(0,
|
|
2840
|
-
F:
|
|
2950
|
+
(0, import_log11.log)("closing", void 0, {
|
|
2951
|
+
F: __dxlog_file10,
|
|
2841
2952
|
L: 129,
|
|
2842
2953
|
S: this,
|
|
2843
2954
|
C: (f, a) => f(...a)
|
|
@@ -2849,26 +2960,26 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2849
2960
|
this._remoteConnection.closed.emit();
|
|
2850
2961
|
this._remoteConnection._remoteConnection = void 0;
|
|
2851
2962
|
this._remoteConnection = void 0;
|
|
2852
|
-
(0,
|
|
2853
|
-
F:
|
|
2963
|
+
(0, import_log11.log)("closed", void 0, {
|
|
2964
|
+
F: __dxlog_file10,
|
|
2854
2965
|
L: 147,
|
|
2855
2966
|
S: this,
|
|
2856
2967
|
C: (f, a) => f(...a)
|
|
2857
2968
|
});
|
|
2858
2969
|
}
|
|
2859
2970
|
this.closed.emit();
|
|
2860
|
-
(0,
|
|
2861
|
-
F:
|
|
2971
|
+
(0, import_log11.log)("closed", void 0, {
|
|
2972
|
+
F: __dxlog_file10,
|
|
2862
2973
|
L: 151,
|
|
2863
2974
|
S: this,
|
|
2864
2975
|
C: (f, a) => f(...a)
|
|
2865
2976
|
});
|
|
2866
2977
|
}
|
|
2867
2978
|
signal({ payload }) {
|
|
2868
|
-
(0,
|
|
2979
|
+
(0, import_log11.log)("received signal", {
|
|
2869
2980
|
payload
|
|
2870
2981
|
}, {
|
|
2871
|
-
F:
|
|
2982
|
+
F: __dxlog_file10,
|
|
2872
2983
|
L: 155,
|
|
2873
2984
|
S: this,
|
|
2874
2985
|
C: (f, a) => f(...a)
|
|
@@ -2878,16 +2989,16 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2878
2989
|
}
|
|
2879
2990
|
const transportId = payload.transportId;
|
|
2880
2991
|
if (transportId) {
|
|
2881
|
-
const remoteId =
|
|
2992
|
+
const remoteId = import_keys10.PublicKey.fromHex(transportId);
|
|
2882
2993
|
this._remote.wake(remoteId);
|
|
2883
2994
|
}
|
|
2884
2995
|
}
|
|
2885
2996
|
};
|
|
2886
2997
|
_ts_decorate4([
|
|
2887
|
-
|
|
2998
|
+
import_log11.logInfo
|
|
2888
2999
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
2889
3000
|
_ts_decorate4([
|
|
2890
|
-
|
|
3001
|
+
import_log11.logInfo
|
|
2891
3002
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2892
3003
|
|
|
2893
3004
|
// packages/core/mesh/network-manager/src/transport/transport.ts
|
|
@@ -2903,10 +3014,10 @@ var TransportKind;
|
|
|
2903
3014
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2904
3015
|
var import_simple_peer = __toESM(require("simple-peer"));
|
|
2905
3016
|
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
2906
|
-
var
|
|
3017
|
+
var import_async10 = require("@dxos/async");
|
|
2907
3018
|
var import_debug5 = require("@dxos/debug");
|
|
2908
|
-
var
|
|
2909
|
-
var
|
|
3019
|
+
var import_keys11 = require("@dxos/keys");
|
|
3020
|
+
var import_log12 = require("@dxos/log");
|
|
2910
3021
|
var import_protocols7 = require("@dxos/protocols");
|
|
2911
3022
|
|
|
2912
3023
|
// packages/core/mesh/network-manager/src/transport/webrtc.ts
|
|
@@ -2917,25 +3028,25 @@ try {
|
|
|
2917
3028
|
}
|
|
2918
3029
|
|
|
2919
3030
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2920
|
-
var
|
|
3031
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2921
3032
|
var SimplePeerTransport = class {
|
|
2922
3033
|
constructor(params) {
|
|
2923
3034
|
this.params = params;
|
|
2924
3035
|
this._closed = false;
|
|
2925
|
-
this.closed = new
|
|
2926
|
-
this.connected = new
|
|
3036
|
+
this.closed = new import_async10.Event();
|
|
3037
|
+
this.connected = new import_async10.Event();
|
|
2927
3038
|
this.errors = new import_debug5.ErrorStream();
|
|
2928
|
-
this._instanceId =
|
|
2929
|
-
|
|
3039
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
3040
|
+
import_log12.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.begin({
|
|
2930
3041
|
id: this._instanceId
|
|
2931
3042
|
}), {
|
|
2932
|
-
F:
|
|
3043
|
+
F: __dxlog_file11,
|
|
2933
3044
|
L: 40,
|
|
2934
3045
|
S: this,
|
|
2935
3046
|
C: (f, a) => f(...a)
|
|
2936
3047
|
});
|
|
2937
|
-
(0,
|
|
2938
|
-
F:
|
|
3048
|
+
(0, import_log12.log)("created connection", params, {
|
|
3049
|
+
F: __dxlog_file11,
|
|
2939
3050
|
L: 41,
|
|
2940
3051
|
S: this,
|
|
2941
3052
|
C: (f, a) => f(...a)
|
|
@@ -2947,8 +3058,8 @@ var SimplePeerTransport = class {
|
|
|
2947
3058
|
config: this.params.webrtcConfig
|
|
2948
3059
|
});
|
|
2949
3060
|
this._peer.on("signal", async (data) => {
|
|
2950
|
-
(0,
|
|
2951
|
-
F:
|
|
3061
|
+
(0, import_log12.log)("signal", data, {
|
|
3062
|
+
F: __dxlog_file11,
|
|
2952
3063
|
L: 50,
|
|
2953
3064
|
S: this,
|
|
2954
3065
|
C: (f, a) => f(...a)
|
|
@@ -2960,8 +3071,8 @@ var SimplePeerTransport = class {
|
|
|
2960
3071
|
});
|
|
2961
3072
|
});
|
|
2962
3073
|
this._peer.on("connect", () => {
|
|
2963
|
-
(0,
|
|
2964
|
-
F:
|
|
3074
|
+
(0, import_log12.log)("connected", void 0, {
|
|
3075
|
+
F: __dxlog_file11,
|
|
2965
3076
|
L: 55,
|
|
2966
3077
|
S: this,
|
|
2967
3078
|
C: (f, a) => f(...a)
|
|
@@ -2970,8 +3081,8 @@ var SimplePeerTransport = class {
|
|
|
2970
3081
|
this.connected.emit();
|
|
2971
3082
|
});
|
|
2972
3083
|
this._peer.on("close", async () => {
|
|
2973
|
-
(0,
|
|
2974
|
-
F:
|
|
3084
|
+
(0, import_log12.log)("closed", void 0, {
|
|
3085
|
+
F: __dxlog_file11,
|
|
2975
3086
|
L: 61,
|
|
2976
3087
|
S: this,
|
|
2977
3088
|
C: (f, a) => f(...a)
|
|
@@ -2986,9 +3097,13 @@ var SimplePeerTransport = class {
|
|
|
2986
3097
|
} else {
|
|
2987
3098
|
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown RTCError", err));
|
|
2988
3099
|
}
|
|
2989
|
-
} else if (err.name === "InvalidStateError") {
|
|
2990
|
-
this.errors.raise(new import_protocols7.ConnectionResetError("safari WebRTC error", err));
|
|
2991
3100
|
} else if ("code" in err) {
|
|
3101
|
+
import_log12.log.info("simple-peer error", err, {
|
|
3102
|
+
F: __dxlog_file11,
|
|
3103
|
+
L: 77,
|
|
3104
|
+
S: this,
|
|
3105
|
+
C: (f, a) => f(...a)
|
|
3106
|
+
});
|
|
2992
3107
|
switch (err.code) {
|
|
2993
3108
|
case "ERR_WEBRTC_SUPPORT":
|
|
2994
3109
|
this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
|
|
@@ -3007,45 +3122,51 @@ var SimplePeerTransport = class {
|
|
|
3007
3122
|
this.errors.raise(new Error("unknown simple-peer error"));
|
|
3008
3123
|
}
|
|
3009
3124
|
} else {
|
|
3125
|
+
import_log12.log.info("unknown peer connection error", err, {
|
|
3126
|
+
F: __dxlog_file11,
|
|
3127
|
+
L: 96,
|
|
3128
|
+
S: this,
|
|
3129
|
+
C: (f, a) => f(...a)
|
|
3130
|
+
});
|
|
3010
3131
|
this.errors.raise(err);
|
|
3011
3132
|
}
|
|
3012
3133
|
try {
|
|
3013
|
-
if (typeof this._peer?._pc
|
|
3134
|
+
if (typeof this._peer?._pc?.getStats === "function") {
|
|
3014
3135
|
this._peer._pc.getStats().then((stats) => {
|
|
3015
|
-
|
|
3136
|
+
import_log12.log.warn("report after webrtc error", {
|
|
3016
3137
|
config: this.params.webrtcConfig,
|
|
3017
3138
|
stats
|
|
3018
3139
|
}, {
|
|
3019
|
-
F:
|
|
3020
|
-
L:
|
|
3140
|
+
F: __dxlog_file11,
|
|
3141
|
+
L: 104,
|
|
3021
3142
|
S: this,
|
|
3022
3143
|
C: (f, a) => f(...a)
|
|
3023
3144
|
});
|
|
3024
3145
|
});
|
|
3025
3146
|
}
|
|
3026
3147
|
} catch (err2) {
|
|
3027
|
-
|
|
3028
|
-
F:
|
|
3029
|
-
L:
|
|
3148
|
+
import_log12.log.catch(err2, void 0, {
|
|
3149
|
+
F: __dxlog_file11,
|
|
3150
|
+
L: 111,
|
|
3030
3151
|
S: this,
|
|
3031
3152
|
C: (f, a) => f(...a)
|
|
3032
3153
|
});
|
|
3033
3154
|
}
|
|
3034
3155
|
await this.destroy();
|
|
3035
3156
|
});
|
|
3036
|
-
|
|
3157
|
+
import_log12.log.trace("dxos.mesh.webrtc-transport.constructor", import_protocols7.trace.end({
|
|
3037
3158
|
id: this._instanceId
|
|
3038
3159
|
}), {
|
|
3039
|
-
F:
|
|
3040
|
-
L:
|
|
3160
|
+
F: __dxlog_file11,
|
|
3161
|
+
L: 116,
|
|
3041
3162
|
S: this,
|
|
3042
3163
|
C: (f, a) => f(...a)
|
|
3043
3164
|
});
|
|
3044
3165
|
}
|
|
3045
3166
|
async destroy() {
|
|
3046
|
-
(0,
|
|
3047
|
-
F:
|
|
3048
|
-
L:
|
|
3167
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
3168
|
+
F: __dxlog_file11,
|
|
3169
|
+
L: 120,
|
|
3049
3170
|
S: this,
|
|
3050
3171
|
C: (f, a) => f(...a)
|
|
3051
3172
|
});
|
|
@@ -3053,9 +3174,9 @@ var SimplePeerTransport = class {
|
|
|
3053
3174
|
await this._disconnectStreams();
|
|
3054
3175
|
this._peer.destroy();
|
|
3055
3176
|
this.closed.emit();
|
|
3056
|
-
(0,
|
|
3057
|
-
F:
|
|
3058
|
-
L:
|
|
3177
|
+
(0, import_log12.log)("closed", void 0, {
|
|
3178
|
+
F: __dxlog_file11,
|
|
3179
|
+
L: 125,
|
|
3059
3180
|
S: this,
|
|
3060
3181
|
C: (f, a) => f(...a)
|
|
3061
3182
|
});
|
|
@@ -3082,16 +3203,15 @@ var createSimplePeerTransportFactory = (webrtcConfig) => ({
|
|
|
3082
3203
|
var import_node_stream2 = require("node:stream");
|
|
3083
3204
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
3084
3205
|
var import_invariant11 = require("@dxos/invariant");
|
|
3085
|
-
var
|
|
3086
|
-
var
|
|
3206
|
+
var import_keys12 = require("@dxos/keys");
|
|
3207
|
+
var import_log13 = require("@dxos/log");
|
|
3087
3208
|
var import_bridge = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
3088
|
-
var
|
|
3089
|
-
var
|
|
3209
|
+
var import_util9 = require("@dxos/util");
|
|
3210
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
3090
3211
|
var SimplePeerTransportService = class {
|
|
3091
|
-
// prettier-ignore
|
|
3092
3212
|
constructor(_webrtcConfig) {
|
|
3093
3213
|
this._webrtcConfig = _webrtcConfig;
|
|
3094
|
-
this.transports = new
|
|
3214
|
+
this.transports = new import_util9.ComplexMap(import_keys12.PublicKey.hash);
|
|
3095
3215
|
}
|
|
3096
3216
|
open(request) {
|
|
3097
3217
|
const rpcStream = new import_codec_protobuf.Stream(({ ready, next, close }) => {
|
|
@@ -3167,8 +3287,8 @@ var SimplePeerTransportService = class {
|
|
|
3167
3287
|
}
|
|
3168
3288
|
async sendSignal({ proxyId, signal }) {
|
|
3169
3289
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3170
|
-
F:
|
|
3171
|
-
L:
|
|
3290
|
+
F: __dxlog_file12,
|
|
3291
|
+
L: 110,
|
|
3172
3292
|
S: this,
|
|
3173
3293
|
A: [
|
|
3174
3294
|
"this.transports.has(proxyId)",
|
|
@@ -3179,8 +3299,8 @@ var SimplePeerTransportService = class {
|
|
|
3179
3299
|
}
|
|
3180
3300
|
async sendData({ proxyId, payload }) {
|
|
3181
3301
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3182
|
-
F:
|
|
3183
|
-
L:
|
|
3302
|
+
F: __dxlog_file12,
|
|
3303
|
+
L: 115,
|
|
3184
3304
|
S: this,
|
|
3185
3305
|
A: [
|
|
3186
3306
|
"this.transports.has(proxyId)",
|
|
@@ -3199,9 +3319,9 @@ var SimplePeerTransportService = class {
|
|
|
3199
3319
|
await this.transports.get(proxyId)?.transport.destroy();
|
|
3200
3320
|
await this.transports.get(proxyId)?.stream.end();
|
|
3201
3321
|
this.transports.delete(proxyId);
|
|
3202
|
-
(0,
|
|
3203
|
-
F:
|
|
3204
|
-
L:
|
|
3322
|
+
(0, import_log13.log)("Closed.", void 0, {
|
|
3323
|
+
F: __dxlog_file12,
|
|
3324
|
+
L: 129,
|
|
3205
3325
|
S: this,
|
|
3206
3326
|
C: (f, a) => f(...a)
|
|
3207
3327
|
});
|
|
@@ -3210,24 +3330,23 @@ var SimplePeerTransportService = class {
|
|
|
3210
3330
|
|
|
3211
3331
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts
|
|
3212
3332
|
var import_node_stream3 = require("node:stream");
|
|
3213
|
-
var
|
|
3333
|
+
var import_async11 = require("@dxos/async");
|
|
3214
3334
|
var import_context6 = require("@dxos/context");
|
|
3215
3335
|
var import_debug6 = require("@dxos/debug");
|
|
3216
3336
|
var import_invariant12 = require("@dxos/invariant");
|
|
3217
|
-
var
|
|
3218
|
-
var
|
|
3337
|
+
var import_keys13 = require("@dxos/keys");
|
|
3338
|
+
var import_log14 = require("@dxos/log");
|
|
3219
3339
|
var import_protocols8 = require("@dxos/protocols");
|
|
3220
3340
|
var import_bridge2 = require("@dxos/protocols/proto/dxos/mesh/bridge");
|
|
3221
|
-
var
|
|
3222
|
-
var
|
|
3341
|
+
var import_util10 = require("@dxos/util");
|
|
3342
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3223
3343
|
var SimplePeerTransportProxy = class {
|
|
3224
|
-
// prettier-ignore
|
|
3225
3344
|
constructor(_params) {
|
|
3226
3345
|
this._params = _params;
|
|
3227
|
-
this._proxyId =
|
|
3346
|
+
this._proxyId = import_keys13.PublicKey.random();
|
|
3228
3347
|
this._ctx = new import_context6.Context();
|
|
3229
|
-
this.closed = new
|
|
3230
|
-
this.connected = new
|
|
3348
|
+
this.closed = new import_async11.Event();
|
|
3349
|
+
this.connected = new import_async11.Event();
|
|
3231
3350
|
this.errors = new import_debug6.ErrorStream();
|
|
3232
3351
|
this._closed = false;
|
|
3233
3352
|
this._serviceStream = this._params.bridgeService.open({
|
|
@@ -3236,9 +3355,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3236
3355
|
});
|
|
3237
3356
|
this._serviceStream.waitUntilReady().then(() => {
|
|
3238
3357
|
this._serviceStream.subscribe(async (event) => {
|
|
3239
|
-
(0,
|
|
3240
|
-
F:
|
|
3241
|
-
L:
|
|
3358
|
+
(0, import_log14.log)("SimplePeerTransportProxy: event", event, {
|
|
3359
|
+
F: __dxlog_file13,
|
|
3360
|
+
L: 55,
|
|
3242
3361
|
S: this,
|
|
3243
3362
|
C: (f, a) => f(...a)
|
|
3244
3363
|
});
|
|
@@ -3256,8 +3375,8 @@ var SimplePeerTransportProxy = class {
|
|
|
3256
3375
|
proxyId: this._proxyId,
|
|
3257
3376
|
payload: chunk
|
|
3258
3377
|
}).then(() => callback(), (err) => {
|
|
3259
|
-
|
|
3260
|
-
F:
|
|
3378
|
+
import_log14.log.catch(err, void 0, {
|
|
3379
|
+
F: __dxlog_file13,
|
|
3261
3380
|
L: 76,
|
|
3262
3381
|
S: this,
|
|
3263
3382
|
C: (f, a) => f(...a)
|
|
@@ -3265,9 +3384,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3265
3384
|
});
|
|
3266
3385
|
}
|
|
3267
3386
|
}));
|
|
3268
|
-
}, (error) =>
|
|
3269
|
-
F:
|
|
3270
|
-
L:
|
|
3387
|
+
}, (error) => import_log14.log.catch(error, void 0, {
|
|
3388
|
+
F: __dxlog_file13,
|
|
3389
|
+
L: 83,
|
|
3271
3390
|
S: this,
|
|
3272
3391
|
C: (f, a) => f(...a)
|
|
3273
3392
|
}));
|
|
@@ -3288,7 +3407,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3288
3407
|
}
|
|
3289
3408
|
}
|
|
3290
3409
|
_handleData(dataEvent) {
|
|
3291
|
-
this._params.stream.write((0,
|
|
3410
|
+
this._params.stream.write((0, import_util10.arrayToBuffer)(dataEvent.payload));
|
|
3292
3411
|
}
|
|
3293
3412
|
async _handleSignal(signalEvent) {
|
|
3294
3413
|
await this._params.sendSignal(signalEvent.payload);
|
|
@@ -3311,9 +3430,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3311
3430
|
proxyId: this._proxyId
|
|
3312
3431
|
});
|
|
3313
3432
|
} catch (err) {
|
|
3314
|
-
|
|
3315
|
-
F:
|
|
3316
|
-
L:
|
|
3433
|
+
import_log14.log.catch(err, void 0, {
|
|
3434
|
+
F: __dxlog_file13,
|
|
3435
|
+
L: 134,
|
|
3317
3436
|
S: this,
|
|
3318
3437
|
C: (f, a) => f(...a)
|
|
3319
3438
|
});
|
|
@@ -3348,8 +3467,8 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3348
3467
|
}
|
|
3349
3468
|
createTransport(options) {
|
|
3350
3469
|
(0, import_invariant12.invariant)(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3351
|
-
F:
|
|
3352
|
-
L:
|
|
3470
|
+
F: __dxlog_file13,
|
|
3471
|
+
L: 171,
|
|
3353
3472
|
S: this,
|
|
3354
3473
|
A: [
|
|
3355
3474
|
"this._bridgeService",
|
|
@@ -3367,15 +3486,15 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3367
3486
|
};
|
|
3368
3487
|
var decodeError = (err) => {
|
|
3369
3488
|
const message = typeof err === "string" ? err : err.message;
|
|
3370
|
-
if (message.includes("
|
|
3489
|
+
if (message.includes("CONNECTION_RESET")) {
|
|
3371
3490
|
return new import_protocols8.ConnectionResetError(message);
|
|
3372
|
-
} else if (message.includes("
|
|
3491
|
+
} else if (message.includes("TIMEOUT")) {
|
|
3373
3492
|
return new import_protocols8.TimeoutError(message);
|
|
3374
|
-
} else if (message.includes("
|
|
3493
|
+
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3375
3494
|
return new import_protocols8.ProtocolError(message);
|
|
3376
|
-
} else if (message.includes("
|
|
3495
|
+
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
3377
3496
|
return new import_protocols8.ConnectivityError(message);
|
|
3378
|
-
} else if (message.includes("
|
|
3497
|
+
} else if (message.includes("UNKNOWN_PROTOCOL_ERROR")) {
|
|
3379
3498
|
return new import_protocols8.UnknownProtocolError(message);
|
|
3380
3499
|
} else {
|
|
3381
3500
|
return typeof err === "string" ? new Error(err) : err;
|
|
@@ -3387,9 +3506,9 @@ init_datachannel();
|
|
|
3387
3506
|
|
|
3388
3507
|
// packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts
|
|
3389
3508
|
var import_stream = require("stream");
|
|
3390
|
-
var
|
|
3509
|
+
var import_async12 = require("@dxos/async");
|
|
3391
3510
|
var import_debug7 = require("@dxos/debug");
|
|
3392
|
-
var
|
|
3511
|
+
var import_log15 = require("@dxos/log");
|
|
3393
3512
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
3394
3513
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3395
3514
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3400,7 +3519,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3400
3519
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3401
3520
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3402
3521
|
}
|
|
3403
|
-
var
|
|
3522
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3404
3523
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3405
3524
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3406
3525
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -3408,11 +3527,11 @@ var LibDataChannelTransport = class {
|
|
|
3408
3527
|
constructor(params) {
|
|
3409
3528
|
this.params = params;
|
|
3410
3529
|
this._closed = false;
|
|
3411
|
-
this.closed = new
|
|
3530
|
+
this.closed = new import_async12.Event();
|
|
3412
3531
|
this._connected = false;
|
|
3413
|
-
this.connected = new
|
|
3532
|
+
this.connected = new import_async12.Event();
|
|
3414
3533
|
this.errors = new import_debug7.ErrorStream();
|
|
3415
|
-
this._readyForCandidates = new
|
|
3534
|
+
this._readyForCandidates = new import_async12.Trigger();
|
|
3416
3535
|
this._writeCallback = null;
|
|
3417
3536
|
this._peer = (async () => {
|
|
3418
3537
|
const { RTCPeerConnection: PeerConnection2 } = await Promise.resolve().then(() => (init_datachannel(), datachannel_exports));
|
|
@@ -3421,32 +3540,32 @@ var LibDataChannelTransport = class {
|
|
|
3421
3540
|
}
|
|
3422
3541
|
const peer = new PeerConnection2(params.webrtcConfig);
|
|
3423
3542
|
peer.onicecandidateerror = (event) => {
|
|
3424
|
-
|
|
3543
|
+
import_log15.log.error("peer.onicecandidateerror", {
|
|
3425
3544
|
event
|
|
3426
3545
|
}, {
|
|
3427
|
-
F:
|
|
3546
|
+
F: __dxlog_file14,
|
|
3428
3547
|
L: 53,
|
|
3429
3548
|
S: this,
|
|
3430
3549
|
C: (f, a) => f(...a)
|
|
3431
3550
|
});
|
|
3432
3551
|
};
|
|
3433
3552
|
peer.onconnectionstatechange = (event) => {
|
|
3434
|
-
|
|
3553
|
+
import_log15.log.debug("peer.onconnectionstatechange", {
|
|
3435
3554
|
event,
|
|
3436
3555
|
peerConnectionState: peer.connectionState,
|
|
3437
3556
|
transportConnectionState: this._connected
|
|
3438
3557
|
}, {
|
|
3439
|
-
F:
|
|
3558
|
+
F: __dxlog_file14,
|
|
3440
3559
|
L: 57,
|
|
3441
3560
|
S: this,
|
|
3442
3561
|
C: (f, a) => f(...a)
|
|
3443
3562
|
});
|
|
3444
3563
|
};
|
|
3445
3564
|
peer.onicecandidate = async (event) => {
|
|
3446
|
-
|
|
3565
|
+
import_log15.log.debug("peer.onicecandidate", {
|
|
3447
3566
|
event
|
|
3448
3567
|
}, {
|
|
3449
|
-
F:
|
|
3568
|
+
F: __dxlog_file14,
|
|
3450
3569
|
L: 66,
|
|
3451
3570
|
S: this,
|
|
3452
3571
|
C: (f, a) => f(...a)
|
|
@@ -3467,10 +3586,10 @@ var LibDataChannelTransport = class {
|
|
|
3467
3586
|
}
|
|
3468
3587
|
});
|
|
3469
3588
|
} catch (err) {
|
|
3470
|
-
|
|
3589
|
+
import_log15.log.warn("signaling errror", {
|
|
3471
3590
|
err
|
|
3472
3591
|
}, {
|
|
3473
|
-
F:
|
|
3592
|
+
F: __dxlog_file14,
|
|
3474
3593
|
L: 83,
|
|
3475
3594
|
S: this,
|
|
3476
3595
|
C: (f, a) => f(...a)
|
|
@@ -3481,20 +3600,20 @@ var LibDataChannelTransport = class {
|
|
|
3481
3600
|
if (params.initiator) {
|
|
3482
3601
|
peer.createOffer().then(async (offer) => {
|
|
3483
3602
|
if (peer.connectionState !== "connecting") {
|
|
3484
|
-
|
|
3603
|
+
import_log15.log.error("i am initiator but peer not in state connecting", {
|
|
3485
3604
|
peer
|
|
3486
3605
|
}, {
|
|
3487
|
-
F:
|
|
3606
|
+
F: __dxlog_file14,
|
|
3488
3607
|
L: 92,
|
|
3489
3608
|
S: this,
|
|
3490
3609
|
C: (f, a) => f(...a)
|
|
3491
3610
|
});
|
|
3492
3611
|
this.errors.raise(new Error("invalid state: peer is initiator, but other peer not in state connecting"));
|
|
3493
3612
|
}
|
|
3494
|
-
|
|
3613
|
+
import_log15.log.debug(`im the initiator, creating offer, peer is in state ${peer.connectionState}`, {
|
|
3495
3614
|
offer
|
|
3496
3615
|
}, {
|
|
3497
|
-
F:
|
|
3616
|
+
F: __dxlog_file14,
|
|
3498
3617
|
L: 95,
|
|
3499
3618
|
S: this,
|
|
3500
3619
|
C: (f, a) => f(...a)
|
|
@@ -3513,8 +3632,8 @@ var LibDataChannelTransport = class {
|
|
|
3513
3632
|
this.errors.raise(err);
|
|
3514
3633
|
});
|
|
3515
3634
|
this.handleChannel(peer.createDataChannel(DATACHANNEL_LABEL));
|
|
3516
|
-
|
|
3517
|
-
F:
|
|
3635
|
+
import_log15.log.debug("created data channel", void 0, {
|
|
3636
|
+
F: __dxlog_file14,
|
|
3518
3637
|
L: 104,
|
|
3519
3638
|
S: this,
|
|
3520
3639
|
C: (f, a) => f(...a)
|
|
@@ -3524,10 +3643,10 @@ var LibDataChannelTransport = class {
|
|
|
3524
3643
|
};
|
|
3525
3644
|
} else {
|
|
3526
3645
|
peer.ondatachannel = (event) => {
|
|
3527
|
-
|
|
3646
|
+
import_log15.log.debug("peer.ondatachannel (non-initiator)", {
|
|
3528
3647
|
event
|
|
3529
3648
|
}, {
|
|
3530
|
-
F:
|
|
3649
|
+
F: __dxlog_file14,
|
|
3531
3650
|
L: 110,
|
|
3532
3651
|
S: this,
|
|
3533
3652
|
C: (f, a) => f(...a)
|
|
@@ -3544,8 +3663,8 @@ var LibDataChannelTransport = class {
|
|
|
3544
3663
|
handleChannel(dataChannel) {
|
|
3545
3664
|
this._channel = dataChannel;
|
|
3546
3665
|
this._channel.onopen = () => {
|
|
3547
|
-
|
|
3548
|
-
F:
|
|
3666
|
+
import_log15.log.debug("dataChannel.onopen", void 0, {
|
|
3667
|
+
F: __dxlog_file14,
|
|
3549
3668
|
L: 126,
|
|
3550
3669
|
S: this,
|
|
3551
3670
|
C: (f, a) => f(...a)
|
|
@@ -3560,8 +3679,8 @@ var LibDataChannelTransport = class {
|
|
|
3560
3679
|
dataChannel.send(chunk);
|
|
3561
3680
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3562
3681
|
if (this._writeCallback !== null) {
|
|
3563
|
-
|
|
3564
|
-
F:
|
|
3682
|
+
import_log15.log.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3683
|
+
F: __dxlog_file14,
|
|
3565
3684
|
L: 139,
|
|
3566
3685
|
S: this,
|
|
3567
3686
|
C: (f, a) => f(...a)
|
|
@@ -3583,10 +3702,10 @@ var LibDataChannelTransport = class {
|
|
|
3583
3702
|
await this._close();
|
|
3584
3703
|
};
|
|
3585
3704
|
this._channel.onclose = async (err) => {
|
|
3586
|
-
|
|
3705
|
+
import_log15.log.info("channel onclose", {
|
|
3587
3706
|
err
|
|
3588
3707
|
}, {
|
|
3589
|
-
F:
|
|
3708
|
+
F: __dxlog_file14,
|
|
3590
3709
|
L: 159,
|
|
3591
3710
|
S: this,
|
|
3592
3711
|
C: (f, a) => f(...a)
|
|
@@ -3620,10 +3739,10 @@ var LibDataChannelTransport = class {
|
|
|
3620
3739
|
switch (data.type) {
|
|
3621
3740
|
case "offer": {
|
|
3622
3741
|
if ((await this._peer).connectionState !== "new") {
|
|
3623
|
-
|
|
3742
|
+
import_log15.log.error("received offer but peer not in state new", {
|
|
3624
3743
|
peer
|
|
3625
3744
|
}, {
|
|
3626
|
-
F:
|
|
3745
|
+
F: __dxlog_file14,
|
|
3627
3746
|
L: 194,
|
|
3628
3747
|
S: this,
|
|
3629
3748
|
C: (f, a) => f(...a)
|
|
@@ -3648,10 +3767,10 @@ var LibDataChannelTransport = class {
|
|
|
3648
3767
|
});
|
|
3649
3768
|
this._readyForCandidates.wake();
|
|
3650
3769
|
} catch (err) {
|
|
3651
|
-
|
|
3770
|
+
import_log15.log.error("can't handle offer from signalling server", {
|
|
3652
3771
|
err
|
|
3653
3772
|
}, {
|
|
3654
|
-
F:
|
|
3773
|
+
F: __dxlog_file14,
|
|
3655
3774
|
L: 205,
|
|
3656
3775
|
S: this,
|
|
3657
3776
|
C: (f, a) => f(...a)
|
|
@@ -3668,10 +3787,10 @@ var LibDataChannelTransport = class {
|
|
|
3668
3787
|
});
|
|
3669
3788
|
this._readyForCandidates.wake();
|
|
3670
3789
|
} catch (err) {
|
|
3671
|
-
|
|
3790
|
+
import_log15.log.error("can't handle answer from signalling server", {
|
|
3672
3791
|
err
|
|
3673
3792
|
}, {
|
|
3674
|
-
F:
|
|
3793
|
+
F: __dxlog_file14,
|
|
3675
3794
|
L: 216,
|
|
3676
3795
|
S: this,
|
|
3677
3796
|
C: (f, a) => f(...a)
|
|
@@ -3686,11 +3805,11 @@ var LibDataChannelTransport = class {
|
|
|
3686
3805
|
});
|
|
3687
3806
|
break;
|
|
3688
3807
|
default:
|
|
3689
|
-
|
|
3808
|
+
import_log15.log.error("unhandled signal type", {
|
|
3690
3809
|
type: data.type,
|
|
3691
3810
|
signal
|
|
3692
3811
|
}, {
|
|
3693
|
-
F:
|
|
3812
|
+
F: __dxlog_file14,
|
|
3694
3813
|
L: 227,
|
|
3695
3814
|
S: this,
|
|
3696
3815
|
C: (f, a) => f(...a)
|
|
@@ -3698,8 +3817,8 @@ var LibDataChannelTransport = class {
|
|
|
3698
3817
|
this.errors.raise(new Error(`unhandled signal type ${data.type}`));
|
|
3699
3818
|
}
|
|
3700
3819
|
}).catch((err) => {
|
|
3701
|
-
|
|
3702
|
-
F:
|
|
3820
|
+
import_log15.log.catch(err, void 0, {
|
|
3821
|
+
F: __dxlog_file14,
|
|
3703
3822
|
L: 232,
|
|
3704
3823
|
S: this,
|
|
3705
3824
|
C: (f, a) => f(...a)
|
|
@@ -3715,7 +3834,7 @@ var LibDataChannelTransport = class {
|
|
|
3715
3834
|
}
|
|
3716
3835
|
};
|
|
3717
3836
|
_ts_decorate5([
|
|
3718
|
-
|
|
3837
|
+
import_async12.synchronized
|
|
3719
3838
|
], LibDataChannelTransport.prototype, "_close", null);
|
|
3720
3839
|
var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
3721
3840
|
createTransport: (params) => new LibDataChannelTransport({
|
|
@@ -3726,10 +3845,10 @@ var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
|
3726
3845
|
|
|
3727
3846
|
// packages/core/mesh/network-manager/src/transport/tcp-transport.ts
|
|
3728
3847
|
var import_node_net = require("node:net");
|
|
3729
|
-
var
|
|
3848
|
+
var import_async13 = require("@dxos/async");
|
|
3730
3849
|
var import_debug8 = require("@dxos/debug");
|
|
3731
|
-
var
|
|
3732
|
-
var
|
|
3850
|
+
var import_log16 = require("@dxos/log");
|
|
3851
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/tcp-transport.ts";
|
|
3733
3852
|
var TcpTransportFactory = {
|
|
3734
3853
|
createTransport: (params) => new TcpTransport(params)
|
|
3735
3854
|
};
|
|
@@ -3738,13 +3857,13 @@ var TcpTransport = class {
|
|
|
3738
3857
|
this.options = options;
|
|
3739
3858
|
this._server = void 0;
|
|
3740
3859
|
this._socket = void 0;
|
|
3741
|
-
this.closed = new
|
|
3742
|
-
this.connected = new
|
|
3860
|
+
this.closed = new import_async13.Event();
|
|
3861
|
+
this.connected = new import_async13.Event();
|
|
3743
3862
|
this.errors = new import_debug8.ErrorStream();
|
|
3744
3863
|
this._destroyed = false;
|
|
3745
3864
|
this._connected = false;
|
|
3746
|
-
(0,
|
|
3747
|
-
F:
|
|
3865
|
+
(0, import_log16.log)("creating", void 0, {
|
|
3866
|
+
F: __dxlog_file15,
|
|
3748
3867
|
L: 34,
|
|
3749
3868
|
S: this,
|
|
3750
3869
|
C: (f, a) => f(...a)
|
|
@@ -3753,8 +3872,8 @@ var TcpTransport = class {
|
|
|
3753
3872
|
setTimeout(async () => {
|
|
3754
3873
|
const { Server } = await import("node:net");
|
|
3755
3874
|
this._server = new Server((socket) => {
|
|
3756
|
-
(0,
|
|
3757
|
-
F:
|
|
3875
|
+
(0, import_log16.log)("new connection", void 0, {
|
|
3876
|
+
F: __dxlog_file15,
|
|
3758
3877
|
L: 42,
|
|
3759
3878
|
S: this,
|
|
3760
3879
|
C: (f, a) => f(...a)
|
|
@@ -3766,10 +3885,10 @@ var TcpTransport = class {
|
|
|
3766
3885
|
});
|
|
3767
3886
|
this._server.on("listening", () => {
|
|
3768
3887
|
const { port: port2 } = this._server.address();
|
|
3769
|
-
(0,
|
|
3888
|
+
(0, import_log16.log)("listening", {
|
|
3770
3889
|
port: port2
|
|
3771
3890
|
}, {
|
|
3772
|
-
F:
|
|
3891
|
+
F: __dxlog_file15,
|
|
3773
3892
|
L: 51,
|
|
3774
3893
|
S: this,
|
|
3775
3894
|
C: (f, a) => f(...a)
|
|
@@ -3792,8 +3911,8 @@ var TcpTransport = class {
|
|
|
3792
3911
|
}
|
|
3793
3912
|
}
|
|
3794
3913
|
async destroy() {
|
|
3795
|
-
(0,
|
|
3796
|
-
F:
|
|
3914
|
+
(0, import_log16.log)("closing", void 0, {
|
|
3915
|
+
F: __dxlog_file15,
|
|
3797
3916
|
L: 72,
|
|
3798
3917
|
S: this,
|
|
3799
3918
|
C: (f, a) => f(...a)
|
|
@@ -3803,10 +3922,10 @@ var TcpTransport = class {
|
|
|
3803
3922
|
this._destroyed = true;
|
|
3804
3923
|
}
|
|
3805
3924
|
signal({ payload }) {
|
|
3806
|
-
(0,
|
|
3925
|
+
(0, import_log16.log)("received signal", {
|
|
3807
3926
|
payload
|
|
3808
3927
|
}, {
|
|
3809
|
-
F:
|
|
3928
|
+
F: __dxlog_file15,
|
|
3810
3929
|
L: 80,
|
|
3811
3930
|
S: this,
|
|
3812
3931
|
C: (f, a) => f(...a)
|
|
@@ -3822,11 +3941,11 @@ var TcpTransport = class {
|
|
|
3822
3941
|
});
|
|
3823
3942
|
}
|
|
3824
3943
|
_handleSocket(socket) {
|
|
3825
|
-
(0,
|
|
3944
|
+
(0, import_log16.log)("handling socket", {
|
|
3826
3945
|
remotePort: socket.remotePort,
|
|
3827
3946
|
localPort: socket.localPort
|
|
3828
3947
|
}, {
|
|
3829
|
-
F:
|
|
3948
|
+
F: __dxlog_file15,
|
|
3830
3949
|
L: 91,
|
|
3831
3950
|
S: this,
|
|
3832
3951
|
C: (f, a) => f(...a)
|
|
@@ -3835,10 +3954,10 @@ var TcpTransport = class {
|
|
|
3835
3954
|
this.connected.emit();
|
|
3836
3955
|
this.options.stream.pipe(this._socket).pipe(this.options.stream);
|
|
3837
3956
|
this._socket.on("connect", () => {
|
|
3838
|
-
(0,
|
|
3957
|
+
(0, import_log16.log)("connected to", {
|
|
3839
3958
|
port: this._socket?.remotePort
|
|
3840
3959
|
}, {
|
|
3841
|
-
F:
|
|
3960
|
+
F: __dxlog_file15,
|
|
3842
3961
|
L: 97,
|
|
3843
3962
|
S: this,
|
|
3844
3963
|
C: (f, a) => f(...a)
|
|
@@ -3854,118 +3973,6 @@ var TcpTransport = class {
|
|
|
3854
3973
|
}
|
|
3855
3974
|
};
|
|
3856
3975
|
|
|
3857
|
-
// packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
|
|
3858
|
-
var import_async13 = require("@dxos/async");
|
|
3859
|
-
var import_keys13 = require("@dxos/keys");
|
|
3860
|
-
var import_log16 = require("@dxos/log");
|
|
3861
|
-
var import_teleport2 = require("@dxos/teleport");
|
|
3862
|
-
var import_util10 = require("@dxos/util");
|
|
3863
|
-
|
|
3864
|
-
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
3865
|
-
var import_teleport = require("@dxos/teleport");
|
|
3866
|
-
var createTeleportProtocolFactory = (onConnection) => {
|
|
3867
|
-
return (params) => {
|
|
3868
|
-
const teleport = new import_teleport.Teleport(params);
|
|
3869
|
-
return {
|
|
3870
|
-
stream: teleport.stream,
|
|
3871
|
-
open: async () => {
|
|
3872
|
-
await teleport.open();
|
|
3873
|
-
await onConnection(teleport);
|
|
3874
|
-
},
|
|
3875
|
-
close: async () => {
|
|
3876
|
-
await teleport.close();
|
|
3877
|
-
},
|
|
3878
|
-
abort: async () => {
|
|
3879
|
-
await teleport.abort();
|
|
3880
|
-
}
|
|
3881
|
-
};
|
|
3882
|
-
};
|
|
3883
|
-
};
|
|
3884
|
-
|
|
3885
|
-
// packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts
|
|
3886
|
-
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/testing/test-wire-protocol.ts";
|
|
3887
|
-
var TestWireProtocol = class {
|
|
3888
|
-
constructor(peerId, _extensionFactory = () => []) {
|
|
3889
|
-
this.peerId = peerId;
|
|
3890
|
-
this._extensionFactory = _extensionFactory;
|
|
3891
|
-
this.connections = new import_util10.ComplexMap(import_keys13.PublicKey.hash);
|
|
3892
|
-
this.streamConnections = new import_util10.ComplexMap(import_keys13.PublicKey.hash);
|
|
3893
|
-
this.connected = new import_async13.Event();
|
|
3894
|
-
this.disconnected = new import_async13.Event();
|
|
3895
|
-
this.otherConnections = new import_util10.ComplexMap(({ remotePeerId, extension }) => remotePeerId.toHex() + extension);
|
|
3896
|
-
this.factory = createTeleportProtocolFactory(async (teleport) => {
|
|
3897
|
-
(0, import_log16.log)("create", {
|
|
3898
|
-
remotePeerId: teleport.remotePeerId
|
|
3899
|
-
}, {
|
|
3900
|
-
F: __dxlog_file15,
|
|
3901
|
-
L: 38,
|
|
3902
|
-
S: this,
|
|
3903
|
-
C: (f, a) => f(...a)
|
|
3904
|
-
});
|
|
3905
|
-
const extension = new import_teleport2.TestExtension({
|
|
3906
|
-
onClose: async () => {
|
|
3907
|
-
this.connections.delete(teleport.remotePeerId);
|
|
3908
|
-
this.disconnected.emit(teleport.remotePeerId);
|
|
3909
|
-
}
|
|
3910
|
-
});
|
|
3911
|
-
this.connections.set(teleport.remotePeerId, extension);
|
|
3912
|
-
teleport.addExtension("test", extension);
|
|
3913
|
-
this.connected.emit(teleport.remotePeerId);
|
|
3914
|
-
const streamExtension = new import_teleport2.TestExtensionWithStreams({
|
|
3915
|
-
onClose: async () => {
|
|
3916
|
-
this.streamConnections.delete(teleport.remotePeerId);
|
|
3917
|
-
}
|
|
3918
|
-
});
|
|
3919
|
-
this.streamConnections.set(teleport.remotePeerId, streamExtension);
|
|
3920
|
-
teleport.addExtension("test-stream", streamExtension);
|
|
3921
|
-
for (const { name, extension: extension2 } of this._extensionFactory()) {
|
|
3922
|
-
this.otherConnections.set({
|
|
3923
|
-
remotePeerId: teleport.remotePeerId,
|
|
3924
|
-
extension: name
|
|
3925
|
-
}, extension2);
|
|
3926
|
-
teleport.addExtension(name, extension2);
|
|
3927
|
-
}
|
|
3928
|
-
});
|
|
3929
|
-
}
|
|
3930
|
-
async waitForConnection(peerId) {
|
|
3931
|
-
if (this.connections.has(peerId)) {
|
|
3932
|
-
return this.connections.get(peerId);
|
|
3933
|
-
}
|
|
3934
|
-
(0, import_log16.log)("waitForConnection", {
|
|
3935
|
-
peerId
|
|
3936
|
-
}, {
|
|
3937
|
-
F: __dxlog_file15,
|
|
3938
|
-
L: 67,
|
|
3939
|
-
S: this,
|
|
3940
|
-
C: (f, a) => f(...a)
|
|
3941
|
-
});
|
|
3942
|
-
await (0, import_async13.asyncTimeout)(
|
|
3943
|
-
this.connected.waitFor((connectedId) => connectedId.equals(peerId)),
|
|
3944
|
-
// TODO(nf): Make this configurable.
|
|
3945
|
-
1e4
|
|
3946
|
-
);
|
|
3947
|
-
return this.connections.get(peerId);
|
|
3948
|
-
}
|
|
3949
|
-
async testConnection(peerId, message) {
|
|
3950
|
-
const connection = await this.waitForConnection(peerId);
|
|
3951
|
-
await connection.test(message);
|
|
3952
|
-
}
|
|
3953
|
-
async openStream(peerId, streamTag, streamLoadInterval, streamLoadChunkSize) {
|
|
3954
|
-
if (!this.streamConnections.has(peerId)) {
|
|
3955
|
-
throw new Error("Connection does not exist.");
|
|
3956
|
-
}
|
|
3957
|
-
const connection = this.streamConnections.get(peerId);
|
|
3958
|
-
return connection.addNewStream(streamLoadInterval, streamLoadChunkSize, streamTag);
|
|
3959
|
-
}
|
|
3960
|
-
async closeStream(peerId, streamTag) {
|
|
3961
|
-
if (!this.streamConnections.has(peerId)) {
|
|
3962
|
-
throw new Error("Connection does not exist.");
|
|
3963
|
-
}
|
|
3964
|
-
const connection = this.streamConnections.get(peerId);
|
|
3965
|
-
return connection.closeStream(streamTag);
|
|
3966
|
-
}
|
|
3967
|
-
};
|
|
3968
|
-
|
|
3969
3976
|
// packages/core/mesh/network-manager/src/testing/test-builder.ts
|
|
3970
3977
|
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/testing/test-builder.ts";
|
|
3971
3978
|
var port = process.env.SIGNAL_PORT ?? 4e3;
|