@dxos/network-manager 0.3.8 → 0.3.9-main.03b62b6
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-KGZ5C6JO.mjs} +407 -118
- package/dist/lib/browser/chunk-KGZ5C6JO.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-XE5JOIGD.cjs → chunk-JDKM4UPJ.cjs} +21 -13
- package/dist/lib/node/chunk-JDKM4UPJ.cjs.map +7 -0
- package/dist/lib/node/{chunk-RBHZCZH4.cjs → chunk-WUBZ4UOJ.cjs} +410 -111
- package/dist/lib/node/chunk-WUBZ4UOJ.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 +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/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 +27 -1
- package/src/swarm/connection.ts +40 -6
- package/src/topology/mmst-topology.ts +34 -6
- 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-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
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from "./chunk-YERMWDRB.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/core/mesh/network-manager/src/swarm/connection.ts
|
|
7
|
-
import { DeferredTask, Event, sleep, scheduleTask, synchronized } from "@dxos/async";
|
|
7
|
+
import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
8
8
|
import { Context, cancelWithContext } from "@dxos/context";
|
|
9
9
|
import { ErrorStream } from "@dxos/debug";
|
|
10
10
|
import { invariant } from "@dxos/invariant";
|
|
11
11
|
import { PublicKey } from "@dxos/keys";
|
|
12
|
-
import { log } from "@dxos/log";
|
|
13
|
-
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
12
|
+
import { log, logInfo } from "@dxos/log";
|
|
13
|
+
import { CancelledError, ProtocolError, ConnectionResetError, ConnectivityError, TimeoutError, UnknownProtocolError, trace } from "@dxos/protocols";
|
|
14
14
|
function _ts_decorate(decorators, target, key, desc) {
|
|
15
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -21,9 +21,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
21
21
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
23
|
}
|
|
24
|
-
var __dxlog_file = "/home/
|
|
24
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection.ts";
|
|
25
25
|
var STARTING_SIGNALLING_DELAY = 10;
|
|
26
26
|
var TRANSPORT_CONNECTION_TIMEOUT = 1e4;
|
|
27
|
+
var TRANSPORT_STATS_INTERVAL = 5e3;
|
|
27
28
|
var MAX_SIGNALLING_DELAY = 300;
|
|
28
29
|
var ConnectionState;
|
|
29
30
|
(function(ConnectionState5) {
|
|
@@ -86,6 +87,7 @@ var Connection = class {
|
|
|
86
87
|
this.stateChanged = new Event();
|
|
87
88
|
this.errors = new ErrorStream();
|
|
88
89
|
this._instanceId = PublicKey.random().toHex();
|
|
90
|
+
this.transportStats = new Event();
|
|
89
91
|
this._signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
90
92
|
await this._flushSignalBuffer();
|
|
91
93
|
});
|
|
@@ -98,11 +100,14 @@ var Connection = class {
|
|
|
98
100
|
initiator: this.initiator
|
|
99
101
|
}, {
|
|
100
102
|
F: __dxlog_file,
|
|
101
|
-
L:
|
|
103
|
+
L: 134,
|
|
102
104
|
S: this,
|
|
103
105
|
C: (f, a) => f(...a)
|
|
104
106
|
});
|
|
105
107
|
}
|
|
108
|
+
get sessionIdString() {
|
|
109
|
+
return this.sessionId.truncate();
|
|
110
|
+
}
|
|
106
111
|
get state() {
|
|
107
112
|
return this._state;
|
|
108
113
|
}
|
|
@@ -118,7 +123,7 @@ var Connection = class {
|
|
|
118
123
|
async openConnection() {
|
|
119
124
|
invariant(this._state === ConnectionState.INITIAL, "Invalid state.", {
|
|
120
125
|
F: __dxlog_file,
|
|
121
|
-
L:
|
|
126
|
+
L: 164,
|
|
122
127
|
S: this,
|
|
123
128
|
A: [
|
|
124
129
|
"this._state === ConnectionState.INITIAL",
|
|
@@ -129,7 +134,7 @@ var Connection = class {
|
|
|
129
134
|
id: this._instanceId
|
|
130
135
|
}), {
|
|
131
136
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
137
|
+
L: 165,
|
|
133
138
|
S: this,
|
|
134
139
|
C: (f, a) => f(...a)
|
|
135
140
|
});
|
|
@@ -141,35 +146,35 @@ var Connection = class {
|
|
|
141
146
|
initiator: this.initiator
|
|
142
147
|
}, {
|
|
143
148
|
F: __dxlog_file,
|
|
144
|
-
L:
|
|
149
|
+
L: 166,
|
|
145
150
|
S: this,
|
|
146
151
|
C: (f, a) => f(...a)
|
|
147
152
|
});
|
|
148
153
|
this._changeState(ConnectionState.CONNECTING);
|
|
149
|
-
this._protocol.open().catch((err) => {
|
|
154
|
+
this._protocol.open(this.sessionId).catch((err) => {
|
|
150
155
|
this.errors.raise(err);
|
|
151
156
|
});
|
|
152
157
|
this._protocol.stream.on("close", () => {
|
|
153
158
|
log("protocol stream closed", void 0, {
|
|
154
159
|
F: __dxlog_file,
|
|
155
|
-
L:
|
|
160
|
+
L: 183,
|
|
156
161
|
S: this,
|
|
157
162
|
C: (f, a) => f(...a)
|
|
158
163
|
});
|
|
159
164
|
this.close(new ProtocolError("protocol stream closed")).catch((err) => this.errors.raise(err));
|
|
160
165
|
});
|
|
161
166
|
scheduleTask(this.connectedTimeoutContext, async () => {
|
|
162
|
-
log.info(
|
|
167
|
+
log.info(`timeout waiting ${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect, aborting`, void 0, {
|
|
163
168
|
F: __dxlog_file,
|
|
164
|
-
L:
|
|
169
|
+
L: 190,
|
|
165
170
|
S: this,
|
|
166
171
|
C: (f, a) => f(...a)
|
|
167
172
|
});
|
|
168
|
-
await this.abort().catch((err) => this.errors.raise(err));
|
|
173
|
+
await this.abort(new TimeoutError(`${TRANSPORT_CONNECTION_TIMEOUT / 1e3}s for transport to connect`)).catch((err) => this.errors.raise(err));
|
|
169
174
|
}, TRANSPORT_CONNECTION_TIMEOUT);
|
|
170
175
|
invariant(!this._transport, void 0, {
|
|
171
176
|
F: __dxlog_file,
|
|
172
|
-
L:
|
|
177
|
+
L: 198,
|
|
173
178
|
S: this,
|
|
174
179
|
A: [
|
|
175
180
|
"!this._transport",
|
|
@@ -179,18 +184,20 @@ var Connection = class {
|
|
|
179
184
|
this._transport = this._transportFactory.createTransport({
|
|
180
185
|
initiator: this.initiator,
|
|
181
186
|
stream: this._protocol.stream,
|
|
182
|
-
sendSignal: async (signal) => this._sendSignal(signal)
|
|
187
|
+
sendSignal: async (signal) => this._sendSignal(signal),
|
|
188
|
+
sessionId: this.sessionId
|
|
183
189
|
});
|
|
184
190
|
this._transport.connected.once(async () => {
|
|
185
191
|
this._changeState(ConnectionState.CONNECTED);
|
|
186
192
|
await this.connectedTimeoutContext.dispose();
|
|
187
193
|
this._callbacks?.onConnected?.();
|
|
194
|
+
scheduleTaskInterval(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
|
|
188
195
|
});
|
|
189
196
|
this._transport.closed.once(() => {
|
|
190
197
|
this._transport = void 0;
|
|
191
198
|
log("abort triggered by transport close", void 0, {
|
|
192
199
|
F: __dxlog_file,
|
|
193
|
-
L:
|
|
200
|
+
L: 216,
|
|
194
201
|
S: this,
|
|
195
202
|
C: (f, a) => f(...a)
|
|
196
203
|
});
|
|
@@ -201,7 +208,7 @@ var Connection = class {
|
|
|
201
208
|
err
|
|
202
209
|
}, {
|
|
203
210
|
F: __dxlog_file,
|
|
204
|
-
L:
|
|
211
|
+
L: 221,
|
|
205
212
|
S: this,
|
|
206
213
|
C: (f, a) => f(...a)
|
|
207
214
|
});
|
|
@@ -211,7 +218,7 @@ var Connection = class {
|
|
|
211
218
|
if (err instanceof ConnectionResetError) {
|
|
212
219
|
log.info("aborting due to transport ConnectionResetError", void 0, {
|
|
213
220
|
F: __dxlog_file,
|
|
214
|
-
L:
|
|
221
|
+
L: 228,
|
|
215
222
|
S: this,
|
|
216
223
|
C: (f, a) => f(...a)
|
|
217
224
|
});
|
|
@@ -219,7 +226,7 @@ var Connection = class {
|
|
|
219
226
|
} else if (err instanceof ConnectivityError) {
|
|
220
227
|
log.info("aborting due to transport ConnectivityError", void 0, {
|
|
221
228
|
F: __dxlog_file,
|
|
222
|
-
L:
|
|
229
|
+
L: 231,
|
|
223
230
|
S: this,
|
|
224
231
|
C: (f, a) => f(...a)
|
|
225
232
|
});
|
|
@@ -229,7 +236,7 @@ var Connection = class {
|
|
|
229
236
|
err
|
|
230
237
|
}, {
|
|
231
238
|
F: __dxlog_file,
|
|
232
|
-
L:
|
|
239
|
+
L: 234,
|
|
233
240
|
S: this,
|
|
234
241
|
C: (f, a) => f(...a)
|
|
235
242
|
});
|
|
@@ -247,7 +254,7 @@ var Connection = class {
|
|
|
247
254
|
id: this._instanceId
|
|
248
255
|
}), {
|
|
249
256
|
F: __dxlog_file,
|
|
250
|
-
L:
|
|
257
|
+
L: 250,
|
|
251
258
|
S: this,
|
|
252
259
|
C: (f, a) => f(...a)
|
|
253
260
|
});
|
|
@@ -257,14 +264,14 @@ var Connection = class {
|
|
|
257
264
|
err
|
|
258
265
|
}, {
|
|
259
266
|
F: __dxlog_file,
|
|
260
|
-
L:
|
|
267
|
+
L: 257,
|
|
261
268
|
S: this,
|
|
262
269
|
C: (f, a) => f(...a)
|
|
263
270
|
});
|
|
264
271
|
if (this._state === ConnectionState.CLOSED || this._state === ConnectionState.ABORTED) {
|
|
265
272
|
log(`abort ignored: already ${this._state}`, this.closeReason, {
|
|
266
273
|
F: __dxlog_file,
|
|
267
|
-
L:
|
|
274
|
+
L: 259,
|
|
268
275
|
S: this,
|
|
269
276
|
C: (f, a) => f(...a)
|
|
270
277
|
});
|
|
@@ -279,7 +286,7 @@ var Connection = class {
|
|
|
279
286
|
try {
|
|
280
287
|
log("aborting protocol... ", void 0, {
|
|
281
288
|
F: __dxlog_file,
|
|
282
|
-
L:
|
|
289
|
+
L: 273,
|
|
283
290
|
S: this,
|
|
284
291
|
C: (f, a) => f(...a)
|
|
285
292
|
});
|
|
@@ -287,7 +294,7 @@ var Connection = class {
|
|
|
287
294
|
} catch (err2) {
|
|
288
295
|
log.catch(err2, void 0, {
|
|
289
296
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
297
|
+
L: 276,
|
|
291
298
|
S: this,
|
|
292
299
|
C: (f, a) => f(...a)
|
|
293
300
|
});
|
|
@@ -297,7 +304,7 @@ var Connection = class {
|
|
|
297
304
|
} catch (err2) {
|
|
298
305
|
log.catch(err2, void 0, {
|
|
299
306
|
F: __dxlog_file,
|
|
300
|
-
L:
|
|
307
|
+
L: 283,
|
|
301
308
|
S: this,
|
|
302
309
|
C: (f, a) => f(...a)
|
|
303
310
|
});
|
|
@@ -307,7 +314,7 @@ var Connection = class {
|
|
|
307
314
|
} catch (err2) {
|
|
308
315
|
log.catch(err2, void 0, {
|
|
309
316
|
F: __dxlog_file,
|
|
310
|
-
L:
|
|
317
|
+
L: 289,
|
|
311
318
|
S: this,
|
|
312
319
|
C: (f, a) => f(...a)
|
|
313
320
|
});
|
|
@@ -331,7 +338,7 @@ var Connection = class {
|
|
|
331
338
|
peerId: this.ownId
|
|
332
339
|
}, {
|
|
333
340
|
F: __dxlog_file,
|
|
334
|
-
L:
|
|
341
|
+
L: 314,
|
|
335
342
|
S: this,
|
|
336
343
|
C: (f, a) => f(...a)
|
|
337
344
|
});
|
|
@@ -341,7 +348,34 @@ var Connection = class {
|
|
|
341
348
|
} catch (err2) {
|
|
342
349
|
log.catch(err2, void 0, {
|
|
343
350
|
F: __dxlog_file,
|
|
344
|
-
L:
|
|
351
|
+
L: 321,
|
|
352
|
+
S: this,
|
|
353
|
+
C: (f, a) => f(...a)
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
await this._transport?.destroy();
|
|
358
|
+
} catch (err2) {
|
|
359
|
+
log.catch(err2, void 0, {
|
|
360
|
+
F: __dxlog_file,
|
|
361
|
+
L: 328,
|
|
362
|
+
S: this,
|
|
363
|
+
C: (f, a) => f(...a)
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
} else {
|
|
367
|
+
log.info(`graceful close requested when we were in ${lastState} state? aborting`, void 0, {
|
|
368
|
+
F: __dxlog_file,
|
|
369
|
+
L: 331,
|
|
370
|
+
S: this,
|
|
371
|
+
C: (f, a) => f(...a)
|
|
372
|
+
});
|
|
373
|
+
try {
|
|
374
|
+
await this._protocol.abort();
|
|
375
|
+
} catch (err2) {
|
|
376
|
+
log.catch(err2, void 0, {
|
|
377
|
+
F: __dxlog_file,
|
|
378
|
+
L: 335,
|
|
345
379
|
S: this,
|
|
346
380
|
C: (f, a) => f(...a)
|
|
347
381
|
});
|
|
@@ -351,7 +385,7 @@ var Connection = class {
|
|
|
351
385
|
} catch (err2) {
|
|
352
386
|
log.catch(err2, void 0, {
|
|
353
387
|
F: __dxlog_file,
|
|
354
|
-
L:
|
|
388
|
+
L: 340,
|
|
355
389
|
S: this,
|
|
356
390
|
C: (f, a) => f(...a)
|
|
357
391
|
});
|
|
@@ -361,7 +395,7 @@ var Connection = class {
|
|
|
361
395
|
peerId: this.ownId
|
|
362
396
|
}, {
|
|
363
397
|
F: __dxlog_file,
|
|
364
|
-
L:
|
|
398
|
+
L: 344,
|
|
365
399
|
S: this,
|
|
366
400
|
C: (f, a) => f(...a)
|
|
367
401
|
});
|
|
@@ -404,7 +438,7 @@ var Connection = class {
|
|
|
404
438
|
err
|
|
405
439
|
}, {
|
|
406
440
|
F: __dxlog_file,
|
|
407
|
-
L:
|
|
441
|
+
L: 382,
|
|
408
442
|
S: this,
|
|
409
443
|
C: (f, a) => f(...a)
|
|
410
444
|
});
|
|
@@ -417,7 +451,7 @@ var Connection = class {
|
|
|
417
451
|
async signal(msg) {
|
|
418
452
|
invariant(msg.sessionId, void 0, {
|
|
419
453
|
F: __dxlog_file,
|
|
420
|
-
L:
|
|
454
|
+
L: 391,
|
|
421
455
|
S: this,
|
|
422
456
|
A: [
|
|
423
457
|
"msg.sessionId",
|
|
@@ -427,7 +461,7 @@ var Connection = class {
|
|
|
427
461
|
if (!msg.sessionId.equals(this.sessionId)) {
|
|
428
462
|
log("dropping signal for incorrect session id", void 0, {
|
|
429
463
|
F: __dxlog_file,
|
|
430
|
-
L:
|
|
464
|
+
L: 393,
|
|
431
465
|
S: this,
|
|
432
466
|
C: (f, a) => f(...a)
|
|
433
467
|
});
|
|
@@ -435,7 +469,7 @@ var Connection = class {
|
|
|
435
469
|
}
|
|
436
470
|
invariant(msg.data.signal || msg.data.signalBatch, void 0, {
|
|
437
471
|
F: __dxlog_file,
|
|
438
|
-
L:
|
|
472
|
+
L: 396,
|
|
439
473
|
S: this,
|
|
440
474
|
A: [
|
|
441
475
|
"msg.data.signal || msg.data.signalBatch",
|
|
@@ -444,7 +478,7 @@ var Connection = class {
|
|
|
444
478
|
});
|
|
445
479
|
invariant(msg.author?.equals(this.remoteId), void 0, {
|
|
446
480
|
F: __dxlog_file,
|
|
447
|
-
L:
|
|
481
|
+
L: 397,
|
|
448
482
|
S: this,
|
|
449
483
|
A: [
|
|
450
484
|
"msg.author?.equals(this.remoteId)",
|
|
@@ -453,7 +487,7 @@ var Connection = class {
|
|
|
453
487
|
});
|
|
454
488
|
invariant(msg.recipient?.equals(this.ownId), void 0, {
|
|
455
489
|
F: __dxlog_file,
|
|
456
|
-
L:
|
|
490
|
+
L: 398,
|
|
457
491
|
S: this,
|
|
458
492
|
A: [
|
|
459
493
|
"msg.recipient?.equals(this.ownId)",
|
|
@@ -477,7 +511,7 @@ var Connection = class {
|
|
|
477
511
|
msg: msg.data
|
|
478
512
|
}, {
|
|
479
513
|
F: __dxlog_file,
|
|
480
|
-
L:
|
|
514
|
+
L: 407,
|
|
481
515
|
S: this,
|
|
482
516
|
C: (f, a) => f(...a)
|
|
483
517
|
});
|
|
@@ -485,7 +519,7 @@ var Connection = class {
|
|
|
485
519
|
} else {
|
|
486
520
|
invariant(this._transport, "Connection not ready to accept signals.", {
|
|
487
521
|
F: __dxlog_file,
|
|
488
|
-
L:
|
|
522
|
+
L: 410,
|
|
489
523
|
S: this,
|
|
490
524
|
A: [
|
|
491
525
|
"this._transport",
|
|
@@ -498,7 +532,7 @@ var Connection = class {
|
|
|
498
532
|
msg: msg.data
|
|
499
533
|
}, {
|
|
500
534
|
F: __dxlog_file,
|
|
501
|
-
L:
|
|
535
|
+
L: 411,
|
|
502
536
|
S: this,
|
|
503
537
|
C: (f, a) => f(...a)
|
|
504
538
|
});
|
|
@@ -516,13 +550,13 @@ var Connection = class {
|
|
|
516
550
|
peerId: this.ownId
|
|
517
551
|
}, {
|
|
518
552
|
F: __dxlog_file,
|
|
519
|
-
L:
|
|
553
|
+
L: 422,
|
|
520
554
|
S: this,
|
|
521
555
|
C: (f, a) => f(...a)
|
|
522
556
|
});
|
|
523
557
|
invariant(state !== this._state, "Already in this state.", {
|
|
524
558
|
F: __dxlog_file,
|
|
525
|
-
L:
|
|
559
|
+
L: 423,
|
|
526
560
|
S: this,
|
|
527
561
|
A: [
|
|
528
562
|
"state !== this._state",
|
|
@@ -532,7 +566,16 @@ var Connection = class {
|
|
|
532
566
|
this._state = state;
|
|
533
567
|
this.stateChanged.emit(state);
|
|
534
568
|
}
|
|
569
|
+
async _emitTransportStats() {
|
|
570
|
+
const stats = await this.transport?.getStats();
|
|
571
|
+
if (stats) {
|
|
572
|
+
this.transportStats.emit(stats);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
535
575
|
};
|
|
576
|
+
_ts_decorate([
|
|
577
|
+
logInfo
|
|
578
|
+
], Connection.prototype, "sessionIdString", null);
|
|
536
579
|
_ts_decorate([
|
|
537
580
|
synchronized
|
|
538
581
|
], Connection.prototype, "abort", null);
|
|
@@ -545,9 +588,9 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
545
588
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
546
589
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
547
590
|
import { log as log2 } from "@dxos/log";
|
|
548
|
-
import { schema, TimeoutError } from "@dxos/protocols";
|
|
591
|
+
import { schema, TimeoutError as TimeoutError2 } from "@dxos/protocols";
|
|
549
592
|
import { ComplexMap } from "@dxos/util";
|
|
550
|
-
var __dxlog_file2 = "/home/
|
|
593
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/signal/swarm-messenger.ts";
|
|
551
594
|
var SwarmMessage = schema.getCodecForType("dxos.mesh.swarm.SwarmMessage");
|
|
552
595
|
var SwarmMessenger = class {
|
|
553
596
|
constructor({ sendMessage, onSignal, onOffer, topic }) {
|
|
@@ -730,7 +773,7 @@ var SwarmMessenger = class {
|
|
|
730
773
|
}
|
|
731
774
|
});
|
|
732
775
|
} catch (err) {
|
|
733
|
-
if (err instanceof
|
|
776
|
+
if (err instanceof TimeoutError2) {
|
|
734
777
|
log2.info("timeout sending answer to offer", {
|
|
735
778
|
err
|
|
736
779
|
}, {
|
|
@@ -789,7 +832,7 @@ import { Context as Context4 } from "@dxos/context";
|
|
|
789
832
|
import { ErrorStream as ErrorStream2 } from "@dxos/debug";
|
|
790
833
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
791
834
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
792
|
-
import { log as log4, logInfo } from "@dxos/log";
|
|
835
|
+
import { log as log4, logInfo as logInfo2 } from "@dxos/log";
|
|
793
836
|
import { trace as trace2 } from "@dxos/protocols";
|
|
794
837
|
import { ComplexMap as ComplexMap2, isNotNullOrUndefined } from "@dxos/util";
|
|
795
838
|
|
|
@@ -810,7 +853,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
810
853
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
811
854
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
812
855
|
}
|
|
813
|
-
var __dxlog_file3 = "/home/
|
|
856
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/peer.ts";
|
|
814
857
|
var ConnectionDisplacedError = class extends SystemError {
|
|
815
858
|
constructor() {
|
|
816
859
|
super("Connection displaced by remote initiator.");
|
|
@@ -1288,7 +1331,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1288
1331
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1289
1332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1290
1333
|
}
|
|
1291
|
-
var __dxlog_file4 = "/home/
|
|
1334
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm.ts";
|
|
1292
1335
|
var INITIATION_DELAY = 100;
|
|
1293
1336
|
var getClassName = (obj) => Object.getPrototypeOf(obj).constructor.name;
|
|
1294
1337
|
var Swarm = class {
|
|
@@ -1753,13 +1796,13 @@ var Swarm = class {
|
|
|
1753
1796
|
}
|
|
1754
1797
|
};
|
|
1755
1798
|
_ts_decorate3([
|
|
1756
|
-
|
|
1799
|
+
logInfo2
|
|
1757
1800
|
], Swarm.prototype, "_instanceId", void 0);
|
|
1758
1801
|
_ts_decorate3([
|
|
1759
|
-
|
|
1802
|
+
logInfo2
|
|
1760
1803
|
], Swarm.prototype, "ownPeerId", null);
|
|
1761
1804
|
_ts_decorate3([
|
|
1762
|
-
|
|
1805
|
+
logInfo2
|
|
1763
1806
|
], Swarm.prototype, "topic", null);
|
|
1764
1807
|
_ts_decorate3([
|
|
1765
1808
|
synchronized3
|
|
@@ -1779,7 +1822,7 @@ import { Event as Event4, EventSubscriptions } from "@dxos/async";
|
|
|
1779
1822
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1780
1823
|
import { log as log5 } from "@dxos/log";
|
|
1781
1824
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
1782
|
-
var __dxlog_file5 = "/home/
|
|
1825
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/swarm-mapper.ts";
|
|
1783
1826
|
var SwarmMapper = class {
|
|
1784
1827
|
get peers() {
|
|
1785
1828
|
return Array.from(this._peers.values());
|
|
@@ -1851,7 +1894,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
|
1851
1894
|
import { log as log6 } from "@dxos/log";
|
|
1852
1895
|
import { CancelledError as CancelledError3 } from "@dxos/protocols";
|
|
1853
1896
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1854
|
-
var __dxlog_file6 = "/home/
|
|
1897
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/swarm/connection-limiter.ts";
|
|
1855
1898
|
var MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
1856
1899
|
var ConnectionLimiter = class {
|
|
1857
1900
|
constructor({ maxConcurrentInitConnections = MAX_CONCURRENT_INITIATING_CONNECTIONS } = {}) {
|
|
@@ -1930,6 +1973,7 @@ import { Event as Event5 } from "@dxos/async";
|
|
|
1930
1973
|
import { raise } from "@dxos/debug";
|
|
1931
1974
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1932
1975
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1976
|
+
var CONNECTION_GC_THRESHOLD = 1e3 * 60 * 15;
|
|
1933
1977
|
var EventType;
|
|
1934
1978
|
(function(EventType2) {
|
|
1935
1979
|
EventType2["CONNECTION_STATE_CHANGED"] = "CONNECTION_STATE_CHANGED";
|
|
@@ -1970,25 +2014,39 @@ var ConnectionLog = class {
|
|
|
1970
2014
|
sessionId: connection.sessionId,
|
|
1971
2015
|
transport: connection.transport && Object.getPrototypeOf(connection.transport).constructor.name,
|
|
1972
2016
|
protocolExtensions: [],
|
|
1973
|
-
events: []
|
|
2017
|
+
events: [],
|
|
2018
|
+
lastUpdate: /* @__PURE__ */ new Date()
|
|
1974
2019
|
};
|
|
1975
2020
|
info.connections.push(connectionInfo);
|
|
1976
2021
|
this.update.emit();
|
|
1977
|
-
connection.stateChanged.on((state) => {
|
|
2022
|
+
connection.stateChanged.on(async (state) => {
|
|
1978
2023
|
connectionInfo.state = state;
|
|
1979
2024
|
connectionInfo.closeReason = connection.closeReason;
|
|
2025
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
1980
2026
|
connectionInfo.events.push({
|
|
1981
2027
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
1982
2028
|
newState: state
|
|
1983
2029
|
});
|
|
2030
|
+
if (state === ConnectionState.CONNECTED) {
|
|
2031
|
+
const details = await connection.transport?.getDetails();
|
|
2032
|
+
connectionInfo.transportDetails = details;
|
|
2033
|
+
}
|
|
1984
2034
|
this.update.emit();
|
|
1985
2035
|
});
|
|
1986
2036
|
connection.protocol?.stats?.on((stats) => {
|
|
1987
2037
|
connectionInfo.readBufferSize = stats.readBufferSize;
|
|
1988
2038
|
connectionInfo.writeBufferSize = stats.writeBufferSize;
|
|
1989
2039
|
connectionInfo.streams = stats.channels;
|
|
2040
|
+
connectionInfo.lastUpdate = /* @__PURE__ */ new Date();
|
|
1990
2041
|
this.update.emit();
|
|
1991
2042
|
});
|
|
2043
|
+
connection.transportStats?.on((stats) => {
|
|
2044
|
+
connectionInfo.transportBytesSent = stats.bytesSent;
|
|
2045
|
+
connectionInfo.transportBytesReceived = stats.bytesReceived;
|
|
2046
|
+
connectionInfo.transportPacketsSent = stats.packetsSent;
|
|
2047
|
+
connectionInfo.transportPacketsReceived = stats.packetsReceived;
|
|
2048
|
+
});
|
|
2049
|
+
gcSwarm(info);
|
|
1992
2050
|
});
|
|
1993
2051
|
}
|
|
1994
2052
|
leftSwarm(swarm) {
|
|
@@ -1996,6 +2054,11 @@ var ConnectionLog = class {
|
|
|
1996
2054
|
this.update.emit();
|
|
1997
2055
|
}
|
|
1998
2056
|
};
|
|
2057
|
+
var gcSwarm = (swarm) => {
|
|
2058
|
+
swarm.connections = swarm.connections?.filter((connection) => {
|
|
2059
|
+
return connection.lastUpdate ? Date.now() - connection.lastUpdate.getTime() < CONNECTION_GC_THRESHOLD : true;
|
|
2060
|
+
});
|
|
2061
|
+
};
|
|
1999
2062
|
|
|
2000
2063
|
// packages/core/mesh/network-manager/src/network-manager.ts
|
|
2001
2064
|
import { Event as Event6 } from "@dxos/async";
|
|
@@ -2006,7 +2069,7 @@ import { Messenger } from "@dxos/messaging";
|
|
|
2006
2069
|
import { trace as trace3 } from "@dxos/protocols";
|
|
2007
2070
|
import { ConnectionState as ConnectionState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2008
2071
|
import { ComplexMap as ComplexMap6 } from "@dxos/util";
|
|
2009
|
-
var __dxlog_file7 = "/home/
|
|
2072
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/network-manager.ts";
|
|
2010
2073
|
var NetworkManager = class {
|
|
2011
2074
|
constructor({ transportFactory, signalManager, log: log1 }) {
|
|
2012
2075
|
/**
|
|
@@ -2242,7 +2305,7 @@ var NetworkManager = class {
|
|
|
2242
2305
|
|
|
2243
2306
|
// packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts
|
|
2244
2307
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2245
|
-
var __dxlog_file8 = "/home/
|
|
2308
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/fully-connected-topology.ts";
|
|
2246
2309
|
var FullyConnectedTopology = class {
|
|
2247
2310
|
toString() {
|
|
2248
2311
|
return "FullyConnectedTopology";
|
|
@@ -2285,10 +2348,13 @@ var FullyConnectedTopology = class {
|
|
|
2285
2348
|
import distance from "xor-distance";
|
|
2286
2349
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2287
2350
|
import { log as log8 } from "@dxos/log";
|
|
2288
|
-
var __dxlog_file9 = "/home/
|
|
2351
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/mmst-topology.ts";
|
|
2352
|
+
var MIN_UPDATE_INTERVAL = 1e3 * 10;
|
|
2353
|
+
var MAX_CHANGES_PER_UPDATE = 1;
|
|
2289
2354
|
var MMSTTopology = class {
|
|
2290
2355
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 } = {}) {
|
|
2291
2356
|
this._sampleCollected = false;
|
|
2357
|
+
this._lastAction = /* @__PURE__ */ new Date(0);
|
|
2292
2358
|
this._originateConnections = originateConnections;
|
|
2293
2359
|
this._maxPeers = maxPeers;
|
|
2294
2360
|
this._sampleSize = sampleSize;
|
|
@@ -2296,7 +2362,7 @@ var MMSTTopology = class {
|
|
|
2296
2362
|
init(controller) {
|
|
2297
2363
|
invariant8(!this._controller, "Already initialized", {
|
|
2298
2364
|
F: __dxlog_file9,
|
|
2299
|
-
L:
|
|
2365
|
+
L: 51,
|
|
2300
2366
|
S: this,
|
|
2301
2367
|
A: [
|
|
2302
2368
|
"!this._controller",
|
|
@@ -2308,7 +2374,7 @@ var MMSTTopology = class {
|
|
|
2308
2374
|
update() {
|
|
2309
2375
|
invariant8(this._controller, "Not initialized", {
|
|
2310
2376
|
F: __dxlog_file9,
|
|
2311
|
-
L:
|
|
2377
|
+
L: 56,
|
|
2312
2378
|
S: this,
|
|
2313
2379
|
A: [
|
|
2314
2380
|
"this._controller",
|
|
@@ -2319,7 +2385,7 @@ var MMSTTopology = class {
|
|
|
2319
2385
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
2320
2386
|
log8("Running the algorithm.", void 0, {
|
|
2321
2387
|
F: __dxlog_file9,
|
|
2322
|
-
L:
|
|
2388
|
+
L: 60,
|
|
2323
2389
|
S: this,
|
|
2324
2390
|
C: (f, a) => f(...a)
|
|
2325
2391
|
});
|
|
@@ -2330,7 +2396,7 @@ var MMSTTopology = class {
|
|
|
2330
2396
|
async onOffer(peer) {
|
|
2331
2397
|
invariant8(this._controller, "Not initialized", {
|
|
2332
2398
|
F: __dxlog_file9,
|
|
2333
|
-
L:
|
|
2399
|
+
L: 67,
|
|
2334
2400
|
S: this,
|
|
2335
2401
|
A: [
|
|
2336
2402
|
"this._controller",
|
|
@@ -2341,7 +2407,7 @@ var MMSTTopology = class {
|
|
|
2341
2407
|
const accept = connected.length < this._maxPeers;
|
|
2342
2408
|
log8(`Offer ${peer} accept=${accept}`, void 0, {
|
|
2343
2409
|
F: __dxlog_file9,
|
|
2344
|
-
L:
|
|
2410
|
+
L: 70,
|
|
2345
2411
|
S: this,
|
|
2346
2412
|
C: (f, a) => f(...a)
|
|
2347
2413
|
});
|
|
@@ -2352,7 +2418,7 @@ var MMSTTopology = class {
|
|
|
2352
2418
|
_runAlgorithm() {
|
|
2353
2419
|
invariant8(this._controller, "Not initialized", {
|
|
2354
2420
|
F: __dxlog_file9,
|
|
2355
|
-
L:
|
|
2421
|
+
L: 79,
|
|
2356
2422
|
S: this,
|
|
2357
2423
|
A: [
|
|
2358
2424
|
"this._controller",
|
|
@@ -2361,27 +2427,84 @@ var MMSTTopology = class {
|
|
|
2361
2427
|
});
|
|
2362
2428
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
2363
2429
|
if (connected.length > this._maxPeers) {
|
|
2430
|
+
log8(`disconnect ${connected.length - this._maxPeers} peers.`, void 0, {
|
|
2431
|
+
F: __dxlog_file9,
|
|
2432
|
+
L: 85,
|
|
2433
|
+
S: this,
|
|
2434
|
+
C: (f, a) => f(...a)
|
|
2435
|
+
});
|
|
2364
2436
|
const sorted = sortByXorDistance(connected, ownPeerId).reverse().slice(0, this._maxPeers - connected.length);
|
|
2365
|
-
|
|
2366
|
-
|
|
2437
|
+
invariant8(sorted.length === 0, void 0, {
|
|
2438
|
+
F: __dxlog_file9,
|
|
2439
|
+
L: 89,
|
|
2440
|
+
S: this,
|
|
2441
|
+
A: [
|
|
2442
|
+
"sorted.length === 0",
|
|
2443
|
+
""
|
|
2444
|
+
]
|
|
2445
|
+
});
|
|
2446
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2447
|
+
log8(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2448
|
+
F: __dxlog_file9,
|
|
2449
|
+
L: 92,
|
|
2450
|
+
S: this,
|
|
2451
|
+
C: (f, a) => f(...a)
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2455
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2456
|
+
log8(`Disconnect ${peer}.`, void 0, {
|
|
2457
|
+
F: __dxlog_file9,
|
|
2458
|
+
L: 97,
|
|
2459
|
+
S: this,
|
|
2460
|
+
C: (f, a) => f(...a)
|
|
2461
|
+
});
|
|
2462
|
+
this._controller.disconnect(peer);
|
|
2463
|
+
}
|
|
2464
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2465
|
+
} else {
|
|
2466
|
+
log8("rate limited discconnect", void 0, {
|
|
2367
2467
|
F: __dxlog_file9,
|
|
2368
|
-
L:
|
|
2468
|
+
L: 102,
|
|
2369
2469
|
S: this,
|
|
2370
2470
|
C: (f, a) => f(...a)
|
|
2371
2471
|
});
|
|
2372
|
-
this._controller.disconnect(peer);
|
|
2373
2472
|
}
|
|
2374
2473
|
} else if (connected.length < this._originateConnections) {
|
|
2474
|
+
log8(`connect ${this._originateConnections - connected.length} peers.`, void 0, {
|
|
2475
|
+
F: __dxlog_file9,
|
|
2476
|
+
L: 106,
|
|
2477
|
+
S: this,
|
|
2478
|
+
C: (f, a) => f(...a)
|
|
2479
|
+
});
|
|
2375
2480
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
2376
2481
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
2377
|
-
|
|
2378
|
-
log8(`
|
|
2482
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
2483
|
+
log8(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`, void 0, {
|
|
2379
2484
|
F: __dxlog_file9,
|
|
2380
|
-
L:
|
|
2485
|
+
L: 111,
|
|
2486
|
+
S: this,
|
|
2487
|
+
C: (f, a) => f(...a)
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
2491
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
2492
|
+
log8(`Connect ${peer}.`, void 0, {
|
|
2493
|
+
F: __dxlog_file9,
|
|
2494
|
+
L: 115,
|
|
2495
|
+
S: this,
|
|
2496
|
+
C: (f, a) => f(...a)
|
|
2497
|
+
});
|
|
2498
|
+
this._controller.connect(peer);
|
|
2499
|
+
}
|
|
2500
|
+
this._lastAction = /* @__PURE__ */ new Date();
|
|
2501
|
+
} else {
|
|
2502
|
+
log8("rate limited connect", void 0, {
|
|
2503
|
+
F: __dxlog_file9,
|
|
2504
|
+
L: 120,
|
|
2381
2505
|
S: this,
|
|
2382
2506
|
C: (f, a) => f(...a)
|
|
2383
2507
|
});
|
|
2384
|
-
this._controller.connect(peer);
|
|
2385
2508
|
}
|
|
2386
2509
|
}
|
|
2387
2510
|
}
|
|
@@ -2394,7 +2517,7 @@ var sortByXorDistance = (keys, reference) => keys.sort((a, b) => distance.gt(dis
|
|
|
2394
2517
|
// packages/core/mesh/network-manager/src/topology/star-topology.ts
|
|
2395
2518
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
2396
2519
|
import { log as log9 } from "@dxos/log";
|
|
2397
|
-
var __dxlog_file10 = "/home/
|
|
2520
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/topology/star-topology.ts";
|
|
2398
2521
|
var StarTopology = class {
|
|
2399
2522
|
constructor(_centralPeer) {
|
|
2400
2523
|
this._centralPeer = _centralPeer;
|
|
@@ -2493,7 +2616,7 @@ import { Event as Event7, Trigger } from "@dxos/async";
|
|
|
2493
2616
|
import { ErrorStream as ErrorStream3 } from "@dxos/debug";
|
|
2494
2617
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2495
2618
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
2496
|
-
import { log as log10, logInfo as
|
|
2619
|
+
import { log as log10, logInfo as logInfo3 } from "@dxos/log";
|
|
2497
2620
|
import { ComplexMap as ComplexMap7 } from "@dxos/util";
|
|
2498
2621
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
2499
2622
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2505,7 +2628,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
2505
2628
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2506
2629
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2507
2630
|
}
|
|
2508
|
-
var __dxlog_file11 = "/home/
|
|
2631
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/memory-transport.ts";
|
|
2509
2632
|
var MEMORY_TRANSPORT_DELAY = 1;
|
|
2510
2633
|
var createStreamDelay = (delay) => {
|
|
2511
2634
|
return new Transform({
|
|
@@ -2668,12 +2791,23 @@ var MemoryTransport = class _MemoryTransport {
|
|
|
2668
2791
|
this._remote.wake(remoteId);
|
|
2669
2792
|
}
|
|
2670
2793
|
}
|
|
2794
|
+
async getDetails() {
|
|
2795
|
+
return this._instanceId.toHex();
|
|
2796
|
+
}
|
|
2797
|
+
async getStats() {
|
|
2798
|
+
return {
|
|
2799
|
+
bytesSent: 0,
|
|
2800
|
+
bytesReceived: 0,
|
|
2801
|
+
packetsSent: 0,
|
|
2802
|
+
packetsReceived: 0
|
|
2803
|
+
};
|
|
2804
|
+
}
|
|
2671
2805
|
};
|
|
2672
2806
|
_ts_decorate4([
|
|
2673
|
-
|
|
2807
|
+
logInfo3
|
|
2674
2808
|
], MemoryTransport.prototype, "_instanceId", void 0);
|
|
2675
2809
|
_ts_decorate4([
|
|
2676
|
-
|
|
2810
|
+
logInfo3
|
|
2677
2811
|
], MemoryTransport.prototype, "_remoteInstanceId", void 0);
|
|
2678
2812
|
|
|
2679
2813
|
// packages/core/mesh/network-manager/src/transport/transport.ts
|
|
@@ -2703,8 +2837,11 @@ try {
|
|
|
2703
2837
|
}
|
|
2704
2838
|
|
|
2705
2839
|
// packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts
|
|
2706
|
-
var __dxlog_file12 = "/home/
|
|
2840
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport.ts";
|
|
2707
2841
|
var SimplePeerTransport = class {
|
|
2842
|
+
/**
|
|
2843
|
+
* @params opts.config formatted as per https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
|
|
2844
|
+
*/
|
|
2708
2845
|
constructor(params) {
|
|
2709
2846
|
this.params = params;
|
|
2710
2847
|
this._closed = false;
|
|
@@ -2717,13 +2854,13 @@ var SimplePeerTransport = class {
|
|
|
2717
2854
|
id: this._instanceId
|
|
2718
2855
|
}), {
|
|
2719
2856
|
F: __dxlog_file12,
|
|
2720
|
-
L:
|
|
2857
|
+
L: 44,
|
|
2721
2858
|
S: this,
|
|
2722
2859
|
C: (f, a) => f(...a)
|
|
2723
2860
|
});
|
|
2724
2861
|
log11("created connection", params, {
|
|
2725
2862
|
F: __dxlog_file12,
|
|
2726
|
-
L:
|
|
2863
|
+
L: 45,
|
|
2727
2864
|
S: this,
|
|
2728
2865
|
C: (f, a) => f(...a)
|
|
2729
2866
|
});
|
|
@@ -2736,7 +2873,7 @@ var SimplePeerTransport = class {
|
|
|
2736
2873
|
this._peer.on("signal", async (data) => {
|
|
2737
2874
|
log11("signal", data, {
|
|
2738
2875
|
F: __dxlog_file12,
|
|
2739
|
-
L:
|
|
2876
|
+
L: 54,
|
|
2740
2877
|
S: this,
|
|
2741
2878
|
C: (f, a) => f(...a)
|
|
2742
2879
|
});
|
|
@@ -2749,7 +2886,7 @@ var SimplePeerTransport = class {
|
|
|
2749
2886
|
this._peer.on("connect", () => {
|
|
2750
2887
|
log11("connected", void 0, {
|
|
2751
2888
|
F: __dxlog_file12,
|
|
2752
|
-
L:
|
|
2889
|
+
L: 59,
|
|
2753
2890
|
S: this,
|
|
2754
2891
|
C: (f, a) => f(...a)
|
|
2755
2892
|
});
|
|
@@ -2760,7 +2897,7 @@ var SimplePeerTransport = class {
|
|
|
2760
2897
|
this._peer.on("close", async () => {
|
|
2761
2898
|
log11("closed", void 0, {
|
|
2762
2899
|
F: __dxlog_file12,
|
|
2763
|
-
L:
|
|
2900
|
+
L: 66,
|
|
2764
2901
|
S: this,
|
|
2765
2902
|
C: (f, a) => f(...a)
|
|
2766
2903
|
});
|
|
@@ -2771,12 +2908,20 @@ var SimplePeerTransport = class {
|
|
|
2771
2908
|
if (err.errorDetail === "sctp-failure") {
|
|
2772
2909
|
this.errors.raise(new ConnectionResetError2("sctp-failure from RTCError", err));
|
|
2773
2910
|
} else {
|
|
2911
|
+
log11.info("unknown RTCError", {
|
|
2912
|
+
err
|
|
2913
|
+
}, {
|
|
2914
|
+
F: __dxlog_file12,
|
|
2915
|
+
L: 77,
|
|
2916
|
+
S: this,
|
|
2917
|
+
C: (f, a) => f(...a)
|
|
2918
|
+
});
|
|
2774
2919
|
this.errors.raise(new UnknownProtocolError2("unknown RTCError", err));
|
|
2775
2920
|
}
|
|
2776
2921
|
} else if ("code" in err) {
|
|
2777
2922
|
log11.info("simple-peer error", err, {
|
|
2778
2923
|
F: __dxlog_file12,
|
|
2779
|
-
L:
|
|
2924
|
+
L: 82,
|
|
2780
2925
|
S: this,
|
|
2781
2926
|
C: (f, a) => f(...a)
|
|
2782
2927
|
});
|
|
@@ -2784,10 +2929,12 @@ var SimplePeerTransport = class {
|
|
|
2784
2929
|
case "ERR_WEBRTC_SUPPORT":
|
|
2785
2930
|
this.errors.raise(new ProtocolError2("WebRTC not supported", err));
|
|
2786
2931
|
break;
|
|
2932
|
+
case "ERR_SIGNALING":
|
|
2933
|
+
this.errors.raise(new ConnectivityError2("signaling failure", err));
|
|
2934
|
+
break;
|
|
2787
2935
|
case "ERR_ICE_CONNECTION_FAILURE":
|
|
2788
2936
|
case "ERR_DATA_CHANNEL":
|
|
2789
2937
|
case "ERR_CONNECTION_FAILURE":
|
|
2790
|
-
case "ERR_SIGNALING":
|
|
2791
2938
|
this.errors.raise(new ConnectivityError2("unknown communication failure", err));
|
|
2792
2939
|
break;
|
|
2793
2940
|
case "ERR_CREATE_OFFER":
|
|
@@ -2804,7 +2951,7 @@ var SimplePeerTransport = class {
|
|
|
2804
2951
|
} else {
|
|
2805
2952
|
log11.info("unknown peer connection error", err, {
|
|
2806
2953
|
F: __dxlog_file12,
|
|
2807
|
-
L:
|
|
2954
|
+
L: 108,
|
|
2808
2955
|
S: this,
|
|
2809
2956
|
C: (f, a) => f(...a)
|
|
2810
2957
|
});
|
|
@@ -2815,10 +2962,10 @@ var SimplePeerTransport = class {
|
|
|
2815
2962
|
this._peer._pc.getStats().then((stats) => {
|
|
2816
2963
|
log11.info("report after webrtc error", {
|
|
2817
2964
|
config: this.params.webrtcConfig,
|
|
2818
|
-
stats
|
|
2965
|
+
stats: Object.fromEntries(stats.entries())
|
|
2819
2966
|
}, {
|
|
2820
2967
|
F: __dxlog_file12,
|
|
2821
|
-
L:
|
|
2968
|
+
L: 116,
|
|
2822
2969
|
S: this,
|
|
2823
2970
|
C: (f, a) => f(...a)
|
|
2824
2971
|
});
|
|
@@ -2827,7 +2974,7 @@ var SimplePeerTransport = class {
|
|
|
2827
2974
|
} catch (err2) {
|
|
2828
2975
|
log11.catch(err2, void 0, {
|
|
2829
2976
|
F: __dxlog_file12,
|
|
2830
|
-
L:
|
|
2977
|
+
L: 123,
|
|
2831
2978
|
S: this,
|
|
2832
2979
|
C: (f, a) => f(...a)
|
|
2833
2980
|
});
|
|
@@ -2838,28 +2985,81 @@ var SimplePeerTransport = class {
|
|
|
2838
2985
|
id: this._instanceId
|
|
2839
2986
|
}), {
|
|
2840
2987
|
F: __dxlog_file12,
|
|
2841
|
-
L:
|
|
2988
|
+
L: 129,
|
|
2842
2989
|
S: this,
|
|
2843
2990
|
C: (f, a) => f(...a)
|
|
2844
2991
|
});
|
|
2845
2992
|
}
|
|
2993
|
+
async getStats() {
|
|
2994
|
+
const stats = await this._getStats();
|
|
2995
|
+
if (!stats) {
|
|
2996
|
+
return {
|
|
2997
|
+
bytesSent: 0,
|
|
2998
|
+
bytesReceived: 0,
|
|
2999
|
+
packetsSent: 0,
|
|
3000
|
+
packetsReceived: 0,
|
|
3001
|
+
rawStats: {}
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
return {
|
|
3005
|
+
bytesSent: stats.transport.bytesSent,
|
|
3006
|
+
bytesReceived: stats.transport.bytesReceived,
|
|
3007
|
+
packetsSent: stats.transport.messagesSent,
|
|
3008
|
+
packetsReceived: stats.transport.messagesReceived,
|
|
3009
|
+
rawStats: stats.raw
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
async _getStats() {
|
|
3013
|
+
if (typeof this._peer?._pc?.getStats !== "function") {
|
|
3014
|
+
return null;
|
|
3015
|
+
}
|
|
3016
|
+
return await this._peer._pc.getStats().then((stats) => {
|
|
3017
|
+
const statsEntries = Array.from(stats.entries());
|
|
3018
|
+
const transport = statsEntries.filter((s) => s[1].type === "transport")[0][1];
|
|
3019
|
+
const candidatePair = statsEntries.filter((s) => s[0] === transport.selectedCandidatePairId);
|
|
3020
|
+
let selectedCandidatePair;
|
|
3021
|
+
let remoteCandidate;
|
|
3022
|
+
if (candidatePair.length > 0) {
|
|
3023
|
+
selectedCandidatePair = candidatePair[0][1];
|
|
3024
|
+
remoteCandidate = statsEntries.filter((s) => s[0] === selectedCandidatePair.remoteCandidateId)[0][1];
|
|
3025
|
+
}
|
|
3026
|
+
return {
|
|
3027
|
+
datachannel: statsEntries.filter((s) => s[1].type === "data-channel")[0][1],
|
|
3028
|
+
transport,
|
|
3029
|
+
selectedCandidatePair,
|
|
3030
|
+
remoteCandidate,
|
|
3031
|
+
raw: Object.fromEntries(stats.entries())
|
|
3032
|
+
};
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
async getDetails() {
|
|
3036
|
+
const stats = await this._getStats();
|
|
3037
|
+
const rc = stats?.remoteCandidate;
|
|
3038
|
+
if (!rc) {
|
|
3039
|
+
return "unavailable";
|
|
3040
|
+
}
|
|
3041
|
+
if (rc.candidateType === "relay") {
|
|
3042
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} relay for ${rc.relatedAddress}:${rc.relatedPort}`;
|
|
3043
|
+
}
|
|
3044
|
+
return `${rc.ip}:${rc.port}/${rc.protocol} ${rc.candidateType}`;
|
|
3045
|
+
}
|
|
2846
3046
|
async destroy() {
|
|
2847
3047
|
log11("closing...", void 0, {
|
|
2848
3048
|
F: __dxlog_file12,
|
|
2849
|
-
L:
|
|
3049
|
+
L: 192,
|
|
2850
3050
|
S: this,
|
|
2851
3051
|
C: (f, a) => f(...a)
|
|
2852
3052
|
});
|
|
2853
3053
|
if (this._closed) {
|
|
2854
3054
|
return;
|
|
2855
3055
|
}
|
|
2856
|
-
this._closed = true;
|
|
2857
3056
|
this._disconnectStreams();
|
|
2858
3057
|
this._peer.destroy();
|
|
3058
|
+
this._closed = true;
|
|
2859
3059
|
this.closed.emit();
|
|
2860
3060
|
log11("closed", void 0, {
|
|
2861
3061
|
F: __dxlog_file12,
|
|
2862
|
-
L:
|
|
3062
|
+
L: 200,
|
|
2863
3063
|
S: this,
|
|
2864
3064
|
C: (f, a) => f(...a)
|
|
2865
3065
|
});
|
|
@@ -2892,7 +3092,7 @@ import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
|
2892
3092
|
import { log as log12 } from "@dxos/log";
|
|
2893
3093
|
import { ConnectionState as ConnectionState3 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
2894
3094
|
import { ComplexMap as ComplexMap8 } from "@dxos/util";
|
|
2895
|
-
var __dxlog_file13 = "/home/
|
|
3095
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-service.ts";
|
|
2896
3096
|
var SimplePeerTransportService = class {
|
|
2897
3097
|
constructor(_webrtcConfig) {
|
|
2898
3098
|
this._webrtcConfig = _webrtcConfig;
|
|
@@ -2974,7 +3174,7 @@ var SimplePeerTransportService = class {
|
|
|
2974
3174
|
async sendSignal({ proxyId, signal }) {
|
|
2975
3175
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
2976
3176
|
F: __dxlog_file13,
|
|
2977
|
-
L:
|
|
3177
|
+
L: 116,
|
|
2978
3178
|
S: this,
|
|
2979
3179
|
A: [
|
|
2980
3180
|
"this.transports.has(proxyId)",
|
|
@@ -2983,18 +3183,46 @@ var SimplePeerTransportService = class {
|
|
|
2983
3183
|
});
|
|
2984
3184
|
await this.transports.get(proxyId).transport.signal(signal);
|
|
2985
3185
|
}
|
|
3186
|
+
async getDetails({ proxyId }) {
|
|
3187
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3188
|
+
F: __dxlog_file13,
|
|
3189
|
+
L: 121,
|
|
3190
|
+
S: this,
|
|
3191
|
+
A: [
|
|
3192
|
+
"this.transports.has(proxyId)",
|
|
3193
|
+
""
|
|
3194
|
+
]
|
|
3195
|
+
});
|
|
3196
|
+
return {
|
|
3197
|
+
details: await this.transports.get(proxyId).transport.getDetails()
|
|
3198
|
+
};
|
|
3199
|
+
}
|
|
3200
|
+
async getStats({ proxyId }) {
|
|
3201
|
+
invariant12(this.transports.has(proxyId), void 0, {
|
|
3202
|
+
F: __dxlog_file13,
|
|
3203
|
+
L: 126,
|
|
3204
|
+
S: this,
|
|
3205
|
+
A: [
|
|
3206
|
+
"this.transports.has(proxyId)",
|
|
3207
|
+
""
|
|
3208
|
+
]
|
|
3209
|
+
});
|
|
3210
|
+
return {
|
|
3211
|
+
stats: await this.transports.get(proxyId).transport.getStats()
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
2986
3214
|
async sendData({ proxyId, payload }) {
|
|
2987
3215
|
if (this.transports.get(proxyId)?.state !== "OPEN") {
|
|
2988
3216
|
log12.debug("transport is closed", void 0, {
|
|
2989
3217
|
F: __dxlog_file13,
|
|
2990
|
-
L:
|
|
3218
|
+
L: 132,
|
|
2991
3219
|
S: this,
|
|
2992
3220
|
C: (f, a) => f(...a)
|
|
2993
3221
|
});
|
|
2994
3222
|
}
|
|
2995
3223
|
invariant12(this.transports.has(proxyId), void 0, {
|
|
2996
3224
|
F: __dxlog_file13,
|
|
2997
|
-
L:
|
|
3225
|
+
L: 134,
|
|
2998
3226
|
S: this,
|
|
2999
3227
|
A: [
|
|
3000
3228
|
"this.transports.has(proxyId)",
|
|
@@ -3017,7 +3245,7 @@ var SimplePeerTransportService = class {
|
|
|
3017
3245
|
}
|
|
3018
3246
|
log12("Closed.", void 0, {
|
|
3019
3247
|
F: __dxlog_file13,
|
|
3020
|
-
L:
|
|
3248
|
+
L: 150,
|
|
3021
3249
|
S: this,
|
|
3022
3250
|
C: (f, a) => f(...a)
|
|
3023
3251
|
});
|
|
@@ -3032,10 +3260,10 @@ import { ErrorStream as ErrorStream5 } from "@dxos/debug";
|
|
|
3032
3260
|
import { invariant as invariant13 } from "@dxos/invariant";
|
|
3033
3261
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
3034
3262
|
import { log as log13 } from "@dxos/log";
|
|
3035
|
-
import { ConnectionResetError as ConnectionResetError3, TimeoutError as
|
|
3263
|
+
import { ConnectionResetError as ConnectionResetError3, TimeoutError as TimeoutError3, ProtocolError as ProtocolError3, ConnectivityError as ConnectivityError3, UnknownProtocolError as UnknownProtocolError3 } from "@dxos/protocols";
|
|
3036
3264
|
import { ConnectionState as ConnectionState4 } from "@dxos/protocols/proto/dxos/mesh/bridge";
|
|
3037
3265
|
import { arrayToBuffer } from "@dxos/util";
|
|
3038
|
-
var __dxlog_file14 = "/home/
|
|
3266
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/simplepeer-transport-proxy.ts";
|
|
3039
3267
|
var RESP_MIN_THRESHOLD = 500;
|
|
3040
3268
|
var TIMEOUT_THRESHOLD = 10;
|
|
3041
3269
|
var SimplePeerTransportProxy = class {
|
|
@@ -3088,9 +3316,9 @@ var SimplePeerTransportProxy = class {
|
|
|
3088
3316
|
}
|
|
3089
3317
|
this._timeoutCount = 0;
|
|
3090
3318
|
}, (err) => {
|
|
3091
|
-
if (err instanceof
|
|
3319
|
+
if (err instanceof TimeoutError3 || err.constructor.name === "TimeoutError") {
|
|
3092
3320
|
if (this._timeoutCount++ > TIMEOUT_THRESHOLD) {
|
|
3093
|
-
throw new
|
|
3321
|
+
throw new TimeoutError3(`too many timeoutes (${this._timeoutCount} > ${TIMEOUT_THRESHOLD}`);
|
|
3094
3322
|
} else {
|
|
3095
3323
|
log13("timeout error, but still invoking callback", void 0, {
|
|
3096
3324
|
F: __dxlog_file14,
|
|
@@ -3156,6 +3384,16 @@ var SimplePeerTransportProxy = class {
|
|
|
3156
3384
|
signal
|
|
3157
3385
|
}).catch((err) => this.errors.raise(decodeError(err)));
|
|
3158
3386
|
}
|
|
3387
|
+
async getDetails() {
|
|
3388
|
+
return (await this._params.bridgeService.getDetails({
|
|
3389
|
+
proxyId: this._proxyId
|
|
3390
|
+
})).details;
|
|
3391
|
+
}
|
|
3392
|
+
async getStats() {
|
|
3393
|
+
return (await this._params.bridgeService.getStats({
|
|
3394
|
+
proxyId: this._proxyId
|
|
3395
|
+
})).stats;
|
|
3396
|
+
}
|
|
3159
3397
|
// TODO(burdon): Move open from constructor.
|
|
3160
3398
|
async destroy() {
|
|
3161
3399
|
await this._ctx.dispose();
|
|
@@ -3170,7 +3408,7 @@ var SimplePeerTransportProxy = class {
|
|
|
3170
3408
|
} catch (err) {
|
|
3171
3409
|
log13.catch(err, void 0, {
|
|
3172
3410
|
F: __dxlog_file14,
|
|
3173
|
-
L:
|
|
3411
|
+
L: 168,
|
|
3174
3412
|
S: this,
|
|
3175
3413
|
C: (f, a) => f(...a)
|
|
3176
3414
|
});
|
|
@@ -3206,7 +3444,7 @@ var SimplePeerTransportProxyFactory = class {
|
|
|
3206
3444
|
createTransport(options) {
|
|
3207
3445
|
invariant13(this._bridgeService, "SimplePeerTransportProxyFactory is not ready to open connections", {
|
|
3208
3446
|
F: __dxlog_file14,
|
|
3209
|
-
L:
|
|
3447
|
+
L: 205,
|
|
3210
3448
|
S: this,
|
|
3211
3449
|
A: [
|
|
3212
3450
|
"this._bridgeService",
|
|
@@ -3227,7 +3465,7 @@ var decodeError = (err) => {
|
|
|
3227
3465
|
if (message.includes("CONNECTION_RESET")) {
|
|
3228
3466
|
return new ConnectionResetError3(message);
|
|
3229
3467
|
} else if (message.includes("TIMEOUT")) {
|
|
3230
|
-
return new
|
|
3468
|
+
return new TimeoutError3(message);
|
|
3231
3469
|
} else if (message.includes("PROTOCOL_ERROR")) {
|
|
3232
3470
|
return new ProtocolError3(message);
|
|
3233
3471
|
} else if (message.includes("CONNECTIVITY_ERROR")) {
|
|
@@ -3254,7 +3492,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3254
3492
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3255
3493
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3256
3494
|
}
|
|
3257
|
-
var __dxlog_file15 = "/home/
|
|
3495
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/core/mesh/network-manager/src/transport/libdatachannel-transport.ts";
|
|
3258
3496
|
var DATACHANNEL_LABEL = "dxos.mesh.transport";
|
|
3259
3497
|
var MAX_BUFFERED_AMOUNT = 64 * 1024;
|
|
3260
3498
|
var MAX_MESSAGE_SIZE = 64 * 1024;
|
|
@@ -3407,16 +3645,21 @@ var LibDataChannelTransport = class {
|
|
|
3407
3645
|
const duplex = new Duplex2({
|
|
3408
3646
|
read: () => {
|
|
3409
3647
|
},
|
|
3410
|
-
write: (chunk, encoding, callback) => {
|
|
3648
|
+
write: async (chunk, encoding, callback) => {
|
|
3411
3649
|
if (chunk.length > MAX_MESSAGE_SIZE) {
|
|
3412
3650
|
this.errors.raise(new Error(`message too large: ${chunk.length} > ${MAX_MESSAGE_SIZE}`));
|
|
3413
3651
|
}
|
|
3414
|
-
|
|
3652
|
+
try {
|
|
3653
|
+
dataChannel.send(chunk);
|
|
3654
|
+
} catch (err) {
|
|
3655
|
+
this.errors.raise(err);
|
|
3656
|
+
await this._close();
|
|
3657
|
+
}
|
|
3415
3658
|
if (this._channel.bufferedAmount > MAX_BUFFERED_AMOUNT) {
|
|
3416
3659
|
if (this._writeCallback !== null) {
|
|
3417
3660
|
log14.error("consumer trying to write before we're ready for more data", void 0, {
|
|
3418
3661
|
F: __dxlog_file15,
|
|
3419
|
-
L:
|
|
3662
|
+
L: 143,
|
|
3420
3663
|
S: this,
|
|
3421
3664
|
C: (f, a) => f(...a)
|
|
3422
3665
|
});
|
|
@@ -3441,7 +3684,7 @@ var LibDataChannelTransport = class {
|
|
|
3441
3684
|
err
|
|
3442
3685
|
}, {
|
|
3443
3686
|
F: __dxlog_file15,
|
|
3444
|
-
L:
|
|
3687
|
+
L: 163,
|
|
3445
3688
|
S: this,
|
|
3446
3689
|
C: (f, a) => f(...a)
|
|
3447
3690
|
});
|
|
@@ -3478,7 +3721,7 @@ var LibDataChannelTransport = class {
|
|
|
3478
3721
|
peer
|
|
3479
3722
|
}, {
|
|
3480
3723
|
F: __dxlog_file15,
|
|
3481
|
-
L:
|
|
3724
|
+
L: 198,
|
|
3482
3725
|
S: this,
|
|
3483
3726
|
C: (f, a) => f(...a)
|
|
3484
3727
|
});
|
|
@@ -3506,7 +3749,7 @@ var LibDataChannelTransport = class {
|
|
|
3506
3749
|
err
|
|
3507
3750
|
}, {
|
|
3508
3751
|
F: __dxlog_file15,
|
|
3509
|
-
L:
|
|
3752
|
+
L: 209,
|
|
3510
3753
|
S: this,
|
|
3511
3754
|
C: (f, a) => f(...a)
|
|
3512
3755
|
});
|
|
@@ -3526,7 +3769,7 @@ var LibDataChannelTransport = class {
|
|
|
3526
3769
|
err
|
|
3527
3770
|
}, {
|
|
3528
3771
|
F: __dxlog_file15,
|
|
3529
|
-
L:
|
|
3772
|
+
L: 220,
|
|
3530
3773
|
S: this,
|
|
3531
3774
|
C: (f, a) => f(...a)
|
|
3532
3775
|
});
|
|
@@ -3545,7 +3788,7 @@ var LibDataChannelTransport = class {
|
|
|
3545
3788
|
signal
|
|
3546
3789
|
}, {
|
|
3547
3790
|
F: __dxlog_file15,
|
|
3548
|
-
L:
|
|
3791
|
+
L: 231,
|
|
3549
3792
|
S: this,
|
|
3550
3793
|
C: (f, a) => f(...a)
|
|
3551
3794
|
});
|
|
@@ -3554,12 +3797,52 @@ var LibDataChannelTransport = class {
|
|
|
3554
3797
|
}).catch((err) => {
|
|
3555
3798
|
log14.catch(err, void 0, {
|
|
3556
3799
|
F: __dxlog_file15,
|
|
3557
|
-
L:
|
|
3800
|
+
L: 236,
|
|
3558
3801
|
S: this,
|
|
3559
3802
|
C: (f, a) => f(...a)
|
|
3560
3803
|
});
|
|
3561
3804
|
});
|
|
3562
3805
|
}
|
|
3806
|
+
async getDetails() {
|
|
3807
|
+
return this._peer.then(async (peer) => {
|
|
3808
|
+
const cp = await peer.getSelectedCandidatePair();
|
|
3809
|
+
if (!cp) {
|
|
3810
|
+
return "unavailable";
|
|
3811
|
+
}
|
|
3812
|
+
return `${cp.remote.address}:${cp.remote.port}/${cp.remote.transportType} ${cp.remote.type}`;
|
|
3813
|
+
}).catch((err) => {
|
|
3814
|
+
log14.catch(err, void 0, {
|
|
3815
|
+
F: __dxlog_file15,
|
|
3816
|
+
L: 250,
|
|
3817
|
+
S: this,
|
|
3818
|
+
C: (f, a) => f(...a)
|
|
3819
|
+
});
|
|
3820
|
+
return "unavailable";
|
|
3821
|
+
});
|
|
3822
|
+
}
|
|
3823
|
+
async getStats() {
|
|
3824
|
+
return this._peer.then((peer) => {
|
|
3825
|
+
return {
|
|
3826
|
+
bytesSent: peer.bytesSent(),
|
|
3827
|
+
bytesReceived: peer.bytesReceived(),
|
|
3828
|
+
packetsSent: 0,
|
|
3829
|
+
packetsReceived: 0
|
|
3830
|
+
};
|
|
3831
|
+
}).catch((err) => {
|
|
3832
|
+
log14.catch(err, void 0, {
|
|
3833
|
+
F: __dxlog_file15,
|
|
3834
|
+
L: 266,
|
|
3835
|
+
S: this,
|
|
3836
|
+
C: (f, a) => f(...a)
|
|
3837
|
+
});
|
|
3838
|
+
return {
|
|
3839
|
+
bytesSent: 0,
|
|
3840
|
+
bytesReceived: 0,
|
|
3841
|
+
packetsSent: 0,
|
|
3842
|
+
packetsReceived: 0
|
|
3843
|
+
};
|
|
3844
|
+
});
|
|
3845
|
+
}
|
|
3563
3846
|
// TODO(nf): add classmethod to call node-datachannel.cleanup() when all instances have been destroyed?
|
|
3564
3847
|
async destroy() {
|
|
3565
3848
|
await this._close();
|
|
@@ -3596,6 +3879,12 @@ var TcpTransport = class {
|
|
|
3596
3879
|
signal() {
|
|
3597
3880
|
throw new Error("Method not implemented.");
|
|
3598
3881
|
}
|
|
3882
|
+
async getStats() {
|
|
3883
|
+
throw new Error("Method not implemented.");
|
|
3884
|
+
}
|
|
3885
|
+
async getDetails() {
|
|
3886
|
+
throw new Error("Method not implemented.");
|
|
3887
|
+
}
|
|
3599
3888
|
};
|
|
3600
3889
|
|
|
3601
3890
|
// packages/core/mesh/network-manager/src/wire-protocol.ts
|
|
@@ -3605,8 +3894,8 @@ var createTeleportProtocolFactory = (onConnection) => {
|
|
|
3605
3894
|
const teleport = new Teleport(params);
|
|
3606
3895
|
return {
|
|
3607
3896
|
stream: teleport.stream,
|
|
3608
|
-
open: async () => {
|
|
3609
|
-
await teleport.open();
|
|
3897
|
+
open: async (sessionId) => {
|
|
3898
|
+
await teleport.open(sessionId);
|
|
3610
3899
|
await onConnection(teleport);
|
|
3611
3900
|
},
|
|
3612
3901
|
close: async () => {
|
|
@@ -3647,4 +3936,4 @@ export {
|
|
|
3647
3936
|
TcpTransport,
|
|
3648
3937
|
createTeleportProtocolFactory
|
|
3649
3938
|
};
|
|
3650
|
-
//# sourceMappingURL=chunk-
|
|
3939
|
+
//# sourceMappingURL=chunk-KGZ5C6JO.mjs.map
|