@dxos/network-manager 0.3.9-main.e6215fc → 0.3.9-main.ef334cd
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-HJ6JLRZM.mjs → chunk-7JESB3AJ.mjs} +160 -70
- package/dist/lib/browser/chunk-7JESB3AJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -11
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -2
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-XZF4MAFB.cjs → chunk-Y2B5BDRH.cjs} +164 -72
- package/dist/lib/node/chunk-Y2B5BDRH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +27 -36
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +18 -19
- package/dist/lib/node/testing/index.cjs.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/index.d.ts +0 -1
- package/dist/types/src/transport/index.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts +1 -0
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/topology/mmst-topology.ts +34 -6
- package/src/transport/index.ts +0 -1
- package/src/transport/libdatachannel-transport.ts +76 -34
- package/src/transport/simplepeer-transport.ts +4 -5
- package/dist/lib/browser/chunk-HJ6JLRZM.mjs.map +0 -7
- package/dist/lib/browser/chunk-YERMWDRB.mjs +0 -24
- package/dist/lib/browser/chunk-YERMWDRB.mjs.map +0 -7
- package/dist/lib/browser/index.browser-O53CPVK3.mjs +0 -14
- package/dist/lib/browser/index.browser-O53CPVK3.mjs.map +0 -7
- package/dist/lib/node/chunk-JDKM4UPJ.cjs +0 -470
- package/dist/lib/node/chunk-JDKM4UPJ.cjs.map +0 -7
- package/dist/lib/node/chunk-XZF4MAFB.cjs.map +0 -7
- package/dist/lib/node/datachannel-3VTTIMR5.cjs +0 -35
- package/dist/lib/node/datachannel-3VTTIMR5.cjs.map +0 -7
- package/dist/types/src/transport/datachannel/index.browser.d.ts +0 -15
- package/dist/types/src/transport/datachannel/index.browser.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/index.d.ts +0 -8
- package/dist/types/src/transport/datachannel/index.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-data-channel.d.ts +0 -29
- package/dist/types/src/transport/datachannel/rtc-data-channel.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-events.d.ts +0 -9
- package/dist/types/src/transport/datachannel/rtc-events.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-ice-candidate.d.ts +0 -22
- package/dist/types/src/transport/datachannel/rtc-ice-candidate.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts +0 -54
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-peer-connection.test.d.ts +0 -2
- package/dist/types/src/transport/datachannel/rtc-peer-connection.test.d.ts.map +0 -1
- package/dist/types/src/transport/datachannel/rtc-session-description.d.ts +0 -10
- package/dist/types/src/transport/datachannel/rtc-session-description.d.ts.map +0 -1
- package/src/transport/datachannel/README.md +0 -2
- package/src/transport/datachannel/index.browser.ts +0 -8
- package/src/transport/datachannel/index.ts +0 -17
- package/src/transport/datachannel/rtc-data-channel.ts +0 -148
- package/src/transport/datachannel/rtc-events.ts +0 -23
- package/src/transport/datachannel/rtc-ice-candidate.ts +0 -54
- package/src/transport/datachannel/rtc-peer-connection.test.ts +0 -112
- package/src/transport/datachannel/rtc-peer-connection.ts +0 -355
- package/src/transport/datachannel/rtc-session-description.ts +0 -23
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
5
9
|
|
|
6
10
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
7
11
|
import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
@@ -2349,9 +2353,12 @@ import distance from "xor-distance";
|
|
|
2349
2353
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2350
2354
|
import { log as log8 } from "@dxos/log";
|
|
2351
2355
|
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2356
|
+
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2357
|
+
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2352
2358
|
var MMSTTopology = class {
|
|
2353
2359
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2354
2360
|
this._sampleCollected = false;
|
|
2361
|
+
this._lastAction = /* @__PURE__ */ new Date(0);
|
|
2355
2362
|
this._originateConnections = originateConnections;
|
|
2356
2363
|
this._maxPeers = maxPeers;
|
|
2357
2364
|
this._sampleSize = sampleSize;
|
|
@@ -2359,7 +2366,7 @@ var MMSTTopology = class {
|
|
|
2359
2366
|
init(controller) {
|
|
2360
2367
|
invariant8(!this._controller, "Already initialized", {
|
|
2361
2368
|
F: __dxlog_file9,
|
|
2362
|
-
L:
|
|
2369
|
+
L: 51,
|
|
2363
2370
|
S: this,
|
|
2364
2371
|
A: [
|
|
2365
2372
|
"!this._controller",
|
|
@@ -2371,7 +2378,7 @@ var MMSTTopology = class {
|
|
|
2371
2378
|
update() {
|
|
2372
2379
|
invariant8(this._controller, "Not initialized", {
|
|
2373
2380
|
F: __dxlog_file9,
|
|
2374
|
-
L:
|
|
2381
|
+
L: 56,
|
|
2375
2382
|
S: this,
|
|
2376
2383
|
A: [
|
|
2377
2384
|
"this._controller",
|
|
@@ -2382,7 +2389,7 @@ var MMSTTopology = class {
|
|
|
2382
2389
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
2383
2390
|
log8("Running the algorithm.", void 0, {
|
|
2384
2391
|
F: __dxlog_file9,
|
|
2385
|
-
L:
|
|
2392
|
+
L: 60,
|
|
2386
2393
|
S: this,
|
|
2387
2394
|
C: (f, a) => f(...a)
|
|
2388
2395
|
});
|
|
@@ -2393,7 +2400,7 @@ var MMSTTopology = class {
|
|
|
2393
2400
|
async onOffer(peer) {
|
|
2394
2401
|
invariant8(this._controller, "Not initialized", {
|
|
2395
2402
|
F: __dxlog_file9,
|
|
2396
|
-
L:
|
|
2403
|
+
L: 67,
|
|
2397
2404
|
S: this,
|
|
2398
2405
|
A: [
|
|
2399
2406
|
"this._controller",
|
|
@@ -2404,7 +2411,7 @@ var MMSTTopology = class {
|
|
|
2404
2411
|
const accept = connected.length < this._maxPeers;
|
|
2405
2412
|
log8(`Offer ${peer} accept=${accept}`, void 0, {
|
|
2406
2413
|
F: __dxlog_file9,
|
|
2407
|
-
L:
|
|
2414
|
+
L: 70,
|
|
2408
2415
|
S: this,
|
|
2409
2416
|
C: (f, a) => f(...a)
|
|
2410
2417
|
});
|
|
@@ -2415,7 +2422,7 @@ var MMSTTopology = class {
|
|
|
2415
2422
|
_runAlgorithm() {
|
|
2416
2423
|
invariant8(this._controller, "Not initialized", {
|
|
2417
2424
|
F: __dxlog_file9,
|
|
2418
|
-
L:
|
|
2425
|
+
L: 79,
|
|
2419
2426
|
S: this,
|
|
2420
2427
|
A: [
|
|
2421
2428
|
"this._controller",
|
|
@@ -2424,27 +2431,84 @@ var MMSTTopology = class {
|
|
|
2424
2431
|
});
|
|
2425
2432
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
2426
2433
|
if (connected.length > this._maxPeers) {
|
|
2434
|
+
log8(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
|
|
2435
|
+
F: __dxlog_file9,
|
|
2436
|
+
L: 85,
|
|
2437
|
+
S: this,
|
|
2438
|
+
C: (f, a) => f(...a)
|
|
2439
|
+
});
|
|
2427
2440
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
2428
|
-
|
|
2429
|
-
|
|
2441
|
+
invariant8(sorted.length === 0, void 0, {
|
|
2442
|
+
F: __dxlog_file9,
|
|
2443
|
+
L: 89,
|
|
2444
|
+
S: this,
|
|
2445
|
+
A: [
|
|
2446
|
+
"sorted.length === 0",
|
|
2447
|
+
""
|
|
2448
|
+
]
|
|
2449
|
+
});
|
|
2450
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2451
|
+
log8(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2430
2452
|
F: __dxlog_file9,
|
|
2431
|
-
L:
|
|
2453
|
+
L: 92,
|
|
2454
|
+
S: this,
|
|
2455
|
+
C: (f, a) => f(...a)
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2459
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2460
|
+
log8(`Disconnect ${peer}.`, void 0, {
|
|
2461
|
+
F: __dxlog_file9,
|
|
2462
|
+
L: 97,
|
|
2463
|
+
S: this,
|
|
2464
|
+
C: (f, a) => f(...a)
|
|
2465
|
+
});
|
|
2466
|
+
this._controller.disconnect(peer);
|
|
2467
|
+
}
|
|
2468
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2469
|
+
} else {
|
|
2470
|
+
log8("rate limited discconnect", void 0, {
|
|
2471
|
+
F: __dxlog_file9,
|
|
2472
|
+
L: 102,
|
|
2432
2473
|
S: this,
|
|
2433
2474
|
C: (f, a) => f(...a)
|
|
2434
2475
|
});
|
|
2435
|
-
this._controller.disconnect(peer);
|
|
2436
2476
|
}
|
|
2437
2477
|
} else if (connected.length < this._originateConnections) {
|
|
2478
|
+
log8(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
|
|
2479
|
+
F: __dxlog_file9,
|
|
2480
|
+
L: 106,
|
|
2481
|
+
S: this,
|
|
2482
|
+
C: (f, a) => f(...a)
|
|
2483
|
+
});
|
|
2438
2484
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
2439
2485
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
2440
|
-
|
|
2441
|
-
log8(`
|
|
2486
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2487
|
+
log8(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2442
2488
|
F: __dxlog_file9,
|
|
2443
|
-
L:
|
|
2489
|
+
L: 111,
|
|
2490
|
+
S: this,
|
|
2491
|
+
C: (f, a) => f(...a)
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2495
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2496
|
+
log8(`Connect ${peer}.`, void 0, {
|
|
2497
|
+
F: __dxlog_file9,
|
|
2498
|
+
L: 115,
|
|
2499
|
+
S: this,
|
|
2500
|
+
C: (f, a) => f(...a)
|
|
2501
|
+
});
|
|
2502
|
+
this._controller.connect(peer);
|
|
2503
|
+
}
|
|
2504
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2505
|
+
} else {
|
|
2506
|
+
log8("rate limited connect", void 0, {
|
|
2507
|
+
F: __dxlog_file9,
|
|
2508
|
+
L: 120,
|
|
2444
2509
|
S: this,
|
|
2445
2510
|
C: (f, a) => f(...a)
|
|
2446
2511
|
});
|
|
2447
|
-
this._controller.connect(peer);
|
|
2448
2512
|
}
|
|
2449
2513
|
}
|
|
2450
2514
|
}
|
|
@@ -2944,8 +3008,8 @@ var SimplePeerTransport = class {
|
|
|
2944
3008
|
return {
|
|
2945
3009
|
bytesSent: stats.transport.bytesSent,
|
|
2946
3010
|
bytesReceived: stats.transport.bytesReceived,
|
|
2947
|
-
packetsSent: stats.transport.
|
|
2948
|
-
packetsReceived: stats.transport.
|
|
3011
|
+
packetsSent: stats.transport.packetsSent,
|
|
3012
|
+
packetsReceived: stats.transport.packetsReceived,
|
|
2949
3013
|
rawStats: stats.raw
|
|
2950
3014
|
};
|
|
2951
3015
|
}
|
|
@@ -2978,8 +3042,8 @@ var SimplePeerTransport = class {
|
|
|
2978
3042
|
if (!rc) {
|
|
2979
3043
|
return "unavailable";
|
|
2980
3044
|
}
|
|
2981
|
-
if (rc.relay) {
|
|
2982
|
-
return `${rc.ip}:${rc.port}/${rc.protocol} relay for
|
|
3045
|
+
if (rc.candidateType === "relay") {
|
|
3046
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for ${rc.relatedAddress}:${rc.relatedPort}`;
|
|
2983
3047
|
}
|
|
2984
3048
|
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
2985
3049
|
}
|
|
@@ -2993,14 +3057,13 @@ var SimplePeerTransport = class {
|
|
|
2993
3057
|
if (this._closed) {
|
|
2994
3058
|
return;
|
|
2995
3059
|
}
|
|
2996
|
-
this._closed = true;
|
|
2997
3060
|
this._disconnectStreams();
|
|
2998
3061
|
this._peer.destroy();
|
|
2999
3062
|
this._closed = true;
|
|
3000
3063
|
this.closed.emit();
|
|
3001
3064
|
log11("closed", void 0, {
|
|
3002
3065
|
F: __dxlog_file12,
|
|
3003
|
-
L:
|
|
3066
|
+
L: 200,
|
|
3004
3067
|
S: this,
|
|
3005
3068
|
C: (f, a) => f(...a)
|
|
3006
3069
|
});
|
|
@@ -3448,17 +3511,24 @@ var LibDataChannelTransport = class {
|
|
|
3448
3511
|
this._readyForCandidates = new Trigger2();
|
|
3449
3512
|
this._writeCallback = null;
|
|
3450
3513
|
this._peer = (async () => {
|
|
3451
|
-
const { RTCPeerConnection
|
|
3514
|
+
const { RTCPeerConnection } = (await importESM("node-datachannel/polyfill")).default;
|
|
3452
3515
|
if (this._closed) {
|
|
3453
3516
|
this.errors.raise(new Error("connection already closed"));
|
|
3454
3517
|
}
|
|
3455
|
-
|
|
3518
|
+
if (params.webrtcConfig) {
|
|
3519
|
+
params.webrtcConfig.iceServers = params.webrtcConfig.iceServers ?? [];
|
|
3520
|
+
} else {
|
|
3521
|
+
params.webrtcConfig = {
|
|
3522
|
+
iceServers: []
|
|
3523
|
+
};
|
|
3524
|
+
}
|
|
3525
|
+
const peer = new RTCPeerConnection(params.webrtcConfig);
|
|
3456
3526
|
peer.onicecandidateerror = (event) => {
|
|
3457
3527
|
log14.error("peer.onicecandidateerror", {
|
|
3458
3528
|
event
|
|
3459
3529
|
}, {
|
|
3460
3530
|
F: __dxlog_file15,
|
|
3461
|
-
L:
|
|
3531
|
+
L: 61,
|
|
3462
3532
|
S: this,
|
|
3463
3533
|
C: (f, a) => f(...a)
|
|
3464
3534
|
});
|
|
@@ -3470,7 +3540,7 @@ var LibDataChannelTransport = class {
|
|
|
3470
3540
|
transportConnectionState: this._connected
|
|
3471
3541
|
}, {
|
|
3472
3542
|
F: __dxlog_file15,
|
|
3473
|
-
L:
|
|
3543
|
+
L: 65,
|
|
3474
3544
|
S: this,
|
|
3475
3545
|
C: (f, a) => f(...a)
|
|
3476
3546
|
});
|
|
@@ -3480,7 +3550,7 @@ var LibDataChannelTransport = class {
|
|
|
3480
3550
|
event
|
|
3481
3551
|
}, {
|
|
3482
3552
|
F: __dxlog_file15,
|
|
3483
|
-
L:
|
|
3553
|
+
L: 74,
|
|
3484
3554
|
S: this,
|
|
3485
3555
|
C: (f, a) => f(...a)
|
|
3486
3556
|
});
|
|
@@ -3504,7 +3574,7 @@ var LibDataChannelTransport = class {
|
|
|
3504
3574
|
err
|
|
3505
3575
|
}, {
|
|
3506
3576
|
F: __dxlog_file15,
|
|
3507
|
-
L:
|
|
3577
|
+
L: 91,
|
|
3508
3578
|
S: this,
|
|
3509
3579
|
C: (f, a) => f(...a)
|
|
3510
3580
|
});
|
|
@@ -3513,12 +3583,15 @@ var LibDataChannelTransport = class {
|
|
|
3513
3583
|
};
|
|
3514
3584
|
if (params.initiator) {
|
|
3515
3585
|
peer.createOffer().then(async (offer) => {
|
|
3586
|
+
if (this._closed) {
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3516
3589
|
if (peer.connectionState !== "connecting") {
|
|
3517
3590
|
log14.error("i am initiator but peer not in state connecting", {
|
|
3518
3591
|
peer
|
|
3519
3592
|
}, {
|
|
3520
3593
|
F: __dxlog_file15,
|
|
3521
|
-
L:
|
|
3594
|
+
L: 104,
|
|
3522
3595
|
S: this,
|
|
3523
3596
|
C: (f, a) => f(...a)
|
|
3524
3597
|
});
|
|
@@ -3528,7 +3601,7 @@ var LibDataChannelTransport = class {
|
|
|
3528
3601
|
offer
|
|
3529
3602
|
}, {
|
|
3530
3603
|
F: __dxlog_file15,
|
|
3531
|
-
L:
|
|
3604
|
+
L: 107,
|
|
3532
3605
|
S: this,
|
|
3533
3606
|
C: (f, a) => f(...a)
|
|
3534
3607
|
});
|
|
@@ -3548,7 +3621,7 @@ var LibDataChannelTransport = class {
|
|
|
3548
3621
|
this.handleChannel(peer.createDataChannel(DATACHANNEL_LABEL));
|
|
3549
3622
|
log14.debug("created data channel", void 0, {
|
|
3550
3623
|
F: __dxlog_file15,
|
|
3551
|
-
L:
|
|
3624
|
+
L: 116,
|
|
3552
3625
|
S: this,
|
|
3553
3626
|
C: (f, a) => f(...a)
|
|
3554
3627
|
});
|
|
@@ -3561,7 +3634,7 @@ var LibDataChannelTransport = class {
|
|
|
3561
3634
|
event
|
|
3562
3635
|
}, {
|
|
3563
3636
|
F: __dxlog_file15,
|
|
3564
|
-
L:
|
|
3637
|
+
L: 122,
|
|
3565
3638
|
S: this,
|
|
3566
3639
|
C: (f, a) => f(...a)
|
|
3567
3640
|
});
|
|
@@ -3579,7 +3652,7 @@ var LibDataChannelTransport = class {
|
|
|
3579
3652
|
this._channel.onopen = () => {
|
|
3580
3653
|
log14.debug("dataChannel.onopen", void 0, {
|
|
3581
3654
|
F: __dxlog_file15,
|
|
3582
|
-
L:
|
|
3655
|
+
L: 138,
|
|
3583
3656
|
S: this,
|
|
3584
3657
|
C: (f, a) => f(...a)
|
|
3585
3658
|
});
|
|
@@ -3600,7 +3673,7 @@ var LibDataChannelTransport = class {
|
|
|
3600
3673
|
if (this._writeCallback !== null) {
|
|
3601
3674
|
log14.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3602
3675
|
F: __dxlog_file15,
|
|
3603
|
-
L:
|
|
3676
|
+
L: 155,
|
|
3604
3677
|
S: this,
|
|
3605
3678
|
C: (f, a) => f(...a)
|
|
3606
3679
|
});
|
|
@@ -3625,7 +3698,7 @@ var LibDataChannelTransport = class {
|
|
|
3625
3698
|
err
|
|
3626
3699
|
}, {
|
|
3627
3700
|
F: __dxlog_file15,
|
|
3628
|
-
L:
|
|
3701
|
+
L: 175,
|
|
3629
3702
|
S: this,
|
|
3630
3703
|
C: (f, a) => f(...a)
|
|
3631
3704
|
});
|
|
@@ -3649,6 +3722,12 @@ var LibDataChannelTransport = class {
|
|
|
3649
3722
|
return;
|
|
3650
3723
|
}
|
|
3651
3724
|
await this._disconnectStreams();
|
|
3725
|
+
const peer = await this._peer;
|
|
3726
|
+
try {
|
|
3727
|
+
peer.close();
|
|
3728
|
+
} catch (err) {
|
|
3729
|
+
this.errors.raise(err);
|
|
3730
|
+
}
|
|
3652
3731
|
this._closed = true;
|
|
3653
3732
|
this.closed.emit();
|
|
3654
3733
|
}
|
|
@@ -3662,7 +3741,7 @@ var LibDataChannelTransport = class {
|
|
|
3662
3741
|
peer
|
|
3663
3742
|
}, {
|
|
3664
3743
|
F: __dxlog_file15,
|
|
3665
|
-
L:
|
|
3744
|
+
L: 216,
|
|
3666
3745
|
S: this,
|
|
3667
3746
|
C: (f, a) => f(...a)
|
|
3668
3747
|
});
|
|
@@ -3690,7 +3769,7 @@ var LibDataChannelTransport = class {
|
|
|
3690
3769
|
err
|
|
3691
3770
|
}, {
|
|
3692
3771
|
F: __dxlog_file15,
|
|
3693
|
-
L:
|
|
3772
|
+
L: 227,
|
|
3694
3773
|
S: this,
|
|
3695
3774
|
C: (f, a) => f(...a)
|
|
3696
3775
|
});
|
|
@@ -3710,7 +3789,7 @@ var LibDataChannelTransport = class {
|
|
|
3710
3789
|
err
|
|
3711
3790
|
}, {
|
|
3712
3791
|
F: __dxlog_file15,
|
|
3713
|
-
L:
|
|
3792
|
+
L: 238,
|
|
3714
3793
|
S: this,
|
|
3715
3794
|
C: (f, a) => f(...a)
|
|
3716
3795
|
});
|
|
@@ -3729,7 +3808,7 @@ var LibDataChannelTransport = class {
|
|
|
3729
3808
|
signal
|
|
3730
3809
|
}, {
|
|
3731
3810
|
F: __dxlog_file15,
|
|
3732
|
-
L:
|
|
3811
|
+
L: 249,
|
|
3733
3812
|
S: this,
|
|
3734
3813
|
C: (f, a) => f(...a)
|
|
3735
3814
|
});
|
|
@@ -3738,51 +3817,61 @@ var LibDataChannelTransport = class {
|
|
|
3738
3817
|
}).catch((err) => {
|
|
3739
3818
|
log14.catch(err, void 0, {
|
|
3740
3819
|
F: __dxlog_file15,
|
|
3741
|
-
L:
|
|
3820
|
+
L: 254,
|
|
3742
3821
|
S: this,
|
|
3743
3822
|
C: (f, a) => f(...a)
|
|
3744
3823
|
});
|
|
3745
3824
|
});
|
|
3746
3825
|
}
|
|
3747
3826
|
async getDetails() {
|
|
3827
|
+
const stats = await this._getStats();
|
|
3828
|
+
const rc = stats?.remoteCandidate;
|
|
3829
|
+
if (!rc) {
|
|
3830
|
+
return "unavailable";
|
|
3831
|
+
}
|
|
3832
|
+
if (rc.candidateType === "relay") {
|
|
3833
|
+
return `${rc.ip}:${rc.port} relay for ${rc.relatedAddress}:${rc.relatedPort}`;
|
|
3834
|
+
}
|
|
3835
|
+
return `${rc.ip}:${rc.port} ${rc.candidateType}`;
|
|
3836
|
+
}
|
|
3837
|
+
async _getStats() {
|
|
3748
3838
|
return this._peer.then(async (peer) => {
|
|
3749
|
-
const
|
|
3750
|
-
|
|
3751
|
-
|
|
3839
|
+
const stats = await peer.getStats();
|
|
3840
|
+
const statsEntries = Array.from(stats.entries());
|
|
3841
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
3842
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
3843
|
+
let selectedCandidatePair;
|
|
3844
|
+
let remoteCandidate;
|
|
3845
|
+
if (candidatePair.length > 0) {
|
|
3846
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
3847
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
3752
3848
|
}
|
|
3753
|
-
return
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
C: (f, a) => f(...a)
|
|
3760
|
-
});
|
|
3761
|
-
return "unavailable";
|
|
3849
|
+
return {
|
|
3850
|
+
transport,
|
|
3851
|
+
selectedCandidatePair,
|
|
3852
|
+
remoteCandidate,
|
|
3853
|
+
raw: Object.fromEntries(stats)
|
|
3854
|
+
};
|
|
3762
3855
|
});
|
|
3763
3856
|
}
|
|
3764
3857
|
async getStats() {
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
bytesSent: peer.bytesSent(),
|
|
3768
|
-
bytesReceived: peer.bytesReceived(),
|
|
3769
|
-
packetsSent: 0,
|
|
3770
|
-
packetsReceived: 0
|
|
3771
|
-
};
|
|
3772
|
-
}).catch((err) => {
|
|
3773
|
-
log14.catch(err, void 0, {
|
|
3774
|
-
F: __dxlog_file15,
|
|
3775
|
-
L: 266,
|
|
3776
|
-
S: this,
|
|
3777
|
-
C: (f, a) => f(...a)
|
|
3778
|
-
});
|
|
3858
|
+
const stats = await this._getStats();
|
|
3859
|
+
if (!stats) {
|
|
3779
3860
|
return {
|
|
3780
3861
|
bytesSent: 0,
|
|
3781
3862
|
bytesReceived: 0,
|
|
3782
3863
|
packetsSent: 0,
|
|
3783
|
-
packetsReceived: 0
|
|
3864
|
+
packetsReceived: 0,
|
|
3865
|
+
rawStats: {}
|
|
3784
3866
|
};
|
|
3785
|
-
}
|
|
3867
|
+
}
|
|
3868
|
+
return {
|
|
3869
|
+
bytesSent: stats.transport.bytesSent,
|
|
3870
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
3871
|
+
packetsSent: 0,
|
|
3872
|
+
packetsReceived: 0,
|
|
3873
|
+
rawStats: stats.raw
|
|
3874
|
+
};
|
|
3786
3875
|
}
|
|
3787
3876
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
3788
3877
|
async destroy() {
|
|
@@ -3801,6 +3890,7 @@ var createLibDataChannelTransportFactory = (webrtcConfig) => ({
|
|
|
3801
3890
|
webrtcConfig
|
|
3802
3891
|
})
|
|
3803
3892
|
});
|
|
3893
|
+
var importESM = Function("path", "return import(path)");
|
|
3804
3894
|
|
|
3805
3895
|
// packages/core/mesh/network-manager/src/transport/tcp-transport.browser.ts
|
|
3806
3896
|
import { Event as Event11 } from "@dxos/async";
|
|
@@ -3877,4 +3967,4 @@ export {
|
|
|
3877
3967
|
TcpTransport,
|
|
3878
3968
|
createTeleportProtocolFactory
|
|
3879
3969
|
};
|
|
3880
|
-
//# sourceMappingURL=chunk-
|
|
3970
|
+
//# sourceMappingURL=chunk-7JESB3AJ.mjs.map
|