@dxos/network-manager 0.1.56-main.cf6bb41 → 0.1.56-main.d36ce19
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-5TRIVLI6.mjs → chunk-BVDMMHEG.mjs} +87 -73
- package/dist/lib/browser/chunk-BVDMMHEG.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 +18 -8
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +86 -72
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +103 -79
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts +1 -1
- package/dist/types/src/signal/swarm-messenger.d.ts.map +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +2 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +4 -3
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-wire-protocol.d.ts +13 -2
- package/dist/types/src/testing/test-wire-protocol.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts +1 -1
- package/dist/types/src/transport/webrtc-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport.d.ts +3 -3
- package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/connection-log.ts +2 -0
- package/src/signal/swarm-messenger.ts +2 -2
- package/src/swarm/connection-limiter.ts +1 -1
- package/src/swarm/connection.ts +8 -1
- package/src/swarm/peer.ts +8 -6
- package/src/swarm/swarm.ts +5 -5
- package/src/testing/test-builder.ts +9 -5
- package/src/testing/test-wire-protocol.ts +22 -2
- package/src/tests/memory-transport.test.ts +1 -1
- package/src/transport/webrtc-transport-proxy.ts +4 -4
- package/src/transport/webrtc-transport.ts +20 -6
- package/dist/lib/browser/chunk-5TRIVLI6.mjs.map +0 -7
|
@@ -92,7 +92,7 @@ var Connection = class {
|
|
|
92
92
|
initiator: this.initiator
|
|
93
93
|
}, {
|
|
94
94
|
F: __dxlog_file,
|
|
95
|
-
L:
|
|
95
|
+
L: 96,
|
|
96
96
|
S: this,
|
|
97
97
|
C: (f, a) => f(...a)
|
|
98
98
|
});
|
|
@@ -112,7 +112,7 @@ var Connection = class {
|
|
|
112
112
|
async openConnection() {
|
|
113
113
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
114
114
|
F: __dxlog_file,
|
|
115
|
-
L:
|
|
115
|
+
L: 121,
|
|
116
116
|
S: this,
|
|
117
117
|
A: [
|
|
118
118
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -123,7 +123,7 @@ var Connection = class {
|
|
|
123
123
|
id: this._instanceId
|
|
124
124
|
}), {
|
|
125
125
|
F: __dxlog_file,
|
|
126
|
-
L:
|
|
126
|
+
L: 122,
|
|
127
127
|
S: this,
|
|
128
128
|
C: (f, a) => f(...a)
|
|
129
129
|
});
|
|
@@ -135,7 +135,7 @@ var Connection = class {
|
|
|
135
135
|
initiator: this.initiator
|
|
136
136
|
}, {
|
|
137
137
|
F: __dxlog_file,
|
|
138
|
-
L:
|
|
138
|
+
L: 123,
|
|
139
139
|
S: this,
|
|
140
140
|
C: (f, a) => f(...a)
|
|
141
141
|
});
|
|
@@ -146,7 +146,7 @@ var Connection = class {
|
|
|
146
146
|
this._protocol.stream.on("close", () => {
|
|
147
147
|
log("protocol stream closed", void 0, {
|
|
148
148
|
F: __dxlog_file,
|
|
149
|
-
L:
|
|
149
|
+
L: 140,
|
|
150
150
|
S: this,
|
|
151
151
|
C: (f, a) => f(...a)
|
|
152
152
|
});
|
|
@@ -154,7 +154,7 @@ var Connection = class {
|
|
|
154
154
|
});
|
|
155
155
|
invariant(!this._transport, void 0, {
|
|
156
156
|
F: __dxlog_file,
|
|
157
|
-
L:
|
|
157
|
+
L: 144,
|
|
158
158
|
S: this,
|
|
159
159
|
A: [
|
|
160
160
|
"!this._transport",
|
|
@@ -174,6 +174,9 @@ var Connection = class {
|
|
|
174
174
|
this.close().catch((err) => this.errors.raise(err));
|
|
175
175
|
});
|
|
176
176
|
this._transport.errors.handle((err) => {
|
|
177
|
+
if (!this.closeReason) {
|
|
178
|
+
this.closeReason = err?.message;
|
|
179
|
+
}
|
|
177
180
|
if (this._state !== ConnectionState.CLOSED && this._state !== ConnectionState.CLOSING) {
|
|
178
181
|
this.errors.raise(err);
|
|
179
182
|
}
|
|
@@ -186,12 +189,15 @@ var Connection = class {
|
|
|
186
189
|
id: this._instanceId
|
|
187
190
|
}), {
|
|
188
191
|
F: __dxlog_file,
|
|
189
|
-
L:
|
|
192
|
+
L: 176,
|
|
190
193
|
S: this,
|
|
191
194
|
C: (f, a) => f(...a)
|
|
192
195
|
});
|
|
193
196
|
}
|
|
194
|
-
async close() {
|
|
197
|
+
async close(err) {
|
|
198
|
+
if (!this.closeReason) {
|
|
199
|
+
this.closeReason = err?.message;
|
|
200
|
+
}
|
|
195
201
|
if (this._state === ConnectionState.CLOSED) {
|
|
196
202
|
return;
|
|
197
203
|
}
|
|
@@ -201,26 +207,26 @@ var Connection = class {
|
|
|
201
207
|
peerId: this.ownId
|
|
202
208
|
}, {
|
|
203
209
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
210
|
+
L: 191,
|
|
205
211
|
S: this,
|
|
206
212
|
C: (f, a) => f(...a)
|
|
207
213
|
});
|
|
208
214
|
try {
|
|
209
215
|
await this._protocol.destroy();
|
|
210
|
-
} catch (
|
|
211
|
-
log.catch(
|
|
216
|
+
} catch (err2) {
|
|
217
|
+
log.catch(err2, void 0, {
|
|
212
218
|
F: __dxlog_file,
|
|
213
|
-
L:
|
|
219
|
+
L: 197,
|
|
214
220
|
S: this,
|
|
215
221
|
C: (f, a) => f(...a)
|
|
216
222
|
});
|
|
217
223
|
}
|
|
218
224
|
try {
|
|
219
225
|
await this._transport?.destroy();
|
|
220
|
-
} catch (
|
|
221
|
-
log.catch(
|
|
226
|
+
} catch (err2) {
|
|
227
|
+
log.catch(err2, void 0, {
|
|
222
228
|
F: __dxlog_file,
|
|
223
|
-
L:
|
|
229
|
+
L: 204,
|
|
224
230
|
S: this,
|
|
225
231
|
C: (f, a) => f(...a)
|
|
226
232
|
});
|
|
@@ -229,7 +235,7 @@ var Connection = class {
|
|
|
229
235
|
peerId: this.ownId
|
|
230
236
|
}, {
|
|
231
237
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
238
|
+
L: 207,
|
|
233
239
|
S: this,
|
|
234
240
|
C: (f, a) => f(...a)
|
|
235
241
|
});
|
|
@@ -269,7 +275,7 @@ var Connection = class {
|
|
|
269
275
|
err
|
|
270
276
|
}, {
|
|
271
277
|
F: __dxlog_file,
|
|
272
|
-
L:
|
|
278
|
+
L: 241,
|
|
273
279
|
S: this,
|
|
274
280
|
C: (f, a) => f(...a)
|
|
275
281
|
});
|
|
@@ -282,7 +288,7 @@ var Connection = class {
|
|
|
282
288
|
async signal(msg) {
|
|
283
289
|
invariant(msg.sessionId, void 0, {
|
|
284
290
|
F: __dxlog_file,
|
|
285
|
-
L:
|
|
291
|
+
L: 250,
|
|
286
292
|
S: this,
|
|
287
293
|
A: [
|
|
288
294
|
"msg.sessionId",
|
|
@@ -292,7 +298,7 @@ var Connection = class {
|
|
|
292
298
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
293
299
|
log("dropping signal for incorrect session id", void 0, {
|
|
294
300
|
F: __dxlog_file,
|
|
295
|
-
L:
|
|
301
|
+
L: 252,
|
|
296
302
|
S: this,
|
|
297
303
|
C: (f, a) => f(...a)
|
|
298
304
|
});
|
|
@@ -300,7 +306,7 @@ var Connection = class {
|
|
|
300
306
|
}
|
|
301
307
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
302
308
|
F: __dxlog_file,
|
|
303
|
-
L:
|
|
309
|
+
L: 255,
|
|
304
310
|
S: this,
|
|
305
311
|
A: [
|
|
306
312
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -309,7 +315,7 @@ var Connection = class {
|
|
|
309
315
|
});
|
|
310
316
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
311
317
|
F: __dxlog_file,
|
|
312
|
-
L:
|
|
318
|
+
L: 256,
|
|
313
319
|
S: this,
|
|
314
320
|
A: [
|
|
315
321
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -318,7 +324,7 @@ var Connection = class {
|
|
|
318
324
|
});
|
|
319
325
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
320
326
|
F: __dxlog_file,
|
|
321
|
-
L:
|
|
327
|
+
L: 257,
|
|
322
328
|
S: this,
|
|
323
329
|
A: [
|
|
324
330
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -339,7 +345,7 @@ var Connection = class {
|
|
|
339
345
|
msg: msg.data
|
|
340
346
|
}, {
|
|
341
347
|
F: __dxlog_file,
|
|
342
|
-
L:
|
|
348
|
+
L: 266,
|
|
343
349
|
S: this,
|
|
344
350
|
C: (f, a) => f(...a)
|
|
345
351
|
});
|
|
@@ -347,7 +353,7 @@ var Connection = class {
|
|
|
347
353
|
} else {
|
|
348
354
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
349
355
|
F: __dxlog_file,
|
|
350
|
-
L:
|
|
356
|
+
L: 269,
|
|
351
357
|
S: this,
|
|
352
358
|
A: [
|
|
353
359
|
"this._transport",
|
|
@@ -360,7 +366,7 @@ var Connection = class {
|
|
|
360
366
|
msg: msg.data
|
|
361
367
|
}, {
|
|
362
368
|
F: __dxlog_file,
|
|
363
|
-
L:
|
|
369
|
+
L: 270,
|
|
364
370
|
S: this,
|
|
365
371
|
C: (f, a) => f(...a)
|
|
366
372
|
});
|
|
@@ -375,13 +381,13 @@ var Connection = class {
|
|
|
375
381
|
peerId: this.ownId
|
|
376
382
|
}, {
|
|
377
383
|
F: __dxlog_file,
|
|
378
|
-
L:
|
|
384
|
+
L: 277,
|
|
379
385
|
S: this,
|
|
380
386
|
C: (f, a) => f(...a)
|
|
381
387
|
});
|
|
382
388
|
invariant(state !== this._state, "Already in this state.", {
|
|
383
389
|
F: __dxlog_file,
|
|
384
|
-
L:
|
|
390
|
+
L: 278,
|
|
385
391
|
S: this,
|
|
386
392
|
A: [
|
|
387
393
|
"state !== this._state",
|
|
@@ -658,6 +664,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
658
664
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
659
665
|
var CONNECTION_COUNTS_STABLE_AFTER = 5e3;
|
|
660
666
|
var Peer = class {
|
|
667
|
+
// TODO(burdon): Convert to map?
|
|
661
668
|
constructor(id, topic, localPeerId, _signalMessaging, _protocolProvider, _transportFactory, _connectionLimiter, _callbacks) {
|
|
662
669
|
this.id = id;
|
|
663
670
|
this.topic = topic;
|
|
@@ -687,12 +694,12 @@ var Peer = class {
|
|
|
687
694
|
sessionId: this.connection?.sessionId
|
|
688
695
|
}, {
|
|
689
696
|
F: __dxlog_file3,
|
|
690
|
-
L:
|
|
697
|
+
L: 108,
|
|
691
698
|
S: this,
|
|
692
699
|
C: (f, a) => f(...a)
|
|
693
700
|
});
|
|
694
701
|
if (this.connection) {
|
|
695
|
-
await this.closeConnection();
|
|
702
|
+
await this.closeConnection(new Error("Connection displaced by remote initiator."));
|
|
696
703
|
}
|
|
697
704
|
} else {
|
|
698
705
|
return {
|
|
@@ -704,7 +711,7 @@ var Peer = class {
|
|
|
704
711
|
if (!this.connection) {
|
|
705
712
|
invariant3(message.sessionId, void 0, {
|
|
706
713
|
F: __dxlog_file3,
|
|
707
|
-
L:
|
|
714
|
+
L: 128,
|
|
708
715
|
S: this,
|
|
709
716
|
A: [
|
|
710
717
|
"message.sessionId",
|
|
@@ -724,12 +731,12 @@ var Peer = class {
|
|
|
724
731
|
err
|
|
725
732
|
}, {
|
|
726
733
|
F: __dxlog_file3,
|
|
727
|
-
L:
|
|
734
|
+
L: 136,
|
|
728
735
|
S: this,
|
|
729
736
|
C: (f, a) => f(...a)
|
|
730
737
|
});
|
|
731
738
|
}
|
|
732
|
-
await this.closeConnection();
|
|
739
|
+
await this.closeConnection(err);
|
|
733
740
|
}
|
|
734
741
|
return {
|
|
735
742
|
accept: true
|
|
@@ -746,7 +753,7 @@ var Peer = class {
|
|
|
746
753
|
async initiateConnection() {
|
|
747
754
|
invariant3(!this.initiating, "Initiation in progress.", {
|
|
748
755
|
F: __dxlog_file3,
|
|
749
|
-
L:
|
|
756
|
+
L: 153,
|
|
750
757
|
S: this,
|
|
751
758
|
A: [
|
|
752
759
|
"!this.initiating",
|
|
@@ -755,7 +762,7 @@ var Peer = class {
|
|
|
755
762
|
});
|
|
756
763
|
invariant3(!this.connection, "Already connected.", {
|
|
757
764
|
F: __dxlog_file3,
|
|
758
|
-
L:
|
|
765
|
+
L: 154,
|
|
759
766
|
S: this,
|
|
760
767
|
A: [
|
|
761
768
|
"!this.connection",
|
|
@@ -770,7 +777,7 @@ var Peer = class {
|
|
|
770
777
|
sessionId
|
|
771
778
|
}, {
|
|
772
779
|
F: __dxlog_file3,
|
|
773
|
-
L:
|
|
780
|
+
L: 156,
|
|
774
781
|
S: this,
|
|
775
782
|
C: (f, a) => f(...a)
|
|
776
783
|
});
|
|
@@ -794,14 +801,14 @@ var Peer = class {
|
|
|
794
801
|
remoteId: this.id
|
|
795
802
|
}, {
|
|
796
803
|
F: __dxlog_file3,
|
|
797
|
-
L:
|
|
804
|
+
L: 171,
|
|
798
805
|
S: this,
|
|
799
806
|
C: (f, a) => f(...a)
|
|
800
807
|
});
|
|
801
808
|
if (connection.state !== ConnectionState.INITIAL) {
|
|
802
809
|
log3("ignoring response", void 0, {
|
|
803
810
|
F: __dxlog_file3,
|
|
804
|
-
L:
|
|
811
|
+
L: 173,
|
|
805
812
|
S: this,
|
|
806
813
|
C: (f, a) => f(...a)
|
|
807
814
|
});
|
|
@@ -821,11 +828,11 @@ var Peer = class {
|
|
|
821
828
|
remoteId: this.id
|
|
822
829
|
}, {
|
|
823
830
|
F: __dxlog_file3,
|
|
824
|
-
L:
|
|
831
|
+
L: 184,
|
|
825
832
|
S: this,
|
|
826
833
|
C: (f, a) => f(...a)
|
|
827
834
|
});
|
|
828
|
-
await this.closeConnection();
|
|
835
|
+
await this.closeConnection(err);
|
|
829
836
|
throw err;
|
|
830
837
|
} finally {
|
|
831
838
|
this.initiating = false;
|
|
@@ -844,13 +851,13 @@ var Peer = class {
|
|
|
844
851
|
sessionId
|
|
845
852
|
}, {
|
|
846
853
|
F: __dxlog_file3,
|
|
847
|
-
L:
|
|
854
|
+
L: 198,
|
|
848
855
|
S: this,
|
|
849
856
|
C: (f, a) => f(...a)
|
|
850
857
|
});
|
|
851
858
|
invariant3(!this.connection, "Already connected.", {
|
|
852
859
|
F: __dxlog_file3,
|
|
853
|
-
L:
|
|
860
|
+
L: 205,
|
|
854
861
|
S: this,
|
|
855
862
|
A: [
|
|
856
863
|
"!this.connection",
|
|
@@ -891,7 +898,7 @@ var Peer = class {
|
|
|
891
898
|
initiator
|
|
892
899
|
}, {
|
|
893
900
|
F: __dxlog_file3,
|
|
894
|
-
L:
|
|
901
|
+
L: 231,
|
|
895
902
|
S: this,
|
|
896
903
|
C: (f, a) => f(...a)
|
|
897
904
|
});
|
|
@@ -905,13 +912,13 @@ var Peer = class {
|
|
|
905
912
|
initiator
|
|
906
913
|
}, {
|
|
907
914
|
F: __dxlog_file3,
|
|
908
|
-
L:
|
|
915
|
+
L: 242,
|
|
909
916
|
S: this,
|
|
910
917
|
C: (f, a) => f(...a)
|
|
911
918
|
});
|
|
912
919
|
invariant3(this.connection === connection, "Connection mismatch (race condition).", {
|
|
913
920
|
F: __dxlog_file3,
|
|
914
|
-
L:
|
|
921
|
+
L: 243,
|
|
915
922
|
S: this,
|
|
916
923
|
A: [
|
|
917
924
|
"this.connection === connection",
|
|
@@ -926,7 +933,7 @@ var Peer = class {
|
|
|
926
933
|
initiator
|
|
927
934
|
}, {
|
|
928
935
|
F: __dxlog_file3,
|
|
929
|
-
L:
|
|
936
|
+
L: 245,
|
|
930
937
|
S: this,
|
|
931
938
|
C: (f, a) => f(...a)
|
|
932
939
|
});
|
|
@@ -956,7 +963,7 @@ var Peer = class {
|
|
|
956
963
|
err
|
|
957
964
|
}, {
|
|
958
965
|
F: __dxlog_file3,
|
|
959
|
-
L:
|
|
966
|
+
L: 279,
|
|
960
967
|
S: this,
|
|
961
968
|
C: (f, a) => f(...a)
|
|
962
969
|
});
|
|
@@ -969,16 +976,16 @@ var Peer = class {
|
|
|
969
976
|
err
|
|
970
977
|
}, {
|
|
971
978
|
F: __dxlog_file3,
|
|
972
|
-
L:
|
|
979
|
+
L: 280,
|
|
973
980
|
S: this,
|
|
974
981
|
C: (f, a) => f(...a)
|
|
975
982
|
});
|
|
976
|
-
void this.closeConnection();
|
|
983
|
+
void this.closeConnection(err);
|
|
977
984
|
});
|
|
978
985
|
this.connection = connection;
|
|
979
986
|
return connection;
|
|
980
987
|
}
|
|
981
|
-
async closeConnection() {
|
|
988
|
+
async closeConnection(err) {
|
|
982
989
|
if (!this.connection) {
|
|
983
990
|
return;
|
|
984
991
|
}
|
|
@@ -988,17 +995,17 @@ var Peer = class {
|
|
|
988
995
|
sessionId: connection.sessionId
|
|
989
996
|
}, {
|
|
990
997
|
F: __dxlog_file3,
|
|
991
|
-
L:
|
|
998
|
+
L: 303,
|
|
992
999
|
S: this,
|
|
993
1000
|
C: (f, a) => f(...a)
|
|
994
1001
|
});
|
|
995
|
-
await connection.close();
|
|
1002
|
+
await connection.close(err);
|
|
996
1003
|
log3("closed", {
|
|
997
1004
|
peerId: this.id,
|
|
998
1005
|
sessionId: connection.sessionId
|
|
999
1006
|
}, {
|
|
1000
1007
|
F: __dxlog_file3,
|
|
1001
|
-
L:
|
|
1008
|
+
L: 309,
|
|
1002
1009
|
S: this,
|
|
1003
1010
|
C: (f, a) => f(...a)
|
|
1004
1011
|
});
|
|
@@ -1009,7 +1016,7 @@ var Peer = class {
|
|
|
1009
1016
|
message
|
|
1010
1017
|
}, {
|
|
1011
1018
|
F: __dxlog_file3,
|
|
1012
|
-
L:
|
|
1019
|
+
L: 314,
|
|
1013
1020
|
S: this,
|
|
1014
1021
|
C: (f, a) => f(...a)
|
|
1015
1022
|
});
|
|
@@ -1024,7 +1031,7 @@ var Peer = class {
|
|
|
1024
1031
|
topic: this.topic
|
|
1025
1032
|
}, {
|
|
1026
1033
|
F: __dxlog_file3,
|
|
1027
|
-
L:
|
|
1034
|
+
L: 324,
|
|
1028
1035
|
S: this,
|
|
1029
1036
|
C: (f, a) => f(...a)
|
|
1030
1037
|
});
|
|
@@ -1073,9 +1080,9 @@ var Swarm = class {
|
|
|
1073
1080
|
this._transportFactory = _transportFactory;
|
|
1074
1081
|
this._label = _label;
|
|
1075
1082
|
this._connectionLimiter = _connectionLimiter;
|
|
1076
|
-
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
1077
1083
|
this._ctx = new Context4();
|
|
1078
1084
|
this._listeningHandle = void 0;
|
|
1085
|
+
this._peers = new ComplexMap2(PublicKey4.hash);
|
|
1079
1086
|
this._instanceId = PublicKey4.random().toHex();
|
|
1080
1087
|
this.connectionAdded = new Event2();
|
|
1081
1088
|
this.disconnected = new Event2();
|
|
@@ -1605,7 +1612,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1605
1612
|
import { log as log6 } from "@dxos/log";
|
|
1606
1613
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1607
1614
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1608
|
-
var MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
1615
|
+
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 10;
|
|
1609
1616
|
var ConnectionLimiter = class {
|
|
1610
1617
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
1611
1618
|
this._ctx = new Context5();
|
|
@@ -1718,6 +1725,7 @@ var ConnectionLog = class {
|
|
|
1718
1725
|
swarm.connectionAdded.on((connection) => {
|
|
1719
1726
|
const connectionInfo = {
|
|
1720
1727
|
state: ConnectionState.INITIAL,
|
|
1728
|
+
closeReason: connection.closeReason,
|
|
1721
1729
|
remotePeerId: connection.remoteId,
|
|
1722
1730
|
sessionId: connection.sessionId,
|
|
1723
1731
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
@@ -1728,6 +1736,7 @@ var ConnectionLog = class {
|
|
|
1728
1736
|
this.update.emit();
|
|
1729
1737
|
connection.stateChanged.on((state) => {
|
|
1730
1738
|
connectionInfo.state = state;
|
|
1739
|
+
connectionInfo.closeReason = connection.closeReason;
|
|
1731
1740
|
connectionInfo.events.push({
|
|
1732
1741
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
1733
1742
|
newState: state
|
|
@@ -2444,34 +2453,39 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-man
|
|
|
2444
2453
|
var WebRTCTransport = class {
|
|
2445
2454
|
constructor(params) {
|
|
2446
2455
|
this.params = params;
|
|
2456
|
+
this._instanceId = PublicKey10.random().toHex();
|
|
2447
2457
|
this._closed = false;
|
|
2448
2458
|
this.closed = new Event7();
|
|
2449
2459
|
this.connected = new Event7();
|
|
2450
2460
|
this.errors = new ErrorStream4();
|
|
2451
|
-
this._instanceId = PublicKey10.random().toHex();
|
|
2452
2461
|
log11.trace("dxos.mesh.webrtc-transport.constructor", trace4.begin({
|
|
2453
2462
|
id: this._instanceId
|
|
2454
2463
|
}), {
|
|
2455
2464
|
F: __dxlog_file12,
|
|
2456
|
-
L:
|
|
2465
|
+
L: 44,
|
|
2457
2466
|
S: this,
|
|
2458
2467
|
C: (f, a) => f(...a)
|
|
2459
2468
|
});
|
|
2460
2469
|
log11("created connection", params, {
|
|
2461
2470
|
F: __dxlog_file12,
|
|
2462
|
-
L:
|
|
2471
|
+
L: 45,
|
|
2463
2472
|
S: this,
|
|
2464
2473
|
C: (f, a) => f(...a)
|
|
2465
2474
|
});
|
|
2466
2475
|
this._peer = new SimplePeerConstructor({
|
|
2467
2476
|
initiator: this.params.initiator,
|
|
2468
|
-
|
|
2469
|
-
|
|
2477
|
+
config: this.params.webrtcConfig,
|
|
2478
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/createDataChannel
|
|
2479
|
+
channelConfig: {
|
|
2480
|
+
protocol: "dxos.mesh"
|
|
2481
|
+
},
|
|
2482
|
+
// Custom WebRTC implementation (for Node); otherwise get-browser-rtc.
|
|
2483
|
+
wrtc: SimplePeerConstructor.WEBRTC_SUPPORT ? void 0 : wrtc ?? raise2(new Error("wrtc not available"))
|
|
2470
2484
|
});
|
|
2471
2485
|
this._peer.on("signal", async (data) => {
|
|
2472
2486
|
log11("signal", data, {
|
|
2473
2487
|
F: __dxlog_file12,
|
|
2474
|
-
L:
|
|
2488
|
+
L: 62,
|
|
2475
2489
|
S: this,
|
|
2476
2490
|
C: (f, a) => f(...a)
|
|
2477
2491
|
});
|
|
@@ -2484,7 +2498,7 @@ var WebRTCTransport = class {
|
|
|
2484
2498
|
this._peer.on("connect", () => {
|
|
2485
2499
|
log11("connected", void 0, {
|
|
2486
2500
|
F: __dxlog_file12,
|
|
2487
|
-
L:
|
|
2501
|
+
L: 67,
|
|
2488
2502
|
S: this,
|
|
2489
2503
|
C: (f, a) => f(...a)
|
|
2490
2504
|
});
|
|
@@ -2494,7 +2508,7 @@ var WebRTCTransport = class {
|
|
|
2494
2508
|
this._peer.on("close", async () => {
|
|
2495
2509
|
log11("closed", void 0, {
|
|
2496
2510
|
F: __dxlog_file12,
|
|
2497
|
-
L:
|
|
2511
|
+
L: 73,
|
|
2498
2512
|
S: this,
|
|
2499
2513
|
C: (f, a) => f(...a)
|
|
2500
2514
|
});
|
|
@@ -2511,7 +2525,7 @@ var WebRTCTransport = class {
|
|
|
2511
2525
|
stats
|
|
2512
2526
|
}, {
|
|
2513
2527
|
F: __dxlog_file12,
|
|
2514
|
-
L:
|
|
2528
|
+
L: 85,
|
|
2515
2529
|
S: this,
|
|
2516
2530
|
C: (f, a) => f(...a)
|
|
2517
2531
|
});
|
|
@@ -2525,7 +2539,7 @@ var WebRTCTransport = class {
|
|
|
2525
2539
|
id: this._instanceId
|
|
2526
2540
|
}), {
|
|
2527
2541
|
F: __dxlog_file12,
|
|
2528
|
-
L:
|
|
2542
|
+
L: 95,
|
|
2529
2543
|
S: this,
|
|
2530
2544
|
C: (f, a) => f(...a)
|
|
2531
2545
|
});
|
|
@@ -2533,7 +2547,7 @@ var WebRTCTransport = class {
|
|
|
2533
2547
|
async destroy() {
|
|
2534
2548
|
log11("closing...", void 0, {
|
|
2535
2549
|
F: __dxlog_file12,
|
|
2536
|
-
L:
|
|
2550
|
+
L: 99,
|
|
2537
2551
|
S: this,
|
|
2538
2552
|
C: (f, a) => f(...a)
|
|
2539
2553
|
});
|
|
@@ -2543,7 +2557,7 @@ var WebRTCTransport = class {
|
|
|
2543
2557
|
this.closed.emit();
|
|
2544
2558
|
log11("closed", void 0, {
|
|
2545
2559
|
F: __dxlog_file12,
|
|
2546
|
-
L:
|
|
2560
|
+
L: 104,
|
|
2547
2561
|
S: this,
|
|
2548
2562
|
C: (f, a) => f(...a)
|
|
2549
2563
|
});
|
|
@@ -2554,7 +2568,7 @@ var WebRTCTransport = class {
|
|
|
2554
2568
|
}
|
|
2555
2569
|
invariant11(signal.payload.data, "Signal message must contain signal data.", {
|
|
2556
2570
|
F: __dxlog_file12,
|
|
2557
|
-
L:
|
|
2571
|
+
L: 112,
|
|
2558
2572
|
S: this,
|
|
2559
2573
|
A: [
|
|
2560
2574
|
"signal.payload.data",
|
|
@@ -2722,9 +2736,9 @@ var WebRTCTransportProxy = class {
|
|
|
2722
2736
|
this._proxyId = PublicKey12.random();
|
|
2723
2737
|
this._ctx = new Context6();
|
|
2724
2738
|
this.closed = new Event8();
|
|
2725
|
-
this._closed = false;
|
|
2726
2739
|
this.connected = new Event8();
|
|
2727
2740
|
this.errors = new ErrorStream5();
|
|
2741
|
+
this._closed = false;
|
|
2728
2742
|
this._serviceStream = this._params.bridgeService.open({
|
|
2729
2743
|
proxyId: this._proxyId,
|
|
2730
2744
|
initiator: this._params.initiator
|
|
@@ -2800,7 +2814,7 @@ var WebRTCTransportProxy = class {
|
|
|
2800
2814
|
if (this._closed) {
|
|
2801
2815
|
return;
|
|
2802
2816
|
}
|
|
2803
|
-
this._serviceStream.close();
|
|
2817
|
+
await this._serviceStream.close();
|
|
2804
2818
|
try {
|
|
2805
2819
|
await this._params.bridgeService.close({
|
|
2806
2820
|
proxyId: this._proxyId
|
|
@@ -2821,7 +2835,7 @@ var WebRTCTransportProxy = class {
|
|
|
2821
2835
|
*/
|
|
2822
2836
|
// TODO(burdon): Option on close method.
|
|
2823
2837
|
forceClose() {
|
|
2824
|
-
this._serviceStream.close();
|
|
2838
|
+
void this._serviceStream.close();
|
|
2825
2839
|
this.closed.emit();
|
|
2826
2840
|
this._closed = true;
|
|
2827
2841
|
}
|
|
@@ -2902,4 +2916,4 @@ export {
|
|
|
2902
2916
|
WebRTCTransportProxyFactory,
|
|
2903
2917
|
createTeleportProtocolFactory
|
|
2904
2918
|
};
|
|
2905
|
-
//# sourceMappingURL=chunk-
|
|
2919
|
+
//# sourceMappingURL=chunk-BVDMMHEG.mjs.map
|