@dxos/network-manager 0.3.8 → 0.3.9-main.14901ff
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-H7XJ7HES.mjs → chunk-S2JHWVGQ.mjs} +325 -98
- package/dist/lib/browser/chunk-S2JHWVGQ.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 +3 -3
- package/dist/lib/node/{chunk-RBHZCZH4.cjs → chunk-3SCPMSHV.cjs} +328 -91
- package/dist/lib/node/chunk-3SCPMSHV.cjs.map +7 -0
- package/dist/lib/node/{chunk-XE5JOIGD.cjs → chunk-DMWORJG3.cjs} +13 -4
- package/dist/lib/node/chunk-DMWORJG3.cjs.map +7 -0
- package/dist/lib/node/{datachannel-53JZPGFA.cjs → datachannel-ABYQKZRC.cjs} +9 -9
- package/dist/lib/node/{datachannel-53JZPGFA.cjs.map → datachannel-ABYQKZRC.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 +21 -21
- 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/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 +4 -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 +27 -1
- package/src/swarm/connection.ts +40 -6
- package/src/transport/datachannel/rtc-peer-connection.ts +13 -1
- 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 +67 -3
- 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-H7XJ7HES.mjs.map +0 -7
- package/dist/lib/node/chunk-RBHZCZH4.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_3SCPMSHV_exports = {};
|
|
30
|
+
__export(chunk_3SCPMSHV_exports, {
|
|
31
31
|
Connection: () => Connection,
|
|
32
32
|
ConnectionLimiter: () => ConnectionLimiter,
|
|
33
33
|
ConnectionLog: () => ConnectionLog,
|
|
@@ -55,8 +55,8 @@ __export(chunk_RBHZCZH4_exports, {
|
|
|
55
55
|
createSimplePeerTransportFactory: () => createSimplePeerTransportFactory,
|
|
56
56
|
createTeleportProtocolFactory: () => createTeleportProtocolFactory
|
|
57
57
|
});
|
|
58
|
-
module.exports = __toCommonJS(
|
|
59
|
-
var
|
|
58
|
+
module.exports = __toCommonJS(chunk_3SCPMSHV_exports);
|
|
59
|
+
var import_chunk_DMWORJG3 = require("./chunk-DMWORJG3.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");
|
|
@@ -163,9 +163,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
163
163
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
164
164
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
165
165
|
}
|
|
166
|
-
var __dxlog_file = "/home/
|
|
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,14 +708,23 @@ 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);
|
|
681
724
|
_ts_decorate([
|
|
682
725
|
import_async.synchronized
|
|
683
726
|
], Connection.prototype, "close", null);
|
|
684
|
-
var __dxlog_file2 = "/home/
|
|
727
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
685
728
|
var SwarmMessage = import_protocols2.schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
686
729
|
var SwarmMessenger = class {
|
|
687
730
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -926,7 +969,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
926
969
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
927
970
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
928
971
|
}
|
|
929
|
-
var __dxlog_file3 = "/home/
|
|
972
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
930
973
|
var ConnectionDisplacedError = class extends import_protocols4.SystemError {
|
|
931
974
|
constructor() {
|
|
932
975
|
super("Connection displaced by remote initiator.");
|
|
@@ -1402,7 +1445,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1402
1445
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1403
1446
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1404
1447
|
}
|
|
1405
|
-
var __dxlog_file4 = "/home/
|
|
1448
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1406
1449
|
var INITIATION_DELAY = 100;
|
|
1407
1450
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1408
1451
|
var Swarm = class {
|
|
@@ -1887,7 +1930,7 @@ _ts_decorate3([
|
|
|
1887
1930
|
_ts_decorate3([
|
|
1888
1931
|
import_async2.synchronized
|
|
1889
1932
|
], Swarm.prototype, "goOnline", null);
|
|
1890
|
-
var __dxlog_file5 = "/home/
|
|
1933
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1891
1934
|
var SwarmMapper = class {
|
|
1892
1935
|
get peers() {
|
|
1893
1936
|
return Array.from(this._peers.values());
|
|
@@ -1950,7 +1993,7 @@ var SwarmMapper = class {
|
|
|
1950
1993
|
this._subscriptions.clear();
|
|
1951
1994
|
}
|
|
1952
1995
|
};
|
|
1953
|
-
var __dxlog_file6 = "/home/
|
|
1996
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1954
1997
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
1955
1998
|
var ConnectionLimiter = class {
|
|
1956
1999
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -2020,6 +2063,7 @@ var ConnectionLimiter = class {
|
|
|
2020
2063
|
this.resolveWaitingPromises.schedule();
|
|
2021
2064
|
}
|
|
2022
2065
|
};
|
|
2066
|
+
var CONNECTION_GC_THRESHOLD = 1e3 * 60 * 15;
|
|
2023
2067
|
var EventType;
|
|
2024
2068
|
(function(EventType2) {
|
|
2025
2069
|
EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
|
|
@@ -2057,25 +2101,39 @@ var ConnectionLog = class {
|
|
|
2057
2101
|
sessionId: connection.sessionId,
|
|
2058
2102
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
2059
2103
|
protocolExtensions: [],
|
|
2060
|
-
events: []
|
|
2104
|
+
events: [],
|
|
2105
|
+
lastUpdate: /* @__PURE__ */ new Date()
|
|
2061
2106
|
};
|
|
2062
2107
|
info.connections.push(connectionInfo);
|
|
2063
2108
|
this.update.emit();
|
|
2064
|
-
connection.stateChanged.on((state) => {
|
|
2109
|
+
connection.stateChanged.on(async (state) => {
|
|
2065
2110
|
connectionInfo.state = state;
|
|
2066
2111
|
connectionInfo.closeReason = connection.closeReason;
|
|
2112
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
2067
2113
|
connectionInfo.events.push({
|
|
2068
2114
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
2069
2115
|
newState: state
|
|
2070
2116
|
});
|
|
2117
|
+
if (state === ConnectionState.CONNECTED) {
|
|
2118
|
+
const details = await connection.transport?.getDetails();
|
|
2119
|
+
connectionInfo.transportDetails = details;
|
|
2120
|
+
}
|
|
2071
2121
|
this.update.emit();
|
|
2072
2122
|
});
|
|
2073
2123
|
connection.protocol?.stats?.on((stats) => {
|
|
2074
2124
|
connectionInfo.readBufferSize = stats.readBufferSize;
|
|
2075
2125
|
connectionInfo.writeBufferSize = stats.writeBufferSize;
|
|
2076
2126
|
connectionInfo.streams = stats.channels;
|
|
2127
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
2077
2128
|
this.update.emit();
|
|
2078
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
|
+
});
|
|
2136
|
+
gcSwarm(info);
|
|
2079
2137
|
});
|
|
2080
2138
|
}
|
|
2081
2139
|
leftSwarm(swarm) {
|
|
@@ -2083,7 +2141,12 @@ var ConnectionLog = class {
|
|
|
2083
2141
|
this.update.emit();
|
|
2084
2142
|
}
|
|
2085
2143
|
};
|
|
2086
|
-
var
|
|
2144
|
+
var gcSwarm = (swarm) => {
|
|
2145
|
+
swarm.connections = swarm.connections?.filter((connection) => {
|
|
2146
|
+
return connection.lastUpdate ? Date.now() - connection.lastUpdate.getTime() < CONNECTION_GC_THRESHOLD : true;
|
|
2147
|
+
});
|
|
2148
|
+
};
|
|
2149
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2087
2150
|
var NetworkManager = class {
|
|
2088
2151
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
2089
2152
|
this._swarms = new import_util6.ComplexMap(import_keys8.PublicKey.hash);
|
|
@@ -2313,7 +2376,7 @@ var NetworkManager = class {
|
|
|
2313
2376
|
this.connectionStateChanged.emit(this._connectionState);
|
|
2314
2377
|
}
|
|
2315
2378
|
};
|
|
2316
|
-
var __dxlog_file8 = "/home/
|
|
2379
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2317
2380
|
var FullyConnectedTopology = class {
|
|
2318
2381
|
toString() {
|
|
2319
2382
|
return "FullyConnectedTopology";
|
|
@@ -2351,7 +2414,7 @@ var FullyConnectedTopology = class {
|
|
|
2351
2414
|
async destroy() {
|
|
2352
2415
|
}
|
|
2353
2416
|
};
|
|
2354
|
-
var __dxlog_file9 = "/home/
|
|
2417
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2355
2418
|
var MMSTTopology = class {
|
|
2356
2419
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2357
2420
|
this._sampleCollected = false;
|
|
@@ -2456,7 +2519,7 @@ var MMSTTopology = class {
|
|
|
2456
2519
|
}
|
|
2457
2520
|
};
|
|
2458
2521
|
var sortByXorDistance = (keys, reference) => keys.sort((a, b) => import_xor_distance.default.gt((0, import_xor_distance.default)(a.asBuffer(), reference.asBuffer()), (0, import_xor_distance.default)(b.asBuffer(), reference.asBuffer())));
|
|
2459
|
-
var __dxlog_file10 = "/home/
|
|
2522
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2460
2523
|
var StarTopology = class {
|
|
2461
2524
|
constructor(_centralPeer) {
|
|
2462
2525
|
this._centralPeer = _centralPeer;
|
|
@@ -2558,7 +2621,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2558
2621
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2559
2622
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2560
2623
|
}
|
|
2561
|
-
var __dxlog_file11 = "/home/
|
|
2624
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2562
2625
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2563
2626
|
var createStreamDelay = (delay) => {
|
|
2564
2627
|
return new import_node_stream.Transform({
|
|
@@ -2720,6 +2783,17 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2720
2783
|
this._remote.wake(remoteId);
|
|
2721
2784
|
}
|
|
2722
2785
|
}
|
|
2786
|
+
async getDetails() {
|
|
2787
|
+
return this._instanceId.toHex();
|
|
2788
|
+
}
|
|
2789
|
+
async getStats() {
|
|
2790
|
+
return {
|
|
2791
|
+
bytesSent: 0,
|
|
2792
|
+
bytesReceived: 0,
|
|
2793
|
+
packetsSent: 0,
|
|
2794
|
+
packetsReceived: 0
|
|
2795
|
+
};
|
|
2796
|
+
}
|
|
2723
2797
|
};
|
|
2724
2798
|
_ts_decorate4([
|
|
2725
2799
|
import_log10.logInfo
|
|
@@ -2737,10 +2811,10 @@ var TransportKind;
|
|
|
2737
2811
|
})(TransportKind || (TransportKind = {}));
|
|
2738
2812
|
var wrtc = null;
|
|
2739
2813
|
try {
|
|
2740
|
-
wrtc = (0,
|
|
2814
|
+
wrtc = (0, import_chunk_DMWORJG3.__require)("@koush/wrtc");
|
|
2741
2815
|
} catch {
|
|
2742
2816
|
}
|
|
2743
|
-
var __dxlog_file12 = "/home/
|
|
2817
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2744
2818
|
var SimplePeerTransport = class {
|
|
2745
2819
|
constructor(params) {
|
|
2746
2820
|
this.params = params;
|
|
@@ -2808,12 +2882,20 @@ var SimplePeerTransport = class {
|
|
|
2808
2882
|
if (err.errorDetail === "sctp-failure") {
|
|
2809
2883
|
this.errors.raise(new import_protocols7.ConnectionResetError("sctp-failure from RTCError", err));
|
|
2810
2884
|
} else {
|
|
2885
|
+
import_log11.log.info("unknown RTCError", {
|
|
2886
|
+
err
|
|
2887
|
+
}, {
|
|
2888
|
+
F: __dxlog_file12,
|
|
2889
|
+
L: 74,
|
|
2890
|
+
S: this,
|
|
2891
|
+
C: (f, a) => f(...a)
|
|
2892
|
+
});
|
|
2811
2893
|
this.errors.raise(new import_protocols7.UnknownProtocolError("unknown RTCError", err));
|
|
2812
2894
|
}
|
|
2813
2895
|
} else if ("code" in err) {
|
|
2814
2896
|
import_log11.log.info("simple-peer error", err, {
|
|
2815
2897
|
F: __dxlog_file12,
|
|
2816
|
-
L:
|
|
2898
|
+
L: 79,
|
|
2817
2899
|
S: this,
|
|
2818
2900
|
C: (f, a) => f(...a)
|
|
2819
2901
|
});
|
|
@@ -2821,10 +2903,12 @@ var SimplePeerTransport = class {
|
|
|
2821
2903
|
case "ERR_WEBRTC_SUPPORT":
|
|
2822
2904
|
this.errors.raise(new import_protocols7.ProtocolError("WebRTC not supported", err));
|
|
2823
2905
|
break;
|
|
2906
|
+
case "ERR_SIGNALING":
|
|
2907
|
+
this.errors.raise(new import_protocols7.ConnectivityError("signaling failure", err));
|
|
2908
|
+
break;
|
|
2824
2909
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
2825
2910
|
case "ERR_DATA_CHANNEL":
|
|
2826
2911
|
case "ERR_CONNECTION_FAILURE":
|
|
2827
|
-
case "ERR_SIGNALING":
|
|
2828
2912
|
this.errors.raise(new import_protocols7.ConnectivityError("unknown communication failure", err));
|
|
2829
2913
|
break;
|
|
2830
2914
|
case "ERR_CREATE_OFFER":
|
|
@@ -2841,7 +2925,7 @@ var SimplePeerTransport = class {
|
|
|
2841
2925
|
} else {
|
|
2842
2926
|
import_log11.log.info("unknown peer connection error", err, {
|
|
2843
2927
|
F: __dxlog_file12,
|
|
2844
|
-
L:
|
|
2928
|
+
L: 105,
|
|
2845
2929
|
S: this,
|
|
2846
2930
|
C: (f, a) => f(...a)
|
|
2847
2931
|
});
|
|
@@ -2852,10 +2936,10 @@ var SimplePeerTransport = class {
|
|
|
2852
2936
|
this._peer._pc.getStats().then((stats) => {
|
|
2853
2937
|
import_log11.log.info("report after webrtc error", {
|
|
2854
2938
|
config: this.params.webrtcConfig,
|
|
2855
|
-
stats
|
|
2939
|
+
stats: Object.fromEntries(stats.entries())
|
|
2856
2940
|
}, {
|
|
2857
2941
|
F: __dxlog_file12,
|
|
2858
|
-
L:
|
|
2942
|
+
L: 113,
|
|
2859
2943
|
S: this,
|
|
2860
2944
|
C: (f, a) => f(...a)
|
|
2861
2945
|
});
|
|
@@ -2864,7 +2948,7 @@ var SimplePeerTransport = class {
|
|
|
2864
2948
|
} catch (err2) {
|
|
2865
2949
|
import_log11.log.catch(err2, void 0, {
|
|
2866
2950
|
F: __dxlog_file12,
|
|
2867
|
-
L:
|
|
2951
|
+
L: 120,
|
|
2868
2952
|
S: this,
|
|
2869
2953
|
C: (f, a) => f(...a)
|
|
2870
2954
|
});
|
|
@@ -2875,15 +2959,68 @@ var SimplePeerTransport = class {
|
|
|
2875
2959
|
id: this._instanceId
|
|
2876
2960
|
}), {
|
|
2877
2961
|
F: __dxlog_file12,
|
|
2878
|
-
L:
|
|
2962
|
+
L: 126,
|
|
2879
2963
|
S: this,
|
|
2880
2964
|
C: (f, a) => f(...a)
|
|
2881
2965
|
});
|
|
2882
2966
|
}
|
|
2967
|
+
async getStats() {
|
|
2968
|
+
const stats = await this._getStats();
|
|
2969
|
+
if (!stats) {
|
|
2970
|
+
return {
|
|
2971
|
+
bytesSent: 0,
|
|
2972
|
+
bytesReceived: 0,
|
|
2973
|
+
packetsSent: 0,
|
|
2974
|
+
packetsReceived: 0,
|
|
2975
|
+
rawStats: {}
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
return {
|
|
2979
|
+
bytesSent: stats.transport.bytesSent,
|
|
2980
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
2981
|
+
packetsSent: stats.transport.messagesSent,
|
|
2982
|
+
packetsReceived: stats.transport.messagesReceived,
|
|
2983
|
+
rawStats: stats.raw
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
async _getStats() {
|
|
2987
|
+
if (typeof this._peer?._pc?.getStats !== "function") {
|
|
2988
|
+
return null;
|
|
2989
|
+
}
|
|
2990
|
+
return await this._peer._pc.getStats().then((stats) => {
|
|
2991
|
+
const statsEntries = Array.from(stats.entries());
|
|
2992
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
2993
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
2994
|
+
let selectedCandidatePair;
|
|
2995
|
+
let remoteCandidate;
|
|
2996
|
+
if (candidatePair.length > 0) {
|
|
2997
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
2998
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
2999
|
+
}
|
|
3000
|
+
return {
|
|
3001
|
+
datachannel: statsEntries.filter((s) => s[1].type === "data-channel")[0][1],
|
|
3002
|
+
transport,
|
|
3003
|
+
selectedCandidatePair,
|
|
3004
|
+
remoteCandidate,
|
|
3005
|
+
raw: Object.fromEntries(stats.entries())
|
|
3006
|
+
};
|
|
3007
|
+
});
|
|
3008
|
+
}
|
|
3009
|
+
async getDetails() {
|
|
3010
|
+
const stats = await this._getStats();
|
|
3011
|
+
const rc = stats?.remoteCandidate;
|
|
3012
|
+
if (!rc) {
|
|
3013
|
+
return "unavailable";
|
|
3014
|
+
}
|
|
3015
|
+
if (rc.relay) {
|
|
3016
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for XXX ${rc.candidateType}`;
|
|
3017
|
+
}
|
|
3018
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
3019
|
+
}
|
|
2883
3020
|
async destroy() {
|
|
2884
3021
|
(0, import_log11.log)("closing...", void 0, {
|
|
2885
3022
|
F: __dxlog_file12,
|
|
2886
|
-
L:
|
|
3023
|
+
L: 189,
|
|
2887
3024
|
S: this,
|
|
2888
3025
|
C: (f, a) => f(...a)
|
|
2889
3026
|
});
|
|
@@ -2893,10 +3030,11 @@ var SimplePeerTransport = class {
|
|
|
2893
3030
|
this._closed = true;
|
|
2894
3031
|
this._disconnectStreams();
|
|
2895
3032
|
this._peer.destroy();
|
|
3033
|
+
this._closed = true;
|
|
2896
3034
|
this.closed.emit();
|
|
2897
3035
|
(0, import_log11.log)("closed", void 0, {
|
|
2898
3036
|
F: __dxlog_file12,
|
|
2899
|
-
L:
|
|
3037
|
+
L: 198,
|
|
2900
3038
|
S: this,
|
|
2901
3039
|
C: (f, a) => f(...a)
|
|
2902
3040
|
});
|
|
@@ -2920,7 +3058,7 @@ var createSimplePeerTransportFactory = (webrtcConfig) => ({
|
|
|
2920
3058
|
webrtcConfig
|
|
2921
3059
|
})
|
|
2922
3060
|
});
|
|
2923
|
-
var __dxlog_file13 = "/home/
|
|
3061
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
2924
3062
|
var SimplePeerTransportService = class {
|
|
2925
3063
|
constructor(_webrtcConfig) {
|
|
2926
3064
|
this._webrtcConfig = _webrtcConfig;
|
|
@@ -3002,7 +3140,7 @@ var SimplePeerTransportService = class {
|
|
|
3002
3140
|
async sendSignal({ proxyId, signal }) {
|
|
3003
3141
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3004
3142
|
F: __dxlog_file13,
|
|
3005
|
-
L:
|
|
3143
|
+
L: 116,
|
|
3006
3144
|
S: this,
|
|
3007
3145
|
A: [
|
|
3008
3146
|
"this.transports.has(proxyId)",
|
|
@@ -3011,18 +3149,46 @@ var SimplePeerTransportService = class {
|
|
|
3011
3149
|
});
|
|
3012
3150
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
3013
3151
|
}
|
|
3152
|
+
async getDetails({ proxyId }) {
|
|
3153
|
+
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3154
|
+
F: __dxlog_file13,
|
|
3155
|
+
L: 121,
|
|
3156
|
+
S: this,
|
|
3157
|
+
A: [
|
|
3158
|
+
"this.transports.has(proxyId)",
|
|
3159
|
+
""
|
|
3160
|
+
]
|
|
3161
|
+
});
|
|
3162
|
+
return {
|
|
3163
|
+
details: await this.transports.get(proxyId).transport.getDetails()
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
async getStats({ proxyId }) {
|
|
3167
|
+
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3168
|
+
F: __dxlog_file13,
|
|
3169
|
+
L: 126,
|
|
3170
|
+
S: this,
|
|
3171
|
+
A: [
|
|
3172
|
+
"this.transports.has(proxyId)",
|
|
3173
|
+
""
|
|
3174
|
+
]
|
|
3175
|
+
});
|
|
3176
|
+
return {
|
|
3177
|
+
stats: await this.transports.get(proxyId).transport.getStats()
|
|
3178
|
+
};
|
|
3179
|
+
}
|
|
3014
3180
|
async sendData({ proxyId, payload }) {
|
|
3015
3181
|
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
3016
3182
|
import_log12.log.debug("transport is closed", void 0, {
|
|
3017
3183
|
F: __dxlog_file13,
|
|
3018
|
-
L:
|
|
3184
|
+
L: 132,
|
|
3019
3185
|
S: this,
|
|
3020
3186
|
C: (f, a) => f(...a)
|
|
3021
3187
|
});
|
|
3022
3188
|
}
|
|
3023
3189
|
(0, import_invariant11.invariant)(this.transports.has(proxyId), void 0, {
|
|
3024
3190
|
F: __dxlog_file13,
|
|
3025
|
-
L:
|
|
3191
|
+
L: 134,
|
|
3026
3192
|
S: this,
|
|
3027
3193
|
A: [
|
|
3028
3194
|
"this.transports.has(proxyId)",
|
|
@@ -3045,13 +3211,13 @@ var SimplePeerTransportService = class {
|
|
|
3045
3211
|
}
|
|
3046
3212
|
(0, import_log12.log)("Closed.", void 0, {
|
|
3047
3213
|
F: __dxlog_file13,
|
|
3048
|
-
L:
|
|
3214
|
+
L: 150,
|
|
3049
3215
|
S: this,
|
|
3050
3216
|
C: (f, a) => f(...a)
|
|
3051
3217
|
});
|
|
3052
3218
|
}
|
|
3053
3219
|
};
|
|
3054
|
-
var __dxlog_file14 = "/home/
|
|
3220
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3055
3221
|
var RESP_MIN_THRESHOLD = 500;
|
|
3056
3222
|
var TIMEOUT_THRESHOLD = 10;
|
|
3057
3223
|
var SimplePeerTransportProxy = class {
|
|
@@ -3172,6 +3338,16 @@ var SimplePeerTransportProxy = class {
|
|
|
3172
3338
|
signal
|
|
3173
3339
|
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3174
3340
|
}
|
|
3341
|
+
async getDetails() {
|
|
3342
|
+
return (await this._params.bridgeService.getDetails({
|
|
3343
|
+
proxyId: this._proxyId
|
|
3344
|
+
})).details;
|
|
3345
|
+
}
|
|
3346
|
+
async getStats() {
|
|
3347
|
+
return (await this._params.bridgeService.getStats({
|
|
3348
|
+
proxyId: this._proxyId
|
|
3349
|
+
})).stats;
|
|
3350
|
+
}
|
|
3175
3351
|
// TODO(burdon): Move open from constructor.
|
|
3176
3352
|
async destroy() {
|
|
3177
3353
|
await this._ctx.dispose();
|
|
@@ -3186,7 +3362,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3186
3362
|
} catch (err) {
|
|
3187
3363
|
import_log13.log.catch(err, void 0, {
|
|
3188
3364
|
F: __dxlog_file14,
|
|
3189
|
-
L:
|
|
3365
|
+
L: 168,
|
|
3190
3366
|
S: this,
|
|
3191
3367
|
C: (f, a) => f(...a)
|
|
3192
3368
|
});
|
|
@@ -3222,7 +3398,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3222
3398
|
createTransport(options) {
|
|
3223
3399
|
(0, import_invariant12.invariant)(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3224
3400
|
F: __dxlog_file14,
|
|
3225
|
-
L:
|
|
3401
|
+
L: 205,
|
|
3226
3402
|
S: this,
|
|
3227
3403
|
A: [
|
|
3228
3404
|
"this._bridgeService",
|
|
@@ -3264,7 +3440,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3264
3440
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3265
3441
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3266
3442
|
}
|
|
3267
|
-
var __dxlog_file15 = "/home/
|
|
3443
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3268
3444
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3269
3445
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3270
3446
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -3279,7 +3455,7 @@ var LibDataChannelTransport = class {
|
|
|
3279
3455
|
this._readyForCandidates = new import_async11.Trigger();
|
|
3280
3456
|
this._writeCallback = null;
|
|
3281
3457
|
this._peer = (async () => {
|
|
3282
|
-
const { RTCPeerConnection: PeerConnection } = await import("./datachannel-
|
|
3458
|
+
const { RTCPeerConnection: PeerConnection } = await import("./datachannel-ABYQKZRC.cjs");
|
|
3283
3459
|
if (this._closed) {
|
|
3284
3460
|
this.errors.raise(new Error("connection already closed"));
|
|
3285
3461
|
}
|
|
@@ -3417,16 +3593,21 @@ var LibDataChannelTransport = class {
|
|
|
3417
3593
|
const duplex = new import_stream.Duplex({
|
|
3418
3594
|
read: () => {
|
|
3419
3595
|
},
|
|
3420
|
-
write: (chunk, encoding, callback) => {
|
|
3596
|
+
write: async (chunk, encoding, callback) => {
|
|
3421
3597
|
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3422
3598
|
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3423
3599
|
}
|
|
3424
|
-
|
|
3600
|
+
try {
|
|
3601
|
+
dataChannel.send(chunk);
|
|
3602
|
+
} catch (err) {
|
|
3603
|
+
this.errors.raise(err);
|
|
3604
|
+
await this._close();
|
|
3605
|
+
}
|
|
3425
3606
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3426
3607
|
if (this._writeCallback !== null) {
|
|
3427
3608
|
import_log14.log.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3428
3609
|
F: __dxlog_file15,
|
|
3429
|
-
L:
|
|
3610
|
+
L: 143,
|
|
3430
3611
|
S: this,
|
|
3431
3612
|
C: (f, a) => f(...a)
|
|
3432
3613
|
});
|
|
@@ -3451,7 +3632,7 @@ var LibDataChannelTransport = class {
|
|
|
3451
3632
|
err
|
|
3452
3633
|
}, {
|
|
3453
3634
|
F: __dxlog_file15,
|
|
3454
|
-
L:
|
|
3635
|
+
L: 163,
|
|
3455
3636
|
S: this,
|
|
3456
3637
|
C: (f, a) => f(...a)
|
|
3457
3638
|
});
|
|
@@ -3488,7 +3669,7 @@ var LibDataChannelTransport = class {
|
|
|
3488
3669
|
peer
|
|
3489
3670
|
}, {
|
|
3490
3671
|
F: __dxlog_file15,
|
|
3491
|
-
L:
|
|
3672
|
+
L: 198,
|
|
3492
3673
|
S: this,
|
|
3493
3674
|
C: (f, a) => f(...a)
|
|
3494
3675
|
});
|
|
@@ -3516,7 +3697,7 @@ var LibDataChannelTransport = class {
|
|
|
3516
3697
|
err
|
|
3517
3698
|
}, {
|
|
3518
3699
|
F: __dxlog_file15,
|
|
3519
|
-
L:
|
|
3700
|
+
L: 209,
|
|
3520
3701
|
S: this,
|
|
3521
3702
|
C: (f, a) => f(...a)
|
|
3522
3703
|
});
|
|
@@ -3536,7 +3717,7 @@ var LibDataChannelTransport = class {
|
|
|
3536
3717
|
err
|
|
3537
3718
|
}, {
|
|
3538
3719
|
F: __dxlog_file15,
|
|
3539
|
-
L:
|
|
3720
|
+
L: 220,
|
|
3540
3721
|
S: this,
|
|
3541
3722
|
C: (f, a) => f(...a)
|
|
3542
3723
|
});
|
|
@@ -3555,7 +3736,7 @@ var LibDataChannelTransport = class {
|
|
|
3555
3736
|
signal
|
|
3556
3737
|
}, {
|
|
3557
3738
|
F: __dxlog_file15,
|
|
3558
|
-
L:
|
|
3739
|
+
L: 231,
|
|
3559
3740
|
S: this,
|
|
3560
3741
|
C: (f, a) => f(...a)
|
|
3561
3742
|
});
|
|
@@ -3564,10 +3745,50 @@ var LibDataChannelTransport = class {
|
|
|
3564
3745
|
}).catch((err) => {
|
|
3565
3746
|
import_log14.log.catch(err, void 0, {
|
|
3566
3747
|
F: __dxlog_file15,
|
|
3567
|
-
L:
|
|
3748
|
+
L: 236,
|
|
3749
|
+
S: this,
|
|
3750
|
+
C: (f, a) => f(...a)
|
|
3751
|
+
});
|
|
3752
|
+
});
|
|
3753
|
+
}
|
|
3754
|
+
async getDetails() {
|
|
3755
|
+
return this._peer.then(async (peer) => {
|
|
3756
|
+
const cp = await peer.getSelectedCandidatePair();
|
|
3757
|
+
if (!cp) {
|
|
3758
|
+
return "unavailable";
|
|
3759
|
+
}
|
|
3760
|
+
return `${cp.remote.address}:${cp.remote.port}/${cp.remote.transportType} ${cp.remote.type}`;
|
|
3761
|
+
}).catch((err) => {
|
|
3762
|
+
import_log14.log.catch(err, void 0, {
|
|
3763
|
+
F: __dxlog_file15,
|
|
3764
|
+
L: 250,
|
|
3568
3765
|
S: this,
|
|
3569
3766
|
C: (f, a) => f(...a)
|
|
3570
3767
|
});
|
|
3768
|
+
return "unavailable";
|
|
3769
|
+
});
|
|
3770
|
+
}
|
|
3771
|
+
async getStats() {
|
|
3772
|
+
return this._peer.then((peer) => {
|
|
3773
|
+
return {
|
|
3774
|
+
bytesSent: peer.bytesSent(),
|
|
3775
|
+
bytesReceived: peer.bytesReceived(),
|
|
3776
|
+
packetsSent: 0,
|
|
3777
|
+
packetsReceived: 0
|
|
3778
|
+
};
|
|
3779
|
+
}).catch((err) => {
|
|
3780
|
+
import_log14.log.catch(err, void 0, {
|
|
3781
|
+
F: __dxlog_file15,
|
|
3782
|
+
L: 266,
|
|
3783
|
+
S: this,
|
|
3784
|
+
C: (f, a) => f(...a)
|
|
3785
|
+
});
|
|
3786
|
+
return {
|
|
3787
|
+
bytesSent: 0,
|
|
3788
|
+
bytesReceived: 0,
|
|
3789
|
+
packetsSent: 0,
|
|
3790
|
+
packetsReceived: 0
|
|
3791
|
+
};
|
|
3571
3792
|
});
|
|
3572
3793
|
}
|
|
3573
3794
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
@@ -3587,7 +3808,7 @@ var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
|
3587
3808
|
webrtcConfig
|
|
3588
3809
|
})
|
|
3589
3810
|
});
|
|
3590
|
-
var __dxlog_file16 = "/home/
|
|
3811
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/tcp-transport.ts";
|
|
3591
3812
|
var TcpTransportFactory = {
|
|
3592
3813
|
createTransport: (params) => new TcpTransport(params)
|
|
3593
3814
|
};
|
|
@@ -3679,13 +3900,29 @@ var TcpTransport = class {
|
|
|
3679
3900
|
host: "localhost"
|
|
3680
3901
|
});
|
|
3681
3902
|
}
|
|
3903
|
+
async getDetails() {
|
|
3904
|
+
if (this.options.initiator) {
|
|
3905
|
+
const { port: port2, address: address2 } = this._server?.address();
|
|
3906
|
+
return `LISTEN ${address2}:${port2}`;
|
|
3907
|
+
}
|
|
3908
|
+
const { port, address } = this._socket?.address();
|
|
3909
|
+
return `ACCEPT ${address}:${port}`;
|
|
3910
|
+
}
|
|
3911
|
+
async getStats() {
|
|
3912
|
+
return {
|
|
3913
|
+
bytesSent: 0,
|
|
3914
|
+
bytesReceived: 0,
|
|
3915
|
+
packetsSent: 0,
|
|
3916
|
+
packetsReceived: 0
|
|
3917
|
+
};
|
|
3918
|
+
}
|
|
3682
3919
|
_handleSocket(socket) {
|
|
3683
3920
|
(0, import_log15.log)("handling socket", {
|
|
3684
3921
|
remotePort: socket.remotePort,
|
|
3685
3922
|
localPort: socket.localPort
|
|
3686
3923
|
}, {
|
|
3687
3924
|
F: __dxlog_file16,
|
|
3688
|
-
L:
|
|
3925
|
+
L: 109,
|
|
3689
3926
|
S: this,
|
|
3690
3927
|
C: (f, a) => f(...a)
|
|
3691
3928
|
});
|
|
@@ -3697,7 +3934,7 @@ var TcpTransport = class {
|
|
|
3697
3934
|
port: this._socket?.remotePort
|
|
3698
3935
|
}, {
|
|
3699
3936
|
F: __dxlog_file16,
|
|
3700
|
-
L:
|
|
3937
|
+
L: 115,
|
|
3701
3938
|
S: this,
|
|
3702
3939
|
C: (f, a) => f(...a)
|
|
3703
3940
|
});
|
|
@@ -3716,8 +3953,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3716
3953
|
const teleport = new import_teleport.Teleport(params);
|
|
3717
3954
|
return {
|
|
3718
3955
|
stream: teleport.stream,
|
|
3719
|
-
open: async () => {
|
|
3720
|
-
await teleport.open();
|
|
3956
|
+
open: async (sessionId) => {
|
|
3957
|
+
await teleport.open(sessionId);
|
|
3721
3958
|
await onConnection(teleport);
|
|
3722
3959
|
},
|
|
3723
3960
|
close: async () => {
|
|
@@ -3758,4 +3995,4 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3758
3995
|
createSimplePeerTransportFactory,
|
|
3759
3996
|
createTeleportProtocolFactory
|
|
3760
3997
|
});
|
|
3761
|
-
//# sourceMappingURL=chunk-
|
|
3998
|
+
//# sourceMappingURL=chunk-3SCPMSHV.cjs.map
|