@dxos/network-manager 0.3.9-main.3a0f16f → 0.3.9-main.4e30508
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-4HITD6WI.mjs → chunk-J7KS7JMZ.mjs} +325 -87
- package/dist/lib/browser/chunk-J7KS7JMZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-6AD7QA4X.cjs → chunk-55WTPQV5.cjs} +334 -86
- package/dist/lib/node/chunk-55WTPQV5.cjs.map +7 -0
- package/dist/lib/node/{chunk-XE5JOIGD.cjs → chunk-JDKM4UPJ.cjs} +21 -13
- package/dist/lib/node/chunk-JDKM4UPJ.cjs.map +7 -0
- package/dist/lib/node/{datachannel-53JZPGFA.cjs → datachannel-3VTTIMR5.cjs} +9 -9
- package/dist/lib/node/{datachannel-53JZPGFA.cjs.map → datachannel-3VTTIMR5.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +32 -32
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +19 -19
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +4 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/topology/mmst-topology.d.ts +1 -0
- package/dist/types/src/topology/mmst-topology.d.ts.map +1 -1
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts +7 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts +3 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts +3 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts +7 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.d.ts.map +1 -1
- package/dist/types/src/transport/transport.d.ts +17 -0
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +1 -1
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/connection-log.ts +14 -1
- package/src/swarm/connection.ts +23 -4
- package/src/topology/mmst-topology.ts +35 -7
- package/src/transport/datachannel/rtc-peer-connection.ts +20 -12
- package/src/transport/libdatachannel-transport.test.ts +0 -4
- package/src/transport/libdatachannel-transport.ts +37 -1
- package/src/transport/memory-transport.ts +14 -1
- package/src/transport/simplepeer-transport-proxy.ts +9 -1
- package/src/transport/simplepeer-transport-service.ts +14 -0
- package/src/transport/simplepeer-transport.ts +66 -2
- package/src/transport/tcp-transport.browser.ts +9 -1
- package/src/transport/tcp-transport.ts +19 -1
- package/src/transport/transport.ts +19 -0
- package/src/wire-protocol.ts +3 -3
- package/dist/lib/browser/chunk-4HITD6WI.mjs.map +0 -7
- package/dist/lib/node/chunk-6AD7QA4X.cjs.map +0 -7
- package/dist/lib/node/chunk-XE5JOIGD.cjs.map +0 -7
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
} from "./chunk-YERMWDRB.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
7
|
-
import { DeferredTask, Event, sleep, scheduleTask, synchronized } from "@dxos/async";
|
|
7
|
+
import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
8
8
|
import { Context, cancelWithContext } from "@dxos/context";
|
|
9
9
|
import { ErrorStream } from "@dxos/debug";
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
import { PublicKey } from "@dxos/keys";
|
|
12
|
-
import { log } from "@dxos/log";
|
|
12
|
+
import { log, logInfo } from "@dxos/log";
|
|
13
13
|
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, TimeoutError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
14
14
|
function _ts_decorate(decorators, target, key, desc) {
|
|
15
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -24,6 +24,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
24
24
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
25
25
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
26
26
|
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
27
|
+
var TRANSPORT_STATS_INTERVAL = 5e3;
|
|
27
28
|
var MAX_SIGNALLING_DELAY = 300;
|
|
28
29
|
var ConnectionState;
|
|
29
30
|
(function(ConnectionState5) {
|
|
@@ -86,6 +87,7 @@ var Connection = class {
|
|
|
86
87
|
this.stateChanged = new Event();
|
|
87
88
|
this.errors = new ErrorStream();
|
|
88
89
|
this._instanceId = PublicKey.random().toHex();
|
|
90
|
+
this.transportStats = new Event();
|
|
89
91
|
this._signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
90
92
|
await this._flushSignalBuffer();
|
|
91
93
|
});
|
|
@@ -98,11 +100,14 @@ var Connection = class {
|
|
|
98
100
|
initiator: this.initiator
|
|
99
101
|
}, {
|
|
100
102
|
F: __dxlog_file,
|
|
101
|
-
L:
|
|
103
|
+
L: 134,
|
|
102
104
|
S: this,
|
|
103
105
|
C: (f, a) => f(...a)
|
|
104
106
|
});
|
|
105
107
|
}
|
|
108
|
+
get sessionIdString() {
|
|
109
|
+
return this.sessionId.truncate();
|
|
110
|
+
}
|
|
106
111
|
get state() {
|
|
107
112
|
return this._state;
|
|
108
113
|
}
|
|
@@ -118,7 +123,7 @@ var Connection = class {
|
|
|
118
123
|
async openConnection() {
|
|
119
124
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
120
125
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
126
|
+
L: 164,
|
|
122
127
|
S: this,
|
|
123
128
|
A: [
|
|
124
129
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -129,7 +134,7 @@ var Connection = class {
|
|
|
129
134
|
id: this._instanceId
|
|
130
135
|
}), {
|
|
131
136
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
137
|
+
L: 165,
|
|
133
138
|
S: this,
|
|
134
139
|
C: (f, a) => f(...a)
|
|
135
140
|
});
|
|
@@ -141,18 +146,18 @@ var Connection = class {
|
|
|
141
146
|
initiator: this.initiator
|
|
142
147
|
}, {
|
|
143
148
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
149
|
+
L: 166,
|
|
145
150
|
S: this,
|
|
146
151
|
C: (f, a) => f(...a)
|
|
147
152
|
});
|
|
148
153
|
this._changeState(ConnectionState.CONNECTING);
|
|
149
|
-
this._protocol.open().catch((err) => {
|
|
154
|
+
this._protocol.open(this.sessionId).catch((err) => {
|
|
150
155
|
this.errors.raise(err);
|
|
151
156
|
});
|
|
152
157
|
this._protocol.stream.on("close", () => {
|
|
153
158
|
log("protocol stream closed", void 0, {
|
|
154
159
|
F: __dxlog_file,
|
|
155
|
-
L:
|
|
160
|
+
L: 183,
|
|
156
161
|
S: this,
|
|
157
162
|
C: (f, a) => f(...a)
|
|
158
163
|
});
|
|
@@ -161,7 +166,7 @@ var Connection = class {
|
|
|
161
166
|
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
162
167
|
log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
163
168
|
F: __dxlog_file,
|
|
164
|
-
L:
|
|
169
|
+
L: 190,
|
|
165
170
|
S: this,
|
|
166
171
|
C: (f, a) => f(...a)
|
|
167
172
|
});
|
|
@@ -169,7 +174,7 @@ var Connection = class {
|
|
|
169
174
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
170
175
|
invariant(!this._transport, void 0, {
|
|
171
176
|
F: __dxlog_file,
|
|
172
|
-
L:
|
|
177
|
+
L: 198,
|
|
173
178
|
S: this,
|
|
174
179
|
A: [
|
|
175
180
|
"!this._transport",
|
|
@@ -179,18 +184,20 @@ var Connection = class {
|
|
|
179
184
|
this._transport = this._transportFactory.createTransport({
|
|
180
185
|
initiator: this.initiator,
|
|
181
186
|
stream: this._protocol.stream,
|
|
182
|
-
sendSignal: async (signal) => this._sendSignal(signal)
|
|
187
|
+
sendSignal: async (signal) => this._sendSignal(signal),
|
|
188
|
+
sessionId: this.sessionId
|
|
183
189
|
});
|
|
184
190
|
this._transport.connected.once(async () => {
|
|
185
191
|
this._changeState(ConnectionState.CONNECTED);
|
|
186
192
|
await this.connectedTimeoutContext.dispose();
|
|
187
193
|
this._callbacks?.onConnected?.();
|
|
194
|
+
scheduleTaskInterval(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
|
|
188
195
|
});
|
|
189
196
|
this._transport.closed.once(() => {
|
|
190
197
|
this._transport = void 0;
|
|
191
198
|
log("abort triggered by transport close", void 0, {
|
|
192
199
|
F: __dxlog_file,
|
|
193
|
-
L:
|
|
200
|
+
L: 216,
|
|
194
201
|
S: this,
|
|
195
202
|
C: (f, a) => f(...a)
|
|
196
203
|
});
|
|
@@ -201,7 +208,7 @@ var Connection = class {
|
|
|
201
208
|
err
|
|
202
209
|
}, {
|
|
203
210
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
211
|
+
L: 221,
|
|
205
212
|
S: this,
|
|
206
213
|
C: (f, a) => f(...a)
|
|
207
214
|
});
|
|
@@ -211,7 +218,7 @@ var Connection = class {
|
|
|
211
218
|
if (err instanceof ConnectionResetError) {
|
|
212
219
|
log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
213
220
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
221
|
+
L: 228,
|
|
215
222
|
S: this,
|
|
216
223
|
C: (f, a) => f(...a)
|
|
217
224
|
});
|
|
@@ -219,7 +226,7 @@ var Connection = class {
|
|
|
219
226
|
} else if (err instanceof ConnectivityError) {
|
|
220
227
|
log.info("aborting due to transport ConnectivityError", void 0, {
|
|
221
228
|
F: __dxlog_file,
|
|
222
|
-
L:
|
|
229
|
+
L: 231,
|
|
223
230
|
S: this,
|
|
224
231
|
C: (f, a) => f(...a)
|
|
225
232
|
});
|
|
@@ -229,7 +236,7 @@ var Connection = class {
|
|
|
229
236
|
err
|
|
230
237
|
}, {
|
|
231
238
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
239
|
+
L: 234,
|
|
233
240
|
S: this,
|
|
234
241
|
C: (f, a) => f(...a)
|
|
235
242
|
});
|
|
@@ -247,7 +254,7 @@ var Connection = class {
|
|
|
247
254
|
id: this._instanceId
|
|
248
255
|
}), {
|
|
249
256
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
257
|
+
L: 250,
|
|
251
258
|
S: this,
|
|
252
259
|
C: (f, a) => f(...a)
|
|
253
260
|
});
|
|
@@ -257,14 +264,14 @@ var Connection = class {
|
|
|
257
264
|
err
|
|
258
265
|
}, {
|
|
259
266
|
F: __dxlog_file,
|
|
260
|
-
L:
|
|
267
|
+
L: 257,
|
|
261
268
|
S: this,
|
|
262
269
|
C: (f, a) => f(...a)
|
|
263
270
|
});
|
|
264
271
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
265
272
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
266
273
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
274
|
+
L: 259,
|
|
268
275
|
S: this,
|
|
269
276
|
C: (f, a) => f(...a)
|
|
270
277
|
});
|
|
@@ -279,7 +286,7 @@ var Connection = class {
|
|
|
279
286
|
try {
|
|
280
287
|
log("aborting protocol... ", void 0, {
|
|
281
288
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
289
|
+
L: 273,
|
|
283
290
|
S: this,
|
|
284
291
|
C: (f, a) => f(...a)
|
|
285
292
|
});
|
|
@@ -287,7 +294,7 @@ var Connection = class {
|
|
|
287
294
|
} catch (err2) {
|
|
288
295
|
log.catch(err2, void 0, {
|
|
289
296
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
297
|
+
L: 276,
|
|
291
298
|
S: this,
|
|
292
299
|
C: (f, a) => f(...a)
|
|
293
300
|
});
|
|
@@ -297,7 +304,7 @@ var Connection = class {
|
|
|
297
304
|
} catch (err2) {
|
|
298
305
|
log.catch(err2, void 0, {
|
|
299
306
|
F: __dxlog_file,
|
|
300
|
-
L:
|
|
307
|
+
L: 283,
|
|
301
308
|
S: this,
|
|
302
309
|
C: (f, a) => f(...a)
|
|
303
310
|
});
|
|
@@ -307,7 +314,7 @@ var Connection = class {
|
|
|
307
314
|
} catch (err2) {
|
|
308
315
|
log.catch(err2, void 0, {
|
|
309
316
|
F: __dxlog_file,
|
|
310
|
-
L:
|
|
317
|
+
L: 289,
|
|
311
318
|
S: this,
|
|
312
319
|
C: (f, a) => f(...a)
|
|
313
320
|
});
|
|
@@ -331,7 +338,7 @@ var Connection = class {
|
|
|
331
338
|
peerId: this.ownId
|
|
332
339
|
}, {
|
|
333
340
|
F: __dxlog_file,
|
|
334
|
-
L:
|
|
341
|
+
L: 314,
|
|
335
342
|
S: this,
|
|
336
343
|
C: (f, a) => f(...a)
|
|
337
344
|
});
|
|
@@ -341,7 +348,7 @@ var Connection = class {
|
|
|
341
348
|
} catch (err2) {
|
|
342
349
|
log.catch(err2, void 0, {
|
|
343
350
|
F: __dxlog_file,
|
|
344
|
-
L:
|
|
351
|
+
L: 321,
|
|
345
352
|
S: this,
|
|
346
353
|
C: (f, a) => f(...a)
|
|
347
354
|
});
|
|
@@ -351,7 +358,7 @@ var Connection = class {
|
|
|
351
358
|
} catch (err2) {
|
|
352
359
|
log.catch(err2, void 0, {
|
|
353
360
|
F: __dxlog_file,
|
|
354
|
-
L:
|
|
361
|
+
L: 328,
|
|
355
362
|
S: this,
|
|
356
363
|
C: (f, a) => f(...a)
|
|
357
364
|
});
|
|
@@ -359,7 +366,7 @@ var Connection = class {
|
|
|
359
366
|
} else {
|
|
360
367
|
log.info(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
361
368
|
F: __dxlog_file,
|
|
362
|
-
L:
|
|
369
|
+
L: 331,
|
|
363
370
|
S: this,
|
|
364
371
|
C: (f, a) => f(...a)
|
|
365
372
|
});
|
|
@@ -368,7 +375,7 @@ var Connection = class {
|
|
|
368
375
|
} catch (err2) {
|
|
369
376
|
log.catch(err2, void 0, {
|
|
370
377
|
F: __dxlog_file,
|
|
371
|
-
L:
|
|
378
|
+
L: 335,
|
|
372
379
|
S: this,
|
|
373
380
|
C: (f, a) => f(...a)
|
|
374
381
|
});
|
|
@@ -378,7 +385,7 @@ var Connection = class {
|
|
|
378
385
|
} catch (err2) {
|
|
379
386
|
log.catch(err2, void 0, {
|
|
380
387
|
F: __dxlog_file,
|
|
381
|
-
L:
|
|
388
|
+
L: 340,
|
|
382
389
|
S: this,
|
|
383
390
|
C: (f, a) => f(...a)
|
|
384
391
|
});
|
|
@@ -388,7 +395,7 @@ var Connection = class {
|
|
|
388
395
|
peerId: this.ownId
|
|
389
396
|
}, {
|
|
390
397
|
F: __dxlog_file,
|
|
391
|
-
L:
|
|
398
|
+
L: 344,
|
|
392
399
|
S: this,
|
|
393
400
|
C: (f, a) => f(...a)
|
|
394
401
|
});
|
|
@@ -431,7 +438,7 @@ var Connection = class {
|
|
|
431
438
|
err
|
|
432
439
|
}, {
|
|
433
440
|
F: __dxlog_file,
|
|
434
|
-
L:
|
|
441
|
+
L: 382,
|
|
435
442
|
S: this,
|
|
436
443
|
C: (f, a) => f(...a)
|
|
437
444
|
});
|
|
@@ -444,7 +451,7 @@ var Connection = class {
|
|
|
444
451
|
async signal(msg) {
|
|
445
452
|
invariant(msg.sessionId, void 0, {
|
|
446
453
|
F: __dxlog_file,
|
|
447
|
-
L:
|
|
454
|
+
L: 391,
|
|
448
455
|
S: this,
|
|
449
456
|
A: [
|
|
450
457
|
"msg.sessionId",
|
|
@@ -454,7 +461,7 @@ var Connection = class {
|
|
|
454
461
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
455
462
|
log("dropping signal for incorrect session id", void 0, {
|
|
456
463
|
F: __dxlog_file,
|
|
457
|
-
L:
|
|
464
|
+
L: 393,
|
|
458
465
|
S: this,
|
|
459
466
|
C: (f, a) => f(...a)
|
|
460
467
|
});
|
|
@@ -462,7 +469,7 @@ var Connection = class {
|
|
|
462
469
|
}
|
|
463
470
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
464
471
|
F: __dxlog_file,
|
|
465
|
-
L:
|
|
472
|
+
L: 396,
|
|
466
473
|
S: this,
|
|
467
474
|
A: [
|
|
468
475
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -471,7 +478,7 @@ var Connection = class {
|
|
|
471
478
|
});
|
|
472
479
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
473
480
|
F: __dxlog_file,
|
|
474
|
-
L:
|
|
481
|
+
L: 397,
|
|
475
482
|
S: this,
|
|
476
483
|
A: [
|
|
477
484
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -480,7 +487,7 @@ var Connection = class {
|
|
|
480
487
|
});
|
|
481
488
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
482
489
|
F: __dxlog_file,
|
|
483
|
-
L:
|
|
490
|
+
L: 398,
|
|
484
491
|
S: this,
|
|
485
492
|
A: [
|
|
486
493
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -504,7 +511,7 @@ var Connection = class {
|
|
|
504
511
|
msg: msg.data
|
|
505
512
|
}, {
|
|
506
513
|
F: __dxlog_file,
|
|
507
|
-
L:
|
|
514
|
+
L: 407,
|
|
508
515
|
S: this,
|
|
509
516
|
C: (f, a) => f(...a)
|
|
510
517
|
});
|
|
@@ -512,7 +519,7 @@ var Connection = class {
|
|
|
512
519
|
} else {
|
|
513
520
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
514
521
|
F: __dxlog_file,
|
|
515
|
-
L:
|
|
522
|
+
L: 410,
|
|
516
523
|
S: this,
|
|
517
524
|
A: [
|
|
518
525
|
"this._transport",
|
|
@@ -525,7 +532,7 @@ var Connection = class {
|
|
|
525
532
|
msg: msg.data
|
|
526
533
|
}, {
|
|
527
534
|
F: __dxlog_file,
|
|
528
|
-
L:
|
|
535
|
+
L: 411,
|
|
529
536
|
S: this,
|
|
530
537
|
C: (f, a) => f(...a)
|
|
531
538
|
});
|
|
@@ -543,13 +550,13 @@ var Connection = class {
|
|
|
543
550
|
peerId: this.ownId
|
|
544
551
|
}, {
|
|
545
552
|
F: __dxlog_file,
|
|
546
|
-
L:
|
|
553
|
+
L: 422,
|
|
547
554
|
S: this,
|
|
548
555
|
C: (f, a) => f(...a)
|
|
549
556
|
});
|
|
550
557
|
invariant(state !== this._state, "Already in this state.", {
|
|
551
558
|
F: __dxlog_file,
|
|
552
|
-
L:
|
|
559
|
+
L: 423,
|
|
553
560
|
S: this,
|
|
554
561
|
A: [
|
|
555
562
|
"state !== this._state",
|
|
@@ -559,7 +566,16 @@ var Connection = class {
|
|
|
559
566
|
this._state = state;
|
|
560
567
|
this.stateChanged.emit(state);
|
|
561
568
|
}
|
|
569
|
+
async _emitTransportStats() {
|
|
570
|
+
const stats = await this.transport?.getStats();
|
|
571
|
+
if (stats) {
|
|
572
|
+
this.transportStats.emit(stats);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
562
575
|
};
|
|
576
|
+
_ts_decorate([
|
|
577
|
+
logInfo
|
|
578
|
+
], Connection.prototype, "sessionIdString", null);
|
|
563
579
|
_ts_decorate([
|
|
564
580
|
synchronized
|
|
565
581
|
], Connection.prototype, "abort", null);
|
|
@@ -816,7 +832,7 @@ import { Context as Context4 } from "@dxos/context";
|
|
|
816
832
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
817
833
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
818
834
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
819
|
-
import { log as log4, logInfo } from "@dxos/log";
|
|
835
|
+
import { log as log4, logInfo as logInfo2 } from "@dxos/log";
|
|
820
836
|
import { trace as trace2 } from "@dxos/protocols";
|
|
821
837
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
822
838
|
|
|
@@ -1780,13 +1796,13 @@ var Swarm = class {
|
|
|
1780
1796
|
}
|
|
1781
1797
|
};
|
|
1782
1798
|
_ts_decorate3([
|
|
1783
|
-
|
|
1799
|
+
logInfo2
|
|
1784
1800
|
], Swarm.prototype, "_instanceId", void 0);
|
|
1785
1801
|
_ts_decorate3([
|
|
1786
|
-
|
|
1802
|
+
logInfo2
|
|
1787
1803
|
], Swarm.prototype, "ownPeerId", null);
|
|
1788
1804
|
_ts_decorate3([
|
|
1789
|
-
|
|
1805
|
+
logInfo2
|
|
1790
1806
|
], Swarm.prototype, "topic", null);
|
|
1791
1807
|
_ts_decorate3([
|
|
1792
1808
|
synchronized3
|
|
@@ -2003,7 +2019,7 @@ var ConnectionLog = class {
|
|
|
2003
2019
|
};
|
|
2004
2020
|
info.connections.push(connectionInfo);
|
|
2005
2021
|
this.update.emit();
|
|
2006
|
-
connection.stateChanged.on((state) => {
|
|
2022
|
+
connection.stateChanged.on(async (state) => {
|
|
2007
2023
|
connectionInfo.state = state;
|
|
2008
2024
|
connectionInfo.closeReason = connection.closeReason;
|
|
2009
2025
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
@@ -2011,6 +2027,10 @@ var ConnectionLog = class {
|
|
|
2011
2027
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
2012
2028
|
newState: state
|
|
2013
2029
|
});
|
|
2030
|
+
if (state === ConnectionState.CONNECTED) {
|
|
2031
|
+
const details = await connection.transport?.getDetails();
|
|
2032
|
+
connectionInfo.transportDetails = details;
|
|
2033
|
+
}
|
|
2014
2034
|
this.update.emit();
|
|
2015
2035
|
});
|
|
2016
2036
|
connection.protocol?.stats?.on((stats) => {
|
|
@@ -2020,6 +2040,12 @@ var ConnectionLog = class {
|
|
|
2020
2040
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
2021
2041
|
this.update.emit();
|
|
2022
2042
|
});
|
|
2043
|
+
connection.transportStats?.on((stats) => {
|
|
2044
|
+
connectionInfo.transportBytesSent = stats.bytesSent;
|
|
2045
|
+
connectionInfo.transportBytesReceived = stats.bytesReceived;
|
|
2046
|
+
connectionInfo.transportPacketsSent = stats.packetsSent;
|
|
2047
|
+
connectionInfo.transportPacketsReceived = stats.packetsReceived;
|
|
2048
|
+
});
|
|
2023
2049
|
gcSwarm(info);
|
|
2024
2050
|
});
|
|
2025
2051
|
}
|
|
@@ -2323,9 +2349,12 @@ import distance from "xor-distance";
|
|
|
2323
2349
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2324
2350
|
import { log as log8 } from "@dxos/log";
|
|
2325
2351
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2352
|
+
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2353
|
+
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2326
2354
|
var MMSTTopology = class {
|
|
2327
2355
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2328
2356
|
this._sampleCollected = false;
|
|
2357
|
+
this._lastAction = /* @__PURE__ */ new Date(0);
|
|
2329
2358
|
this._originateConnections = originateConnections;
|
|
2330
2359
|
this._maxPeers = maxPeers;
|
|
2331
2360
|
this._sampleSize = sampleSize;
|
|
@@ -2333,7 +2362,7 @@ var MMSTTopology = class {
|
|
|
2333
2362
|
init(controller) {
|
|
2334
2363
|
invariant8(!this._controller, "Already initialized", {
|
|
2335
2364
|
F: __dxlog_file9,
|
|
2336
|
-
L:
|
|
2365
|
+
L: 51,
|
|
2337
2366
|
S: this,
|
|
2338
2367
|
A: [
|
|
2339
2368
|
"!this._controller",
|
|
@@ -2345,7 +2374,7 @@ var MMSTTopology = class {
|
|
|
2345
2374
|
update() {
|
|
2346
2375
|
invariant8(this._controller, "Not initialized", {
|
|
2347
2376
|
F: __dxlog_file9,
|
|
2348
|
-
L:
|
|
2377
|
+
L: 56,
|
|
2349
2378
|
S: this,
|
|
2350
2379
|
A: [
|
|
2351
2380
|
"this._controller",
|
|
@@ -2354,9 +2383,9 @@ var MMSTTopology = class {
|
|
|
2354
2383
|
});
|
|
2355
2384
|
const { connected, candidates } = this._controller.getState();
|
|
2356
2385
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
2357
|
-
log8("Running the algorithm.", void 0, {
|
|
2386
|
+
log8.info("Running the algorithm.", void 0, {
|
|
2358
2387
|
F: __dxlog_file9,
|
|
2359
|
-
L:
|
|
2388
|
+
L: 60,
|
|
2360
2389
|
S: this,
|
|
2361
2390
|
C: (f, a) => f(...a)
|
|
2362
2391
|
});
|
|
@@ -2367,7 +2396,7 @@ var MMSTTopology = class {
|
|
|
2367
2396
|
async onOffer(peer) {
|
|
2368
2397
|
invariant8(this._controller, "Not initialized", {
|
|
2369
2398
|
F: __dxlog_file9,
|
|
2370
|
-
L:
|
|
2399
|
+
L: 67,
|
|
2371
2400
|
S: this,
|
|
2372
2401
|
A: [
|
|
2373
2402
|
"this._controller",
|
|
@@ -2378,7 +2407,7 @@ var MMSTTopology = class {
|
|
|
2378
2407
|
const accept = connected.length < this._maxPeers;
|
|
2379
2408
|
log8(`Offer ${peer} accept=${accept}`, void 0, {
|
|
2380
2409
|
F: __dxlog_file9,
|
|
2381
|
-
L:
|
|
2410
|
+
L: 70,
|
|
2382
2411
|
S: this,
|
|
2383
2412
|
C: (f, a) => f(...a)
|
|
2384
2413
|
});
|
|
@@ -2389,7 +2418,7 @@ var MMSTTopology = class {
|
|
|
2389
2418
|
_runAlgorithm() {
|
|
2390
2419
|
invariant8(this._controller, "Not initialized", {
|
|
2391
2420
|
F: __dxlog_file9,
|
|
2392
|
-
L:
|
|
2421
|
+
L: 79,
|
|
2393
2422
|
S: this,
|
|
2394
2423
|
A: [
|
|
2395
2424
|
"this._controller",
|
|
@@ -2398,27 +2427,84 @@ var MMSTTopology = class {
|
|
|
2398
2427
|
});
|
|
2399
2428
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
2400
2429
|
if (connected.length > this._maxPeers) {
|
|
2430
|
+
log8.info(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
|
|
2431
|
+
F: __dxlog_file9,
|
|
2432
|
+
L: 85,
|
|
2433
|
+
S: this,
|
|
2434
|
+
C: (f, a) => f(...a)
|
|
2435
|
+
});
|
|
2401
2436
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
2402
|
-
|
|
2403
|
-
|
|
2437
|
+
invariant8(sorted.length === 0, void 0, {
|
|
2438
|
+
F: __dxlog_file9,
|
|
2439
|
+
L: 89,
|
|
2440
|
+
S: this,
|
|
2441
|
+
A: [
|
|
2442
|
+
"sorted.length === 0",
|
|
2443
|
+
""
|
|
2444
|
+
]
|
|
2445
|
+
});
|
|
2446
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2447
|
+
log8(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2404
2448
|
F: __dxlog_file9,
|
|
2405
|
-
L:
|
|
2449
|
+
L: 92,
|
|
2450
|
+
S: this,
|
|
2451
|
+
C: (f, a) => f(...a)
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2455
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2456
|
+
log8.info(`Disconnect ${peer}.`, void 0, {
|
|
2457
|
+
F: __dxlog_file9,
|
|
2458
|
+
L: 97,
|
|
2459
|
+
S: this,
|
|
2460
|
+
C: (f, a) => f(...a)
|
|
2461
|
+
});
|
|
2462
|
+
this._controller.disconnect(peer);
|
|
2463
|
+
}
|
|
2464
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2465
|
+
} else {
|
|
2466
|
+
log8.info("rate limited discconnect", void 0, {
|
|
2467
|
+
F: __dxlog_file9,
|
|
2468
|
+
L: 102,
|
|
2406
2469
|
S: this,
|
|
2407
2470
|
C: (f, a) => f(...a)
|
|
2408
2471
|
});
|
|
2409
|
-
this._controller.disconnect(peer);
|
|
2410
2472
|
}
|
|
2411
2473
|
} else if (connected.length < this._originateConnections) {
|
|
2474
|
+
log8.info(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
|
|
2475
|
+
F: __dxlog_file9,
|
|
2476
|
+
L: 106,
|
|
2477
|
+
S: this,
|
|
2478
|
+
C: (f, a) => f(...a)
|
|
2479
|
+
});
|
|
2412
2480
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
2413
2481
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
2414
|
-
|
|
2415
|
-
log8(`
|
|
2482
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2483
|
+
log8(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2416
2484
|
F: __dxlog_file9,
|
|
2417
|
-
L:
|
|
2485
|
+
L: 111,
|
|
2486
|
+
S: this,
|
|
2487
|
+
C: (f, a) => f(...a)
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2491
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2492
|
+
log8.info(`Connect ${peer}.`, void 0, {
|
|
2493
|
+
F: __dxlog_file9,
|
|
2494
|
+
L: 115,
|
|
2495
|
+
S: this,
|
|
2496
|
+
C: (f, a) => f(...a)
|
|
2497
|
+
});
|
|
2498
|
+
this._controller.connect(peer);
|
|
2499
|
+
}
|
|
2500
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2501
|
+
} else {
|
|
2502
|
+
log8.info("rate limited connect", void 0, {
|
|
2503
|
+
F: __dxlog_file9,
|
|
2504
|
+
L: 120,
|
|
2418
2505
|
S: this,
|
|
2419
2506
|
C: (f, a) => f(...a)
|
|
2420
2507
|
});
|
|
2421
|
-
this._controller.connect(peer);
|
|
2422
2508
|
}
|
|
2423
2509
|
}
|
|
2424
2510
|
}
|
|
@@ -2530,7 +2616,7 @@ import { Event as Event7, Trigger } from "@dxos/async";
|
|
|
2530
2616
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
2531
2617
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2532
2618
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2533
|
-
import { log as log10, logInfo as
|
|
2619
|
+
import { log as log10, logInfo as logInfo3 } from "@dxos/log";
|
|
2534
2620
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
2535
2621
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2536
2622
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2705,12 +2791,23 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2705
2791
|
this._remote.wake(remoteId);
|
|
2706
2792
|
}
|
|
2707
2793
|
}
|
|
2794
|
+
async getDetails() {
|
|
2795
|
+
return this._instanceId.toHex();
|
|
2796
|
+
}
|
|
2797
|
+
async getStats() {
|
|
2798
|
+
return {
|
|
2799
|
+
bytesSent: 0,
|
|
2800
|
+
bytesReceived: 0,
|
|
2801
|
+
packetsSent: 0,
|
|
2802
|
+
packetsReceived: 0
|
|
2803
|
+
};
|
|
2804
|
+
}
|
|
2708
2805
|
};
|
|
2709
2806
|
_ts_decorate4([
|
|
2710
|
-
|
|
2807
|
+
logInfo3
|
|
2711
2808
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
2712
2809
|
_ts_decorate4([
|
|
2713
|
-
|
|
2810
|
+
logInfo3
|
|
2714
2811
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2715
2812
|
|
|
2716
2813
|
// packages/core/mesh/network-manager/src/transport/transport.ts
|
|
@@ -2742,6 +2839,9 @@ try {
|
|
|
2742
2839
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2743
2840
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2744
2841
|
var SimplePeerTransport = class {
|
|
2842
|
+
/**
|
|
2843
|
+
* @params opts.config formatted as per https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
|
|
2844
|
+
*/
|
|
2745
2845
|
constructor(params) {
|
|
2746
2846
|
this.params = params;
|
|
2747
2847
|
this._closed = false;
|
|
@@ -2754,13 +2854,13 @@ var SimplePeerTransport = class {
|
|
|
2754
2854
|
id: this._instanceId
|
|
2755
2855
|
}), {
|
|
2756
2856
|
F: __dxlog_file12,
|
|
2757
|
-
L:
|
|
2857
|
+
L: 44,
|
|
2758
2858
|
S: this,
|
|
2759
2859
|
C: (f, a) => f(...a)
|
|
2760
2860
|
});
|
|
2761
2861
|
log11("created connection", params, {
|
|
2762
2862
|
F: __dxlog_file12,
|
|
2763
|
-
L:
|
|
2863
|
+
L: 45,
|
|
2764
2864
|
S: this,
|
|
2765
2865
|
C: (f, a) => f(...a)
|
|
2766
2866
|
});
|
|
@@ -2773,7 +2873,7 @@ var SimplePeerTransport = class {
|
|
|
2773
2873
|
this._peer.on("signal", async (data) => {
|
|
2774
2874
|
log11("signal", data, {
|
|
2775
2875
|
F: __dxlog_file12,
|
|
2776
|
-
L:
|
|
2876
|
+
L: 54,
|
|
2777
2877
|
S: this,
|
|
2778
2878
|
C: (f, a) => f(...a)
|
|
2779
2879
|
});
|
|
@@ -2786,7 +2886,7 @@ var SimplePeerTransport = class {
|
|
|
2786
2886
|
this._peer.on("connect", () => {
|
|
2787
2887
|
log11("connected", void 0, {
|
|
2788
2888
|
F: __dxlog_file12,
|
|
2789
|
-
L:
|
|
2889
|
+
L: 59,
|
|
2790
2890
|
S: this,
|
|
2791
2891
|
C: (f, a) => f(...a)
|
|
2792
2892
|
});
|
|
@@ -2797,7 +2897,7 @@ var SimplePeerTransport = class {
|
|
|
2797
2897
|
this._peer.on("close", async () => {
|
|
2798
2898
|
log11("closed", void 0, {
|
|
2799
2899
|
F: __dxlog_file12,
|
|
2800
|
-
L:
|
|
2900
|
+
L: 66,
|
|
2801
2901
|
S: this,
|
|
2802
2902
|
C: (f, a) => f(...a)
|
|
2803
2903
|
});
|
|
@@ -2812,7 +2912,7 @@ var SimplePeerTransport = class {
|
|
|
2812
2912
|
err
|
|
2813
2913
|
}, {
|
|
2814
2914
|
F: __dxlog_file12,
|
|
2815
|
-
L:
|
|
2915
|
+
L: 77,
|
|
2816
2916
|
S: this,
|
|
2817
2917
|
C: (f, a) => f(...a)
|
|
2818
2918
|
});
|
|
@@ -2821,7 +2921,7 @@ var SimplePeerTransport = class {
|
|
|
2821
2921
|
} else if ("code" in err) {
|
|
2822
2922
|
log11.info("simple-peer error", err, {
|
|
2823
2923
|
F: __dxlog_file12,
|
|
2824
|
-
L:
|
|
2924
|
+
L: 82,
|
|
2825
2925
|
S: this,
|
|
2826
2926
|
C: (f, a) => f(...a)
|
|
2827
2927
|
});
|
|
@@ -2851,7 +2951,7 @@ var SimplePeerTransport = class {
|
|
|
2851
2951
|
} else {
|
|
2852
2952
|
log11.info("unknown peer connection error", err, {
|
|
2853
2953
|
F: __dxlog_file12,
|
|
2854
|
-
L:
|
|
2954
|
+
L: 108,
|
|
2855
2955
|
S: this,
|
|
2856
2956
|
C: (f, a) => f(...a)
|
|
2857
2957
|
});
|
|
@@ -2862,10 +2962,10 @@ var SimplePeerTransport = class {
|
|
|
2862
2962
|
this._peer._pc.getStats().then((stats) => {
|
|
2863
2963
|
log11.info("report after webrtc error", {
|
|
2864
2964
|
config: this.params.webrtcConfig,
|
|
2865
|
-
stats
|
|
2965
|
+
stats: Object.fromEntries(stats.entries())
|
|
2866
2966
|
}, {
|
|
2867
2967
|
F: __dxlog_file12,
|
|
2868
|
-
L:
|
|
2968
|
+
L: 116,
|
|
2869
2969
|
S: this,
|
|
2870
2970
|
C: (f, a) => f(...a)
|
|
2871
2971
|
});
|
|
@@ -2874,7 +2974,7 @@ var SimplePeerTransport = class {
|
|
|
2874
2974
|
} catch (err2) {
|
|
2875
2975
|
log11.catch(err2, void 0, {
|
|
2876
2976
|
F: __dxlog_file12,
|
|
2877
|
-
L:
|
|
2977
|
+
L: 123,
|
|
2878
2978
|
S: this,
|
|
2879
2979
|
C: (f, a) => f(...a)
|
|
2880
2980
|
});
|
|
@@ -2885,15 +2985,68 @@ var SimplePeerTransport = class {
|
|
|
2885
2985
|
id: this._instanceId
|
|
2886
2986
|
}), {
|
|
2887
2987
|
F: __dxlog_file12,
|
|
2888
|
-
L:
|
|
2988
|
+
L: 129,
|
|
2889
2989
|
S: this,
|
|
2890
2990
|
C: (f, a) => f(...a)
|
|
2891
2991
|
});
|
|
2892
2992
|
}
|
|
2993
|
+
async getStats() {
|
|
2994
|
+
const stats = await this._getStats();
|
|
2995
|
+
if (!stats) {
|
|
2996
|
+
return {
|
|
2997
|
+
bytesSent: 0,
|
|
2998
|
+
bytesReceived: 0,
|
|
2999
|
+
packetsSent: 0,
|
|
3000
|
+
packetsReceived: 0,
|
|
3001
|
+
rawStats: {}
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
return {
|
|
3005
|
+
bytesSent: stats.transport.bytesSent,
|
|
3006
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
3007
|
+
packetsSent: stats.transport.messagesSent,
|
|
3008
|
+
packetsReceived: stats.transport.messagesReceived,
|
|
3009
|
+
rawStats: stats.raw
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
async _getStats() {
|
|
3013
|
+
if (typeof this._peer?._pc?.getStats !== "function") {
|
|
3014
|
+
return null;
|
|
3015
|
+
}
|
|
3016
|
+
return await this._peer._pc.getStats().then((stats) => {
|
|
3017
|
+
const statsEntries = Array.from(stats.entries());
|
|
3018
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
3019
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
3020
|
+
let selectedCandidatePair;
|
|
3021
|
+
let remoteCandidate;
|
|
3022
|
+
if (candidatePair.length > 0) {
|
|
3023
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
3024
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
3025
|
+
}
|
|
3026
|
+
return {
|
|
3027
|
+
datachannel: statsEntries.filter((s) => s[1].type === "data-channel")[0][1],
|
|
3028
|
+
transport,
|
|
3029
|
+
selectedCandidatePair,
|
|
3030
|
+
remoteCandidate,
|
|
3031
|
+
raw: Object.fromEntries(stats.entries())
|
|
3032
|
+
};
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
async getDetails() {
|
|
3036
|
+
const stats = await this._getStats();
|
|
3037
|
+
const rc = stats?.remoteCandidate;
|
|
3038
|
+
if (!rc) {
|
|
3039
|
+
return "unavailable";
|
|
3040
|
+
}
|
|
3041
|
+
if (rc.relay) {
|
|
3042
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for XXX ${rc.candidateType}`;
|
|
3043
|
+
}
|
|
3044
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
3045
|
+
}
|
|
2893
3046
|
async destroy() {
|
|
2894
3047
|
log11("closing...", void 0, {
|
|
2895
3048
|
F: __dxlog_file12,
|
|
2896
|
-
L:
|
|
3049
|
+
L: 192,
|
|
2897
3050
|
S: this,
|
|
2898
3051
|
C: (f, a) => f(...a)
|
|
2899
3052
|
});
|
|
@@ -2903,10 +3056,11 @@ var SimplePeerTransport = class {
|
|
|
2903
3056
|
this._closed = true;
|
|
2904
3057
|
this._disconnectStreams();
|
|
2905
3058
|
this._peer.destroy();
|
|
3059
|
+
this._closed = true;
|
|
2906
3060
|
this.closed.emit();
|
|
2907
3061
|
log11("closed", void 0, {
|
|
2908
3062
|
F: __dxlog_file12,
|
|
2909
|
-
L:
|
|
3063
|
+
L: 201,
|
|
2910
3064
|
S: this,
|
|
2911
3065
|
C: (f, a) => f(...a)
|
|
2912
3066
|
});
|
|
@@ -3021,7 +3175,7 @@ var SimplePeerTransportService = class {
|
|
|
3021
3175
|
async sendSignal({ proxyId, signal }) {
|
|
3022
3176
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
3023
3177
|
F: __dxlog_file13,
|
|
3024
|
-
L:
|
|
3178
|
+
L: 116,
|
|
3025
3179
|
S: this,
|
|
3026
3180
|
A: [
|
|
3027
3181
|
"this.transports.has(proxyId)",
|
|
@@ -3030,18 +3184,46 @@ var SimplePeerTransportService = class {
|
|
|
3030
3184
|
});
|
|
3031
3185
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
3032
3186
|
}
|
|
3187
|
+
async getDetails({ proxyId }) {
|
|
3188
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3189
|
+
F: __dxlog_file13,
|
|
3190
|
+
L: 121,
|
|
3191
|
+
S: this,
|
|
3192
|
+
A: [
|
|
3193
|
+
"this.transports.has(proxyId)",
|
|
3194
|
+
""
|
|
3195
|
+
]
|
|
3196
|
+
});
|
|
3197
|
+
return {
|
|
3198
|
+
details: await this.transports.get(proxyId).transport.getDetails()
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
async getStats({ proxyId }) {
|
|
3202
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3203
|
+
F: __dxlog_file13,
|
|
3204
|
+
L: 126,
|
|
3205
|
+
S: this,
|
|
3206
|
+
A: [
|
|
3207
|
+
"this.transports.has(proxyId)",
|
|
3208
|
+
""
|
|
3209
|
+
]
|
|
3210
|
+
});
|
|
3211
|
+
return {
|
|
3212
|
+
stats: await this.transports.get(proxyId).transport.getStats()
|
|
3213
|
+
};
|
|
3214
|
+
}
|
|
3033
3215
|
async sendData({ proxyId, payload }) {
|
|
3034
3216
|
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
3035
3217
|
log12.debug("transport is closed", void 0, {
|
|
3036
3218
|
F: __dxlog_file13,
|
|
3037
|
-
L:
|
|
3219
|
+
L: 132,
|
|
3038
3220
|
S: this,
|
|
3039
3221
|
C: (f, a) => f(...a)
|
|
3040
3222
|
});
|
|
3041
3223
|
}
|
|
3042
3224
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
3043
3225
|
F: __dxlog_file13,
|
|
3044
|
-
L:
|
|
3226
|
+
L: 134,
|
|
3045
3227
|
S: this,
|
|
3046
3228
|
A: [
|
|
3047
3229
|
"this.transports.has(proxyId)",
|
|
@@ -3064,7 +3246,7 @@ var SimplePeerTransportService = class {
|
|
|
3064
3246
|
}
|
|
3065
3247
|
log12("Closed.", void 0, {
|
|
3066
3248
|
F: __dxlog_file13,
|
|
3067
|
-
L:
|
|
3249
|
+
L: 150,
|
|
3068
3250
|
S: this,
|
|
3069
3251
|
C: (f, a) => f(...a)
|
|
3070
3252
|
});
|
|
@@ -3203,6 +3385,16 @@ var SimplePeerTransportProxy = class {
|
|
|
3203
3385
|
signal
|
|
3204
3386
|
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3205
3387
|
}
|
|
3388
|
+
async getDetails() {
|
|
3389
|
+
return (await this._params.bridgeService.getDetails({
|
|
3390
|
+
proxyId: this._proxyId
|
|
3391
|
+
})).details;
|
|
3392
|
+
}
|
|
3393
|
+
async getStats() {
|
|
3394
|
+
return (await this._params.bridgeService.getStats({
|
|
3395
|
+
proxyId: this._proxyId
|
|
3396
|
+
})).stats;
|
|
3397
|
+
}
|
|
3206
3398
|
// TODO(burdon): Move open from constructor.
|
|
3207
3399
|
async destroy() {
|
|
3208
3400
|
await this._ctx.dispose();
|
|
@@ -3217,7 +3409,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3217
3409
|
} catch (err) {
|
|
3218
3410
|
log13.catch(err, void 0, {
|
|
3219
3411
|
F: __dxlog_file14,
|
|
3220
|
-
L:
|
|
3412
|
+
L: 168,
|
|
3221
3413
|
S: this,
|
|
3222
3414
|
C: (f, a) => f(...a)
|
|
3223
3415
|
});
|
|
@@ -3253,7 +3445,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3253
3445
|
createTransport(options) {
|
|
3254
3446
|
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3255
3447
|
F: __dxlog_file14,
|
|
3256
|
-
L:
|
|
3448
|
+
L: 205,
|
|
3257
3449
|
S: this,
|
|
3258
3450
|
A: [
|
|
3259
3451
|
"this._bridgeService",
|
|
@@ -3612,6 +3804,46 @@ var LibDataChannelTransport = class {
|
|
|
3612
3804
|
});
|
|
3613
3805
|
});
|
|
3614
3806
|
}
|
|
3807
|
+
async getDetails() {
|
|
3808
|
+
return this._peer.then(async (peer) => {
|
|
3809
|
+
const cp = await peer.getSelectedCandidatePair();
|
|
3810
|
+
if (!cp) {
|
|
3811
|
+
return "unavailable";
|
|
3812
|
+
}
|
|
3813
|
+
return `${cp.remote.address}:${cp.remote.port}/${cp.remote.transportType} ${cp.remote.type}`;
|
|
3814
|
+
}).catch((err) => {
|
|
3815
|
+
log14.catch(err, void 0, {
|
|
3816
|
+
F: __dxlog_file15,
|
|
3817
|
+
L: 250,
|
|
3818
|
+
S: this,
|
|
3819
|
+
C: (f, a) => f(...a)
|
|
3820
|
+
});
|
|
3821
|
+
return "unavailable";
|
|
3822
|
+
});
|
|
3823
|
+
}
|
|
3824
|
+
async getStats() {
|
|
3825
|
+
return this._peer.then((peer) => {
|
|
3826
|
+
return {
|
|
3827
|
+
bytesSent: peer.bytesSent(),
|
|
3828
|
+
bytesReceived: peer.bytesReceived(),
|
|
3829
|
+
packetsSent: 0,
|
|
3830
|
+
packetsReceived: 0
|
|
3831
|
+
};
|
|
3832
|
+
}).catch((err) => {
|
|
3833
|
+
log14.catch(err, void 0, {
|
|
3834
|
+
F: __dxlog_file15,
|
|
3835
|
+
L: 266,
|
|
3836
|
+
S: this,
|
|
3837
|
+
C: (f, a) => f(...a)
|
|
3838
|
+
});
|
|
3839
|
+
return {
|
|
3840
|
+
bytesSent: 0,
|
|
3841
|
+
bytesReceived: 0,
|
|
3842
|
+
packetsSent: 0,
|
|
3843
|
+
packetsReceived: 0
|
|
3844
|
+
};
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3615
3847
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
3616
3848
|
async destroy() {
|
|
3617
3849
|
await this._close();
|
|
@@ -3648,6 +3880,12 @@ var TcpTransport = class {
|
|
|
3648
3880
|
signal() {
|
|
3649
3881
|
throw new Error("Method not implemented.");
|
|
3650
3882
|
}
|
|
3883
|
+
async getStats() {
|
|
3884
|
+
throw new Error("Method not implemented.");
|
|
3885
|
+
}
|
|
3886
|
+
async getDetails() {
|
|
3887
|
+
throw new Error("Method not implemented.");
|
|
3888
|
+
}
|
|
3651
3889
|
};
|
|
3652
3890
|
|
|
3653
3891
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
@@ -3657,8 +3895,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3657
3895
|
const teleport = new Teleport(params);
|
|
3658
3896
|
return {
|
|
3659
3897
|
stream: teleport.stream,
|
|
3660
|
-
open: async () => {
|
|
3661
|
-
await teleport.open();
|
|
3898
|
+
open: async (sessionId) => {
|
|
3899
|
+
await teleport.open(sessionId);
|
|
3662
3900
|
await onConnection(teleport);
|
|
3663
3901
|
},
|
|
3664
3902
|
close: async () => {
|
|
@@ -3699,4 +3937,4 @@ export {
|
|
|
3699
3937
|
TcpTransport,
|
|
3700
3938
|
createTeleportProtocolFactory
|
|
3701
3939
|
};
|
|
3702
|
-
//# sourceMappingURL=chunk-
|
|
3940
|
+
//# sourceMappingURL=chunk-J7KS7JMZ.mjs.map
|