@dxos/network-manager 0.3.9-main.b7e6a67 → 0.3.9-main.c2ac8a5
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-LA2ACGLR.mjs → chunk-Q5B7EFTV.mjs} +382 -103
- package/dist/lib/browser/chunk-Q5B7EFTV.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-XE5JOIGD.cjs → chunk-JDKM4UPJ.cjs} +21 -13
- package/dist/lib/node/chunk-JDKM4UPJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-QWUG7JSH.cjs → chunk-YLQJ2ALQ.cjs} +384 -95
- package/dist/lib/node/chunk-YLQJ2ALQ.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 +40 -6
- 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 +44 -4
- 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 +70 -4
- 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-LA2ACGLR.mjs.map +0 -7
- package/dist/lib/node/chunk-QWUG7JSH.cjs.map +0 -7
- package/dist/lib/node/chunk-XE5JOIGD.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_YLQJ2ALQ_exports = {};
|
|
30
|
+
__export(chunk_YLQJ2ALQ_exports, {
|
|
31
31
|
Connection: () => Connection,
|
|
32
32
|
ConnectionLimiter: () => ConnectionLimiter,
|
|
33
33
|
ConnectionLog: () => ConnectionLog,
|
|
@@ -55,8 +55,8 @@ __export(chunk_QWUG7JSH_exports, {
|
|
|
55
55
|
createSimplePeerTransportFactory: () => createSimplePeerTransportFactory,
|
|
56
56
|
createTeleportProtocolFactory: () => createTeleportProtocolFactory
|
|
57
57
|
});
|
|
58
|
-
module.exports = __toCommonJS(
|
|
59
|
-
var
|
|
58
|
+
module.exports = __toCommonJS(chunk_YLQJ2ALQ_exports);
|
|
59
|
+
var import_chunk_JDKM4UPJ = require("./chunk-JDKM4UPJ.cjs");
|
|
60
60
|
var import_async = require("@dxos/async");
|
|
61
61
|
var import_context = require("@dxos/context");
|
|
62
62
|
var import_debug = require("@dxos/debug");
|
|
@@ -166,6 +166,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
166
166
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
167
167
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
168
168
|
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
169
|
+
var TRANSPORT_STATS_INTERVAL = 5e3;
|
|
169
170
|
var MAX_SIGNALLING_DELAY = 300;
|
|
170
171
|
var ConnectionState;
|
|
171
172
|
(function(ConnectionState5) {
|
|
@@ -228,6 +229,7 @@ var Connection = class {
|
|
|
228
229
|
this.stateChanged = new import_async.Event();
|
|
229
230
|
this.errors = new import_debug.ErrorStream();
|
|
230
231
|
this._instanceId = import_keys.PublicKey.random().toHex();
|
|
232
|
+
this.transportStats = new import_async.Event();
|
|
231
233
|
this._signalSendTask = new import_async.DeferredTask(this._ctx, async () => {
|
|
232
234
|
await this._flushSignalBuffer();
|
|
233
235
|
});
|
|
@@ -240,11 +242,14 @@ var Connection = class {
|
|
|
240
242
|
initiator: this.initiator
|
|
241
243
|
}, {
|
|
242
244
|
F: __dxlog_file,
|
|
243
|
-
L:
|
|
245
|
+
L: 134,
|
|
244
246
|
S: this,
|
|
245
247
|
C: (f, a) => f(...a)
|
|
246
248
|
});
|
|
247
249
|
}
|
|
250
|
+
get sessionIdString() {
|
|
251
|
+
return this.sessionId.truncate();
|
|
252
|
+
}
|
|
248
253
|
get state() {
|
|
249
254
|
return this._state;
|
|
250
255
|
}
|
|
@@ -260,7 +265,7 @@ var Connection = class {
|
|
|
260
265
|
async openConnection() {
|
|
261
266
|
(0, import_invariant.invariant)(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
262
267
|
F: __dxlog_file,
|
|
263
|
-
L:
|
|
268
|
+
L: 164,
|
|
264
269
|
S: this,
|
|
265
270
|
A: [
|
|
266
271
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -271,7 +276,7 @@ var Connection = class {
|
|
|
271
276
|
id: this._instanceId
|
|
272
277
|
}), {
|
|
273
278
|
F: __dxlog_file,
|
|
274
|
-
L:
|
|
279
|
+
L: 165,
|
|
275
280
|
S: this,
|
|
276
281
|
C: (f, a) => f(...a)
|
|
277
282
|
});
|
|
@@ -283,35 +288,35 @@ var Connection = class {
|
|
|
283
288
|
initiator: this.initiator
|
|
284
289
|
}, {
|
|
285
290
|
F: __dxlog_file,
|
|
286
|
-
L:
|
|
291
|
+
L: 166,
|
|
287
292
|
S: this,
|
|
288
293
|
C: (f, a) => f(...a)
|
|
289
294
|
});
|
|
290
295
|
this._changeState(ConnectionState.CONNECTING);
|
|
291
|
-
this._protocol.open().catch((err) => {
|
|
296
|
+
this._protocol.open(this.sessionId).catch((err) => {
|
|
292
297
|
this.errors.raise(err);
|
|
293
298
|
});
|
|
294
299
|
this._protocol.stream.on("close", () => {
|
|
295
300
|
(0, import_log.log)("protocol stream closed", void 0, {
|
|
296
301
|
F: __dxlog_file,
|
|
297
|
-
L:
|
|
302
|
+
L: 183,
|
|
298
303
|
S: this,
|
|
299
304
|
C: (f, a) => f(...a)
|
|
300
305
|
});
|
|
301
306
|
this.close(new import_protocols.ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
302
307
|
});
|
|
303
308
|
(0, import_async.scheduleTask)(this.connectedTimeoutContext, async () => {
|
|
304
|
-
import_log.log.info(
|
|
309
|
+
import_log.log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
305
310
|
F: __dxlog_file,
|
|
306
|
-
L:
|
|
311
|
+
L: 190,
|
|
307
312
|
S: this,
|
|
308
313
|
C: (f, a) => f(...a)
|
|
309
314
|
});
|
|
310
|
-
await this.abort().catch((err) => this.errors.raise(err));
|
|
315
|
+
await this.abort(new import_protocols.TimeoutError(`${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect`)).catch((err) => this.errors.raise(err));
|
|
311
316
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
312
317
|
(0, import_invariant.invariant)(!this._transport, void 0, {
|
|
313
318
|
F: __dxlog_file,
|
|
314
|
-
L:
|
|
319
|
+
L: 198,
|
|
315
320
|
S: this,
|
|
316
321
|
A: [
|
|
317
322
|
"!this._transport",
|
|
@@ -321,18 +326,20 @@ var Connection = class {
|
|
|
321
326
|
this._transport = this._transportFactory.createTransport({
|
|
322
327
|
initiator: this.initiator,
|
|
323
328
|
stream: this._protocol.stream,
|
|
324
|
-
sendSignal: async (signal) => this._sendSignal(signal)
|
|
329
|
+
sendSignal: async (signal) => this._sendSignal(signal),
|
|
330
|
+
sessionId: this.sessionId
|
|
325
331
|
});
|
|
326
332
|
this._transport.connected.once(async () => {
|
|
327
333
|
this._changeState(ConnectionState.CONNECTED);
|
|
328
334
|
await this.connectedTimeoutContext.dispose();
|
|
329
335
|
this._callbacks?.onConnected?.();
|
|
336
|
+
(0, import_async.scheduleTaskInterval)(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
|
|
330
337
|
});
|
|
331
338
|
this._transport.closed.once(() => {
|
|
332
339
|
this._transport = void 0;
|
|
333
340
|
(0, import_log.log)("abort triggered by transport close", void 0, {
|
|
334
341
|
F: __dxlog_file,
|
|
335
|
-
L:
|
|
342
|
+
L: 216,
|
|
336
343
|
S: this,
|
|
337
344
|
C: (f, a) => f(...a)
|
|
338
345
|
});
|
|
@@ -343,7 +350,7 @@ var Connection = class {
|
|
|
343
350
|
err
|
|
344
351
|
}, {
|
|
345
352
|
F: __dxlog_file,
|
|
346
|
-
L:
|
|
353
|
+
L: 221,
|
|
347
354
|
S: this,
|
|
348
355
|
C: (f, a) => f(...a)
|
|
349
356
|
});
|
|
@@ -353,7 +360,7 @@ var Connection = class {
|
|
|
353
360
|
if (err instanceof import_protocols.ConnectionResetError) {
|
|
354
361
|
import_log.log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
355
362
|
F: __dxlog_file,
|
|
356
|
-
L:
|
|
363
|
+
L: 228,
|
|
357
364
|
S: this,
|
|
358
365
|
C: (f, a) => f(...a)
|
|
359
366
|
});
|
|
@@ -361,7 +368,7 @@ var Connection = class {
|
|
|
361
368
|
} else if (err instanceof import_protocols.ConnectivityError) {
|
|
362
369
|
import_log.log.info("aborting due to transport ConnectivityError", void 0, {
|
|
363
370
|
F: __dxlog_file,
|
|
364
|
-
L:
|
|
371
|
+
L: 231,
|
|
365
372
|
S: this,
|
|
366
373
|
C: (f, a) => f(...a)
|
|
367
374
|
});
|
|
@@ -371,7 +378,7 @@ var Connection = class {
|
|
|
371
378
|
err
|
|
372
379
|
}, {
|
|
373
380
|
F: __dxlog_file,
|
|
374
|
-
L:
|
|
381
|
+
L: 234,
|
|
375
382
|
S: this,
|
|
376
383
|
C: (f, a) => f(...a)
|
|
377
384
|
});
|
|
@@ -389,7 +396,7 @@ var Connection = class {
|
|
|
389
396
|
id: this._instanceId
|
|
390
397
|
}), {
|
|
391
398
|
F: __dxlog_file,
|
|
392
|
-
L:
|
|
399
|
+
L: 250,
|
|
393
400
|
S: this,
|
|
394
401
|
C: (f, a) => f(...a)
|
|
395
402
|
});
|
|
@@ -399,14 +406,14 @@ var Connection = class {
|
|
|
399
406
|
err
|
|
400
407
|
}, {
|
|
401
408
|
F: __dxlog_file,
|
|
402
|
-
L:
|
|
409
|
+
L: 257,
|
|
403
410
|
S: this,
|
|
404
411
|
C: (f, a) => f(...a)
|
|
405
412
|
});
|
|
406
413
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
407
414
|
(0, import_log.log)(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
408
415
|
F: __dxlog_file,
|
|
409
|
-
L:
|
|
416
|
+
L: 259,
|
|
410
417
|
S: this,
|
|
411
418
|
C: (f, a) => f(...a)
|
|
412
419
|
});
|
|
@@ -421,7 +428,7 @@ var Connection = class {
|
|
|
421
428
|
try {
|
|
422
429
|
(0, import_log.log)("aborting protocol... ", void 0, {
|
|
423
430
|
F: __dxlog_file,
|
|
424
|
-
L:
|
|
431
|
+
L: 273,
|
|
425
432
|
S: this,
|
|
426
433
|
C: (f, a) => f(...a)
|
|
427
434
|
});
|
|
@@ -429,7 +436,7 @@ var Connection = class {
|
|
|
429
436
|
} catch (err2) {
|
|
430
437
|
import_log.log.catch(err2, void 0, {
|
|
431
438
|
F: __dxlog_file,
|
|
432
|
-
L:
|
|
439
|
+
L: 276,
|
|
433
440
|
S: this,
|
|
434
441
|
C: (f, a) => f(...a)
|
|
435
442
|
});
|
|
@@ -439,7 +446,7 @@ var Connection = class {
|
|
|
439
446
|
} catch (err2) {
|
|
440
447
|
import_log.log.catch(err2, void 0, {
|
|
441
448
|
F: __dxlog_file,
|
|
442
|
-
L:
|
|
449
|
+
L: 283,
|
|
443
450
|
S: this,
|
|
444
451
|
C: (f, a) => f(...a)
|
|
445
452
|
});
|
|
@@ -449,7 +456,7 @@ var Connection = class {
|
|
|
449
456
|
} catch (err2) {
|
|
450
457
|
import_log.log.catch(err2, void 0, {
|
|
451
458
|
F: __dxlog_file,
|
|
452
|
-
L:
|
|
459
|
+
L: 289,
|
|
453
460
|
S: this,
|
|
454
461
|
C: (f, a) => f(...a)
|
|
455
462
|
});
|
|
@@ -473,7 +480,7 @@ var Connection = class {
|
|
|
473
480
|
peerId: this.ownId
|
|
474
481
|
}, {
|
|
475
482
|
F: __dxlog_file,
|
|
476
|
-
L:
|
|
483
|
+
L: 314,
|
|
477
484
|
S: this,
|
|
478
485
|
C: (f, a) => f(...a)
|
|
479
486
|
});
|
|
@@ -483,7 +490,34 @@ var Connection = class {
|
|
|
483
490
|
} catch (err2) {
|
|
484
491
|
import_log.log.catch(err2, void 0, {
|
|
485
492
|
F: __dxlog_file,
|
|
486
|
-
L:
|
|
493
|
+
L: 321,
|
|
494
|
+
S: this,
|
|
495
|
+
C: (f, a) => f(...a)
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
try {
|
|
499
|
+
await this._transport?.destroy();
|
|
500
|
+
} catch (err2) {
|
|
501
|
+
import_log.log.catch(err2, void 0, {
|
|
502
|
+
F: __dxlog_file,
|
|
503
|
+
L: 328,
|
|
504
|
+
S: this,
|
|
505
|
+
C: (f, a) => f(...a)
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
} else {
|
|
509
|
+
import_log.log.info(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
510
|
+
F: __dxlog_file,
|
|
511
|
+
L: 331,
|
|
512
|
+
S: this,
|
|
513
|
+
C: (f, a) => f(...a)
|
|
514
|
+
});
|
|
515
|
+
try {
|
|
516
|
+
await this._protocol.abort();
|
|
517
|
+
} catch (err2) {
|
|
518
|
+
import_log.log.catch(err2, void 0, {
|
|
519
|
+
F: __dxlog_file,
|
|
520
|
+
L: 335,
|
|
487
521
|
S: this,
|
|
488
522
|
C: (f, a) => f(...a)
|
|
489
523
|
});
|
|
@@ -493,7 +527,7 @@ var Connection = class {
|
|
|
493
527
|
} catch (err2) {
|
|
494
528
|
import_log.log.catch(err2, void 0, {
|
|
495
529
|
F: __dxlog_file,
|
|
496
|
-
L:
|
|
530
|
+
L: 340,
|
|
497
531
|
S: this,
|
|
498
532
|
C: (f, a) => f(...a)
|
|
499
533
|
});
|
|
@@ -503,7 +537,7 @@ var Connection = class {
|
|
|
503
537
|
peerId: this.ownId
|
|
504
538
|
}, {
|
|
505
539
|
F: __dxlog_file,
|
|
506
|
-
L:
|
|
540
|
+
L: 344,
|
|
507
541
|
S: this,
|
|
508
542
|
C: (f, a) => f(...a)
|
|
509
543
|
});
|
|
@@ -546,7 +580,7 @@ var Connection = class {
|
|
|
546
580
|
err
|
|
547
581
|
}, {
|
|
548
582
|
F: __dxlog_file,
|
|
549
|
-
L:
|
|
583
|
+
L: 382,
|
|
550
584
|
S: this,
|
|
551
585
|
C: (f, a) => f(...a)
|
|
552
586
|
});
|
|
@@ -559,7 +593,7 @@ var Connection = class {
|
|
|
559
593
|
async signal(msg) {
|
|
560
594
|
(0, import_invariant.invariant)(msg.sessionId, void 0, {
|
|
561
595
|
F: __dxlog_file,
|
|
562
|
-
L:
|
|
596
|
+
L: 391,
|
|
563
597
|
S: this,
|
|
564
598
|
A: [
|
|
565
599
|
"msg.sessionId",
|
|
@@ -569,7 +603,7 @@ var Connection = class {
|
|
|
569
603
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
570
604
|
(0, import_log.log)("dropping signal for incorrect session id", void 0, {
|
|
571
605
|
F: __dxlog_file,
|
|
572
|
-
L:
|
|
606
|
+
L: 393,
|
|
573
607
|
S: this,
|
|
574
608
|
C: (f, a) => f(...a)
|
|
575
609
|
});
|
|
@@ -577,7 +611,7 @@ var Connection = class {
|
|
|
577
611
|
}
|
|
578
612
|
(0, import_invariant.invariant)(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
579
613
|
F: __dxlog_file,
|
|
580
|
-
L:
|
|
614
|
+
L: 396,
|
|
581
615
|
S: this,
|
|
582
616
|
A: [
|
|
583
617
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -586,7 +620,7 @@ var Connection = class {
|
|
|
586
620
|
});
|
|
587
621
|
(0, import_invariant.invariant)(msg.author?.equals(this.remoteId), void 0, {
|
|
588
622
|
F: __dxlog_file,
|
|
589
|
-
L:
|
|
623
|
+
L: 397,
|
|
590
624
|
S: this,
|
|
591
625
|
A: [
|
|
592
626
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -595,7 +629,7 @@ var Connection = class {
|
|
|
595
629
|
});
|
|
596
630
|
(0, import_invariant.invariant)(msg.recipient?.equals(this.ownId), void 0, {
|
|
597
631
|
F: __dxlog_file,
|
|
598
|
-
L:
|
|
632
|
+
L: 398,
|
|
599
633
|
S: this,
|
|
600
634
|
A: [
|
|
601
635
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -619,7 +653,7 @@ var Connection = class {
|
|
|
619
653
|
msg: msg.data
|
|
620
654
|
}, {
|
|
621
655
|
F: __dxlog_file,
|
|
622
|
-
L:
|
|
656
|
+
L: 407,
|
|
623
657
|
S: this,
|
|
624
658
|
C: (f, a) => f(...a)
|
|
625
659
|
});
|
|
@@ -627,7 +661,7 @@ var Connection = class {
|
|
|
627
661
|
} else {
|
|
628
662
|
(0, import_invariant.invariant)(this._transport, "Connection not ready to accept signals.", {
|
|
629
663
|
F: __dxlog_file,
|
|
630
|
-
L:
|
|
664
|
+
L: 410,
|
|
631
665
|
S: this,
|
|
632
666
|
A: [
|
|
633
667
|
"this._transport",
|
|
@@ -640,7 +674,7 @@ var Connection = class {
|
|
|
640
674
|
msg: msg.data
|
|
641
675
|
}, {
|
|
642
676
|
F: __dxlog_file,
|
|
643
|
-
L:
|
|
677
|
+
L: 411,
|
|
644
678
|
S: this,
|
|
645
679
|
C: (f, a) => f(...a)
|
|
646
680
|
});
|
|
@@ -658,13 +692,13 @@ var Connection = class {
|
|
|
658
692
|
peerId: this.ownId
|
|
659
693
|
}, {
|
|
660
694
|
F: __dxlog_file,
|
|
661
|
-
L:
|
|
695
|
+
L: 422,
|
|
662
696
|
S: this,
|
|
663
697
|
C: (f, a) => f(...a)
|
|
664
698
|
});
|
|
665
699
|
(0, import_invariant.invariant)(state !== this._state, "Already in this state.", {
|
|
666
700
|
F: __dxlog_file,
|
|
667
|
-
L:
|
|
701
|
+
L: 423,
|
|
668
702
|
S: this,
|
|
669
703
|
A: [
|
|
670
704
|
"state !== this._state",
|
|
@@ -674,7 +708,16 @@ var Connection = class {
|
|
|
674
708
|
this._state = state;
|
|
675
709
|
this.stateChanged.emit(state);
|
|
676
710
|
}
|
|
711
|
+
async _emitTransportStats() {
|
|
712
|
+
const stats = await this.transport?.getStats();
|
|
713
|
+
if (stats) {
|
|
714
|
+
this.transportStats.emit(stats);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
677
717
|
};
|
|
718
|
+
_ts_decorate([
|
|
719
|
+
import_log.logInfo
|
|
720
|
+
], Connection.prototype, "sessionIdString", null);
|
|
678
721
|
_ts_decorate([
|
|
679
722
|
import_async.synchronized
|
|
680
723
|
], Connection.prototype, "abort", null);
|
|
@@ -2063,7 +2106,7 @@ var ConnectionLog = class {
|
|
|
2063
2106
|
};
|
|
2064
2107
|
info.connections.push(connectionInfo);
|
|
2065
2108
|
this.update.emit();
|
|
2066
|
-
connection.stateChanged.on((state) => {
|
|
2109
|
+
connection.stateChanged.on(async (state) => {
|
|
2067
2110
|
connectionInfo.state = state;
|
|
2068
2111
|
connectionInfo.closeReason = connection.closeReason;
|
|
2069
2112
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
@@ -2071,6 +2114,10 @@ var ConnectionLog = class {
|
|
|
2071
2114
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
2072
2115
|
newState: state
|
|
2073
2116
|
});
|
|
2117
|
+
if (state === ConnectionState.CONNECTED) {
|
|
2118
|
+
const details = await connection.transport?.getDetails();
|
|
2119
|
+
connectionInfo.transportDetails = details;
|
|
2120
|
+
}
|
|
2074
2121
|
this.update.emit();
|
|
2075
2122
|
});
|
|
2076
2123
|
connection.protocol?.stats?.on((stats) => {
|
|
@@ -2080,6 +2127,12 @@ var ConnectionLog = class {
|
|
|
2080
2127
|
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
2081
2128
|
this.update.emit();
|
|
2082
2129
|
});
|
|
2130
|
+
connection.transportStats?.on((stats) => {
|
|
2131
|
+
connectionInfo.transportBytesSent = stats.bytesSent;
|
|
2132
|
+
connectionInfo.transportBytesReceived = stats.bytesReceived;
|
|
2133
|
+
connectionInfo.transportPacketsSent = stats.packetsSent;
|
|
2134
|
+
connectionInfo.transportPacketsReceived = stats.packetsReceived;
|
|
2135
|
+
});
|
|
2083
2136
|
gcSwarm(info);
|
|
2084
2137
|
});
|
|
2085
2138
|
}
|
|
@@ -2362,9 +2415,12 @@ var FullyConnectedTopology = class {
|
|
|
2362
2415
|
}
|
|
2363
2416
|
};
|
|
2364
2417
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2418
|
+
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2419
|
+
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2365
2420
|
var MMSTTopology = class {
|
|
2366
2421
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2367
2422
|
this._sampleCollected = false;
|
|
2423
|
+
this._lastAction = /* @__PURE__ */ new Date(0);
|
|
2368
2424
|
this._originateConnections = originateConnections;
|
|
2369
2425
|
this._maxPeers = maxPeers;
|
|
2370
2426
|
this._sampleSize = sampleSize;
|
|
@@ -2372,7 +2428,7 @@ var MMSTTopology = class {
|
|
|
2372
2428
|
init(controller) {
|
|
2373
2429
|
(0, import_invariant8.invariant)(!this._controller, "Already initialized", {
|
|
2374
2430
|
F: __dxlog_file9,
|
|
2375
|
-
L:
|
|
2431
|
+
L: 51,
|
|
2376
2432
|
S: this,
|
|
2377
2433
|
A: [
|
|
2378
2434
|
"!this._controller",
|
|
@@ -2384,7 +2440,7 @@ var MMSTTopology = class {
|
|
|
2384
2440
|
update() {
|
|
2385
2441
|
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2386
2442
|
F: __dxlog_file9,
|
|
2387
|
-
L:
|
|
2443
|
+
L: 56,
|
|
2388
2444
|
S: this,
|
|
2389
2445
|
A: [
|
|
2390
2446
|
"this._controller",
|
|
@@ -2393,9 +2449,9 @@ var MMSTTopology = class {
|
|
|
2393
2449
|
});
|
|
2394
2450
|
const { connected, candidates } = this._controller.getState();
|
|
2395
2451
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
2396
|
-
|
|
2452
|
+
import_log8.log.info("Running the algorithm.", void 0, {
|
|
2397
2453
|
F: __dxlog_file9,
|
|
2398
|
-
L:
|
|
2454
|
+
L: 60,
|
|
2399
2455
|
S: this,
|
|
2400
2456
|
C: (f, a) => f(...a)
|
|
2401
2457
|
});
|
|
@@ -2406,7 +2462,7 @@ var MMSTTopology = class {
|
|
|
2406
2462
|
async onOffer(peer) {
|
|
2407
2463
|
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2408
2464
|
F: __dxlog_file9,
|
|
2409
|
-
L:
|
|
2465
|
+
L: 67,
|
|
2410
2466
|
S: this,
|
|
2411
2467
|
A: [
|
|
2412
2468
|
"this._controller",
|
|
@@ -2417,7 +2473,7 @@ var MMSTTopology = class {
|
|
|
2417
2473
|
const accept = connected.length < this._maxPeers;
|
|
2418
2474
|
(0, import_log8.log)(`Offer ${peer} accept=${accept}`, void 0, {
|
|
2419
2475
|
F: __dxlog_file9,
|
|
2420
|
-
L:
|
|
2476
|
+
L: 70,
|
|
2421
2477
|
S: this,
|
|
2422
2478
|
C: (f, a) => f(...a)
|
|
2423
2479
|
});
|
|
@@ -2428,7 +2484,7 @@ var MMSTTopology = class {
|
|
|
2428
2484
|
_runAlgorithm() {
|
|
2429
2485
|
(0, import_invariant8.invariant)(this._controller, "Not initialized", {
|
|
2430
2486
|
F: __dxlog_file9,
|
|
2431
|
-
L:
|
|
2487
|
+
L: 79,
|
|
2432
2488
|
S: this,
|
|
2433
2489
|
A: [
|
|
2434
2490
|
"this._controller",
|
|
@@ -2437,27 +2493,84 @@ var MMSTTopology = class {
|
|
|
2437
2493
|
});
|
|
2438
2494
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
2439
2495
|
if (connected.length > this._maxPeers) {
|
|
2496
|
+
import_log8.log.info(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
|
|
2497
|
+
F: __dxlog_file9,
|
|
2498
|
+
L: 85,
|
|
2499
|
+
S: this,
|
|
2500
|
+
C: (f, a) => f(...a)
|
|
2501
|
+
});
|
|
2440
2502
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
2441
|
-
|
|
2442
|
-
|
|
2503
|
+
(0, import_invariant8.invariant)(sorted.length === 0, void 0, {
|
|
2504
|
+
F: __dxlog_file9,
|
|
2505
|
+
L: 89,
|
|
2506
|
+
S: this,
|
|
2507
|
+
A: [
|
|
2508
|
+
"sorted.length === 0",
|
|
2509
|
+
""
|
|
2510
|
+
]
|
|
2511
|
+
});
|
|
2512
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2513
|
+
(0, import_log8.log)(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2443
2514
|
F: __dxlog_file9,
|
|
2444
|
-
L:
|
|
2515
|
+
L: 92,
|
|
2516
|
+
S: this,
|
|
2517
|
+
C: (f, a) => f(...a)
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2521
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2522
|
+
import_log8.log.info(`Disconnect ${peer}.`, void 0, {
|
|
2523
|
+
F: __dxlog_file9,
|
|
2524
|
+
L: 97,
|
|
2525
|
+
S: this,
|
|
2526
|
+
C: (f, a) => f(...a)
|
|
2527
|
+
});
|
|
2528
|
+
this._controller.disconnect(peer);
|
|
2529
|
+
}
|
|
2530
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2531
|
+
} else {
|
|
2532
|
+
import_log8.log.info("rate limited discconnect", void 0, {
|
|
2533
|
+
F: __dxlog_file9,
|
|
2534
|
+
L: 102,
|
|
2445
2535
|
S: this,
|
|
2446
2536
|
C: (f, a) => f(...a)
|
|
2447
2537
|
});
|
|
2448
|
-
this._controller.disconnect(peer);
|
|
2449
2538
|
}
|
|
2450
2539
|
} else if (connected.length < this._originateConnections) {
|
|
2540
|
+
import_log8.log.info(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
|
|
2541
|
+
F: __dxlog_file9,
|
|
2542
|
+
L: 106,
|
|
2543
|
+
S: this,
|
|
2544
|
+
C: (f, a) => f(...a)
|
|
2545
|
+
});
|
|
2451
2546
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
2452
2547
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
2453
|
-
|
|
2454
|
-
(0, import_log8.log)(`
|
|
2548
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2549
|
+
(0, import_log8.log)(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2455
2550
|
F: __dxlog_file9,
|
|
2456
|
-
L:
|
|
2551
|
+
L: 111,
|
|
2552
|
+
S: this,
|
|
2553
|
+
C: (f, a) => f(...a)
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2557
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2558
|
+
import_log8.log.info(`Connect ${peer}.`, void 0, {
|
|
2559
|
+
F: __dxlog_file9,
|
|
2560
|
+
L: 115,
|
|
2561
|
+
S: this,
|
|
2562
|
+
C: (f, a) => f(...a)
|
|
2563
|
+
});
|
|
2564
|
+
this._controller.connect(peer);
|
|
2565
|
+
}
|
|
2566
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2567
|
+
} else {
|
|
2568
|
+
import_log8.log.info("rate limited connect", void 0, {
|
|
2569
|
+
F: __dxlog_file9,
|
|
2570
|
+
L: 120,
|
|
2457
2571
|
S: this,
|
|
2458
2572
|
C: (f, a) => f(...a)
|
|
2459
2573
|
});
|
|
2460
|
-
this._controller.connect(peer);
|
|
2461
2574
|
}
|
|
2462
2575
|
}
|
|
2463
2576
|
}
|
|
@@ -2730,6 +2843,17 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2730
2843
|
this._remote.wake(remoteId);
|
|
2731
2844
|
}
|
|
2732
2845
|
}
|
|
2846
|
+
async getDetails() {
|
|
2847
|
+
return this._instanceId.toHex();
|
|
2848
|
+
}
|
|
2849
|
+
async getStats() {
|
|
2850
|
+
return {
|
|
2851
|
+
bytesSent: 0,
|
|
2852
|
+
bytesReceived: 0,
|
|
2853
|
+
packetsSent: 0,
|
|
2854
|
+
packetsReceived: 0
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2733
2857
|
};
|
|
2734
2858
|
_ts_decorate4([
|
|
2735
2859
|
import_log10.logInfo
|
|
@@ -2747,11 +2871,14 @@ var TransportKind;
|
|
|
2747
2871
|
})(TransportKind || (TransportKind = {}));
|
|
2748
2872
|
var wrtc = null;
|
|
2749
2873
|
try {
|
|
2750
|
-
wrtc = (0,
|
|
2874
|
+
wrtc = (0, import_chunk_JDKM4UPJ.__require)("@koush/wrtc");
|
|
2751
2875
|
} catch {
|
|
2752
2876
|
}
|
|
2753
2877
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2754
2878
|
var SimplePeerTransport = class {
|
|
2879
|
+
/**
|
|
2880
|
+
* @params opts.config formatted as per https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
|
|
2881
|
+
*/
|
|
2755
2882
|
constructor(params) {
|
|
2756
2883
|
this.params = params;
|
|
2757
2884
|
this._closed = false;
|
|
@@ -2764,13 +2891,13 @@ var SimplePeerTransport = class {
|
|
|
2764
2891
|
id: this._instanceId
|
|
2765
2892
|
}), {
|
|
2766
2893
|
F: __dxlog_file12,
|
|
2767
|
-
L:
|
|
2894
|
+
L: 44,
|
|
2768
2895
|
S: this,
|
|
2769
2896
|
C: (f, a) => f(...a)
|
|
2770
2897
|
});
|
|
2771
2898
|
(0, import_log11.log)("created connection", params, {
|
|
2772
2899
|
F: __dxlog_file12,
|
|
2773
|
-
L:
|
|
2900
|
+
L: 45,
|
|
2774
2901
|
S: this,
|
|
2775
2902
|
C: (f, a) => f(...a)
|
|
2776
2903
|
});
|
|
@@ -2783,7 +2910,7 @@ var SimplePeerTransport = class {
|
|
|
2783
2910
|
this._peer.on("signal", async (data) => {
|
|
2784
2911
|
(0, import_log11.log)("signal", data, {
|
|
2785
2912
|
F: __dxlog_file12,
|
|
2786
|
-
L:
|
|
2913
|
+
L: 54,
|
|
2787
2914
|
S: this,
|
|
2788
2915
|
C: (f, a) => f(...a)
|
|
2789
2916
|
});
|
|
@@ -2796,7 +2923,7 @@ var SimplePeerTransport = class {
|
|
|
2796
2923
|
this._peer.on("connect", () => {
|
|
2797
2924
|
(0, import_log11.log)("connected", void 0, {
|
|
2798
2925
|
F: __dxlog_file12,
|
|
2799
|
-
L:
|
|
2926
|
+
L: 59,
|
|
2800
2927
|
S: this,
|
|
2801
2928
|
C: (f, a) => f(...a)
|
|
2802
2929
|
});
|
|
@@ -2807,7 +2934,7 @@ var SimplePeerTransport = class {
|
|
|
2807
2934
|
this._peer.on("close", async () => {
|
|
2808
2935
|
(0, import_log11.log)("closed", void 0, {
|
|
2809
2936
|
F: __dxlog_file12,
|
|
2810
|
-
L:
|
|
2937
|
+
L: 66,
|
|
2811
2938
|
S: this,
|
|
2812
2939
|
C: (f, a) => f(...a)
|
|
2813
2940
|
});
|
|
@@ -2818,12 +2945,20 @@ var SimplePeerTransport = class {
|
|
|
2818
2945
|
if (err.errorDetail === "sctp-failure") {
|
|
2819
2946
|
this.errors.raise(new import_protocols7.ConnectionResetError("sctp-failure from RTCError", err));
|
|
2820
2947
|
} else {
|
|
2948
|
+
import_log11.log.info("unknown RTCError", {
|
|
2949
|
+
err
|
|
2950
|
+
}, {
|
|
2951
|
+
F: __dxlog_file12,
|
|
2952
|
+
L: 77,
|
|
2953
|
+
S: this,
|
|
2954
|
+
C: (f, a) => f(...a)
|
|
2955
|
+
});
|
|
2821
2956
|
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown RTCError", err));
|
|
2822
2957
|
}
|
|
2823
2958
|
} else if ("code" in err) {
|
|
2824
2959
|
import_log11.log.info("simple-peer error", err, {
|
|
2825
2960
|
F: __dxlog_file12,
|
|
2826
|
-
L:
|
|
2961
|
+
L: 82,
|
|
2827
2962
|
S: this,
|
|
2828
2963
|
C: (f, a) => f(...a)
|
|
2829
2964
|
});
|
|
@@ -2831,10 +2966,12 @@ var SimplePeerTransport = class {
|
|
|
2831
2966
|
case "ERR_WEBRTC_SUPPORT":
|
|
2832
2967
|
this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
|
|
2833
2968
|
break;
|
|
2969
|
+
case "ERR_SIGNALING":
|
|
2970
|
+
this.errors.raise(new import_protocols7.ConnectivityError("signaling failure", err));
|
|
2971
|
+
break;
|
|
2834
2972
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
2835
2973
|
case "ERR_DATA_CHANNEL":
|
|
2836
2974
|
case "ERR_CONNECTION_FAILURE":
|
|
2837
|
-
case "ERR_SIGNALING":
|
|
2838
2975
|
this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
|
|
2839
2976
|
break;
|
|
2840
2977
|
case "ERR_CREATE_OFFER":
|
|
@@ -2851,7 +2988,7 @@ var SimplePeerTransport = class {
|
|
|
2851
2988
|
} else {
|
|
2852
2989
|
import_log11.log.info("unknown peer connection error", err, {
|
|
2853
2990
|
F: __dxlog_file12,
|
|
2854
|
-
L:
|
|
2991
|
+
L: 108,
|
|
2855
2992
|
S: this,
|
|
2856
2993
|
C: (f, a) => f(...a)
|
|
2857
2994
|
});
|
|
@@ -2862,10 +2999,10 @@ var SimplePeerTransport = class {
|
|
|
2862
2999
|
this._peer._pc.getStats().then((stats) => {
|
|
2863
3000
|
import_log11.log.info("report after webrtc error", {
|
|
2864
3001
|
config: this.params.webrtcConfig,
|
|
2865
|
-
stats
|
|
3002
|
+
stats: Object.fromEntries(stats.entries())
|
|
2866
3003
|
}, {
|
|
2867
3004
|
F: __dxlog_file12,
|
|
2868
|
-
L:
|
|
3005
|
+
L: 116,
|
|
2869
3006
|
S: this,
|
|
2870
3007
|
C: (f, a) => f(...a)
|
|
2871
3008
|
});
|
|
@@ -2874,7 +3011,7 @@ var SimplePeerTransport = class {
|
|
|
2874
3011
|
} catch (err2) {
|
|
2875
3012
|
import_log11.log.catch(err2, void 0, {
|
|
2876
3013
|
F: __dxlog_file12,
|
|
2877
|
-
L:
|
|
3014
|
+
L: 123,
|
|
2878
3015
|
S: this,
|
|
2879
3016
|
C: (f, a) => f(...a)
|
|
2880
3017
|
});
|
|
@@ -2885,28 +3022,81 @@ var SimplePeerTransport = class {
|
|
|
2885
3022
|
id: this._instanceId
|
|
2886
3023
|
}), {
|
|
2887
3024
|
F: __dxlog_file12,
|
|
2888
|
-
L:
|
|
3025
|
+
L: 129,
|
|
2889
3026
|
S: this,
|
|
2890
3027
|
C: (f, a) => f(...a)
|
|
2891
3028
|
});
|
|
2892
3029
|
}
|
|
3030
|
+
async getStats() {
|
|
3031
|
+
const stats = await this._getStats();
|
|
3032
|
+
if (!stats) {
|
|
3033
|
+
return {
|
|
3034
|
+
bytesSent: 0,
|
|
3035
|
+
bytesReceived: 0,
|
|
3036
|
+
packetsSent: 0,
|
|
3037
|
+
packetsReceived: 0,
|
|
3038
|
+
rawStats: {}
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
return {
|
|
3042
|
+
bytesSent: stats.transport.bytesSent,
|
|
3043
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
3044
|
+
packetsSent: stats.transport.messagesSent,
|
|
3045
|
+
packetsReceived: stats.transport.messagesReceived,
|
|
3046
|
+
rawStats: stats.raw
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
async _getStats() {
|
|
3050
|
+
if (typeof this._peer?._pc?.getStats !== "function") {
|
|
3051
|
+
return null;
|
|
3052
|
+
}
|
|
3053
|
+
return await this._peer._pc.getStats().then((stats) => {
|
|
3054
|
+
const statsEntries = Array.from(stats.entries());
|
|
3055
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
3056
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
3057
|
+
let selectedCandidatePair;
|
|
3058
|
+
let remoteCandidate;
|
|
3059
|
+
if (candidatePair.length > 0) {
|
|
3060
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
3061
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
3062
|
+
}
|
|
3063
|
+
return {
|
|
3064
|
+
datachannel: statsEntries.filter((s) => s[1].type === "data-channel")[0][1],
|
|
3065
|
+
transport,
|
|
3066
|
+
selectedCandidatePair,
|
|
3067
|
+
remoteCandidate,
|
|
3068
|
+
raw: Object.fromEntries(stats.entries())
|
|
3069
|
+
};
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
async getDetails() {
|
|
3073
|
+
const stats = await this._getStats();
|
|
3074
|
+
const rc = stats?.remoteCandidate;
|
|
3075
|
+
if (!rc) {
|
|
3076
|
+
return "unavailable";
|
|
3077
|
+
}
|
|
3078
|
+
if (rc.candidateType === "relay") {
|
|
3079
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for ${rc.relatedAddress}:${rc.relatedPort}`;
|
|
3080
|
+
}
|
|
3081
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
3082
|
+
}
|
|
2893
3083
|
async destroy() {
|
|
2894
3084
|
(0, import_log11.log)("closing...", void 0, {
|
|
2895
3085
|
F: __dxlog_file12,
|
|
2896
|
-
L:
|
|
3086
|
+
L: 192,
|
|
2897
3087
|
S: this,
|
|
2898
3088
|
C: (f, a) => f(...a)
|
|
2899
3089
|
});
|
|
2900
3090
|
if (this._closed) {
|
|
2901
3091
|
return;
|
|
2902
3092
|
}
|
|
2903
|
-
this._closed = true;
|
|
2904
3093
|
this._disconnectStreams();
|
|
2905
3094
|
this._peer.destroy();
|
|
3095
|
+
this._closed = true;
|
|
2906
3096
|
this.closed.emit();
|
|
2907
3097
|
(0, import_log11.log)("closed", void 0, {
|
|
2908
3098
|
F: __dxlog_file12,
|
|
2909
|
-
L:
|
|
3099
|
+
L: 200,
|
|
2910
3100
|
S: this,
|
|
2911
3101
|
C: (f, a) => f(...a)
|
|
2912
3102
|
});
|
|
@@ -3012,7 +3202,7 @@ var SimplePeerTransportService = class {
|
|
|
3012
3202
|
async sendSignal({ proxyId, signal }) {
|
|
3013
3203
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3014
3204
|
F: __dxlog_file13,
|
|
3015
|
-
L:
|
|
3205
|
+
L: 116,
|
|
3016
3206
|
S: this,
|
|
3017
3207
|
A: [
|
|
3018
3208
|
"this.transports.has(proxyId)",
|
|
@@ -3021,18 +3211,46 @@ var SimplePeerTransportService = class {
|
|
|
3021
3211
|
});
|
|
3022
3212
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
3023
3213
|
}
|
|
3214
|
+
async getDetails({ proxyId }) {
|
|
3215
|
+
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3216
|
+
F: __dxlog_file13,
|
|
3217
|
+
L: 121,
|
|
3218
|
+
S: this,
|
|
3219
|
+
A: [
|
|
3220
|
+
"this.transports.has(proxyId)",
|
|
3221
|
+
""
|
|
3222
|
+
]
|
|
3223
|
+
});
|
|
3224
|
+
return {
|
|
3225
|
+
details: await this.transports.get(proxyId).transport.getDetails()
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3228
|
+
async getStats({ proxyId }) {
|
|
3229
|
+
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3230
|
+
F: __dxlog_file13,
|
|
3231
|
+
L: 126,
|
|
3232
|
+
S: this,
|
|
3233
|
+
A: [
|
|
3234
|
+
"this.transports.has(proxyId)",
|
|
3235
|
+
""
|
|
3236
|
+
]
|
|
3237
|
+
});
|
|
3238
|
+
return {
|
|
3239
|
+
stats: await this.transports.get(proxyId).transport.getStats()
|
|
3240
|
+
};
|
|
3241
|
+
}
|
|
3024
3242
|
async sendData({ proxyId, payload }) {
|
|
3025
3243
|
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
3026
3244
|
import_log12.log.debug("transport is closed", void 0, {
|
|
3027
3245
|
F: __dxlog_file13,
|
|
3028
|
-
L:
|
|
3246
|
+
L: 132,
|
|
3029
3247
|
S: this,
|
|
3030
3248
|
C: (f, a) => f(...a)
|
|
3031
3249
|
});
|
|
3032
3250
|
}
|
|
3033
3251
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3034
3252
|
F: __dxlog_file13,
|
|
3035
|
-
L:
|
|
3253
|
+
L: 134,
|
|
3036
3254
|
S: this,
|
|
3037
3255
|
A: [
|
|
3038
3256
|
"this.transports.has(proxyId)",
|
|
@@ -3055,7 +3273,7 @@ var SimplePeerTransportService = class {
|
|
|
3055
3273
|
}
|
|
3056
3274
|
(0, import_log12.log)("Closed.", void 0, {
|
|
3057
3275
|
F: __dxlog_file13,
|
|
3058
|
-
L:
|
|
3276
|
+
L: 150,
|
|
3059
3277
|
S: this,
|
|
3060
3278
|
C: (f, a) => f(...a)
|
|
3061
3279
|
});
|
|
@@ -3182,6 +3400,16 @@ var SimplePeerTransportProxy = class {
|
|
|
3182
3400
|
signal
|
|
3183
3401
|
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3184
3402
|
}
|
|
3403
|
+
async getDetails() {
|
|
3404
|
+
return (await this._params.bridgeService.getDetails({
|
|
3405
|
+
proxyId: this._proxyId
|
|
3406
|
+
})).details;
|
|
3407
|
+
}
|
|
3408
|
+
async getStats() {
|
|
3409
|
+
return (await this._params.bridgeService.getStats({
|
|
3410
|
+
proxyId: this._proxyId
|
|
3411
|
+
})).stats;
|
|
3412
|
+
}
|
|
3185
3413
|
// TODO(burdon): Move open from constructor.
|
|
3186
3414
|
async destroy() {
|
|
3187
3415
|
await this._ctx.dispose();
|
|
@@ -3196,7 +3424,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3196
3424
|
} catch (err) {
|
|
3197
3425
|
import_log13.log.catch(err, void 0, {
|
|
3198
3426
|
F: __dxlog_file14,
|
|
3199
|
-
L:
|
|
3427
|
+
L: 168,
|
|
3200
3428
|
S: this,
|
|
3201
3429
|
C: (f, a) => f(...a)
|
|
3202
3430
|
});
|
|
@@ -3232,7 +3460,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3232
3460
|
createTransport(options) {
|
|
3233
3461
|
(0, import_invariant12.invariant)(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3234
3462
|
F: __dxlog_file14,
|
|
3235
|
-
L:
|
|
3463
|
+
L: 205,
|
|
3236
3464
|
S: this,
|
|
3237
3465
|
A: [
|
|
3238
3466
|
"this._bridgeService",
|
|
@@ -3289,7 +3517,7 @@ var LibDataChannelTransport = class {
|
|
|
3289
3517
|
this._readyForCandidates = new import_async11.Trigger();
|
|
3290
3518
|
this._writeCallback = null;
|
|
3291
3519
|
this._peer = (async () => {
|
|
3292
|
-
const { RTCPeerConnection: PeerConnection } = await import("./datachannel-
|
|
3520
|
+
const { RTCPeerConnection: PeerConnection } = await import("./datachannel-3VTTIMR5.cjs");
|
|
3293
3521
|
if (this._closed) {
|
|
3294
3522
|
this.errors.raise(new Error("connection already closed"));
|
|
3295
3523
|
}
|
|
@@ -3427,16 +3655,21 @@ var LibDataChannelTransport = class {
|
|
|
3427
3655
|
const duplex = new import_stream.Duplex({
|
|
3428
3656
|
read: () => {
|
|
3429
3657
|
},
|
|
3430
|
-
write: (chunk, encoding, callback) => {
|
|
3658
|
+
write: async (chunk, encoding, callback) => {
|
|
3431
3659
|
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3432
3660
|
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3433
3661
|
}
|
|
3434
|
-
|
|
3662
|
+
try {
|
|
3663
|
+
dataChannel.send(chunk);
|
|
3664
|
+
} catch (err) {
|
|
3665
|
+
this.errors.raise(err);
|
|
3666
|
+
await this._close();
|
|
3667
|
+
}
|
|
3435
3668
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3436
3669
|
if (this._writeCallback !== null) {
|
|
3437
3670
|
import_log14.log.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3438
3671
|
F: __dxlog_file15,
|
|
3439
|
-
L:
|
|
3672
|
+
L: 143,
|
|
3440
3673
|
S: this,
|
|
3441
3674
|
C: (f, a) => f(...a)
|
|
3442
3675
|
});
|
|
@@ -3461,7 +3694,7 @@ var LibDataChannelTransport = class {
|
|
|
3461
3694
|
err
|
|
3462
3695
|
}, {
|
|
3463
3696
|
F: __dxlog_file15,
|
|
3464
|
-
L:
|
|
3697
|
+
L: 163,
|
|
3465
3698
|
S: this,
|
|
3466
3699
|
C: (f, a) => f(...a)
|
|
3467
3700
|
});
|
|
@@ -3498,7 +3731,7 @@ var LibDataChannelTransport = class {
|
|
|
3498
3731
|
peer
|
|
3499
3732
|
}, {
|
|
3500
3733
|
F: __dxlog_file15,
|
|
3501
|
-
L:
|
|
3734
|
+
L: 198,
|
|
3502
3735
|
S: this,
|
|
3503
3736
|
C: (f, a) => f(...a)
|
|
3504
3737
|
});
|
|
@@ -3526,7 +3759,7 @@ var LibDataChannelTransport = class {
|
|
|
3526
3759
|
err
|
|
3527
3760
|
}, {
|
|
3528
3761
|
F: __dxlog_file15,
|
|
3529
|
-
L:
|
|
3762
|
+
L: 209,
|
|
3530
3763
|
S: this,
|
|
3531
3764
|
C: (f, a) => f(...a)
|
|
3532
3765
|
});
|
|
@@ -3546,7 +3779,7 @@ var LibDataChannelTransport = class {
|
|
|
3546
3779
|
err
|
|
3547
3780
|
}, {
|
|
3548
3781
|
F: __dxlog_file15,
|
|
3549
|
-
L:
|
|
3782
|
+
L: 220,
|
|
3550
3783
|
S: this,
|
|
3551
3784
|
C: (f, a) => f(...a)
|
|
3552
3785
|
});
|
|
@@ -3565,7 +3798,7 @@ var LibDataChannelTransport = class {
|
|
|
3565
3798
|
signal
|
|
3566
3799
|
}, {
|
|
3567
3800
|
F: __dxlog_file15,
|
|
3568
|
-
L:
|
|
3801
|
+
L: 231,
|
|
3569
3802
|
S: this,
|
|
3570
3803
|
C: (f, a) => f(...a)
|
|
3571
3804
|
});
|
|
@@ -3574,10 +3807,50 @@ var LibDataChannelTransport = class {
|
|
|
3574
3807
|
}).catch((err) => {
|
|
3575
3808
|
import_log14.log.catch(err, void 0, {
|
|
3576
3809
|
F: __dxlog_file15,
|
|
3577
|
-
L:
|
|
3810
|
+
L: 236,
|
|
3811
|
+
S: this,
|
|
3812
|
+
C: (f, a) => f(...a)
|
|
3813
|
+
});
|
|
3814
|
+
});
|
|
3815
|
+
}
|
|
3816
|
+
async getDetails() {
|
|
3817
|
+
return this._peer.then(async (peer) => {
|
|
3818
|
+
const cp = await peer.getSelectedCandidatePair();
|
|
3819
|
+
if (!cp) {
|
|
3820
|
+
return "unavailable";
|
|
3821
|
+
}
|
|
3822
|
+
return `${cp.remote.address}:${cp.remote.port}/${cp.remote.transportType} ${cp.remote.type}`;
|
|
3823
|
+
}).catch((err) => {
|
|
3824
|
+
import_log14.log.catch(err, void 0, {
|
|
3825
|
+
F: __dxlog_file15,
|
|
3826
|
+
L: 250,
|
|
3578
3827
|
S: this,
|
|
3579
3828
|
C: (f, a) => f(...a)
|
|
3580
3829
|
});
|
|
3830
|
+
return "unavailable";
|
|
3831
|
+
});
|
|
3832
|
+
}
|
|
3833
|
+
async getStats() {
|
|
3834
|
+
return this._peer.then((peer) => {
|
|
3835
|
+
return {
|
|
3836
|
+
bytesSent: peer.bytesSent(),
|
|
3837
|
+
bytesReceived: peer.bytesReceived(),
|
|
3838
|
+
packetsSent: 0,
|
|
3839
|
+
packetsReceived: 0
|
|
3840
|
+
};
|
|
3841
|
+
}).catch((err) => {
|
|
3842
|
+
import_log14.log.catch(err, void 0, {
|
|
3843
|
+
F: __dxlog_file15,
|
|
3844
|
+
L: 266,
|
|
3845
|
+
S: this,
|
|
3846
|
+
C: (f, a) => f(...a)
|
|
3847
|
+
});
|
|
3848
|
+
return {
|
|
3849
|
+
bytesSent: 0,
|
|
3850
|
+
bytesReceived: 0,
|
|
3851
|
+
packetsSent: 0,
|
|
3852
|
+
packetsReceived: 0
|
|
3853
|
+
};
|
|
3581
3854
|
});
|
|
3582
3855
|
}
|
|
3583
3856
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
@@ -3689,13 +3962,29 @@ var TcpTransport = class {
|
|
|
3689
3962
|
host: "localhost"
|
|
3690
3963
|
});
|
|
3691
3964
|
}
|
|
3965
|
+
async getDetails() {
|
|
3966
|
+
if (this.options.initiator) {
|
|
3967
|
+
const { port: port2, address: address2 } = this._server?.address();
|
|
3968
|
+
return `LISTEN ${address2}:${port2}`;
|
|
3969
|
+
}
|
|
3970
|
+
const { port, address } = this._socket?.address();
|
|
3971
|
+
return `ACCEPT ${address}:${port}`;
|
|
3972
|
+
}
|
|
3973
|
+
async getStats() {
|
|
3974
|
+
return {
|
|
3975
|
+
bytesSent: 0,
|
|
3976
|
+
bytesReceived: 0,
|
|
3977
|
+
packetsSent: 0,
|
|
3978
|
+
packetsReceived: 0
|
|
3979
|
+
};
|
|
3980
|
+
}
|
|
3692
3981
|
_handleSocket(socket) {
|
|
3693
3982
|
(0, import_log15.log)("handling socket", {
|
|
3694
3983
|
remotePort: socket.remotePort,
|
|
3695
3984
|
localPort: socket.localPort
|
|
3696
3985
|
}, {
|
|
3697
3986
|
F: __dxlog_file16,
|
|
3698
|
-
L:
|
|
3987
|
+
L: 109,
|
|
3699
3988
|
S: this,
|
|
3700
3989
|
C: (f, a) => f(...a)
|
|
3701
3990
|
});
|
|
@@ -3707,7 +3996,7 @@ var TcpTransport = class {
|
|
|
3707
3996
|
port: this._socket?.remotePort
|
|
3708
3997
|
}, {
|
|
3709
3998
|
F: __dxlog_file16,
|
|
3710
|
-
L:
|
|
3999
|
+
L: 115,
|
|
3711
4000
|
S: this,
|
|
3712
4001
|
C: (f, a) => f(...a)
|
|
3713
4002
|
});
|
|
@@ -3726,8 +4015,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3726
4015
|
const teleport = new import_teleport.Teleport(params);
|
|
3727
4016
|
return {
|
|
3728
4017
|
stream: teleport.stream,
|
|
3729
|
-
open: async () => {
|
|
3730
|
-
await teleport.open();
|
|
4018
|
+
open: async (sessionId) => {
|
|
4019
|
+
await teleport.open(sessionId);
|
|
3731
4020
|
await onConnection(teleport);
|
|
3732
4021
|
},
|
|
3733
4022
|
close: async () => {
|
|
@@ -3768,4 +4057,4 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3768
4057
|
createSimplePeerTransportFactory,
|
|
3769
4058
|
createTeleportProtocolFactory
|
|
3770
4059
|
});
|
|
3771
|
-
//# sourceMappingURL=chunk-
|
|
4060
|
+
//# sourceMappingURL=chunk-YLQJ2ALQ.cjs.map
|