@dxos/network-manager 0.3.9-main.3a0f16f → 0.3.9-main.4e30508
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-4HITD6WI.mjs → chunk-J7KS7JMZ.mjs} +325 -87
- package/dist/lib/browser/chunk-J7KS7JMZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-6AD7QA4X.cjs → chunk-55WTPQV5.cjs} +334 -86
- package/dist/lib/node/chunk-55WTPQV5.cjs.map +7 -0
- package/dist/lib/node/{chunk-XE5JOIGD.cjs → chunk-JDKM4UPJ.cjs} +21 -13
- package/dist/lib/node/chunk-JDKM4UPJ.cjs.map +7 -0
- package/dist/lib/node/{datachannel-53JZPGFA.cjs → datachannel-3VTTIMR5.cjs} +9 -9
- package/dist/lib/node/{datachannel-53JZPGFA.cjs.map → datachannel-3VTTIMR5.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +32 -32
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +19 -19
- package/dist/types/src/connection-log.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +4 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/topology/mmst-topology.d.ts +1 -0
- package/dist/types/src/topology/mmst-topology.d.ts.map +1 -1
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts +7 -0
- package/dist/types/src/transport/datachannel/rtc-peer-connection.d.ts.map +1 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts +3 -1
- package/dist/types/src/transport/libdatachannel-transport.d.ts.map +1 -1
- package/dist/types/src/transport/memory-transport.d.ts +3 -1
- package/dist/types/src/transport/memory-transport.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-proxy.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts +3 -1
- package/dist/types/src/transport/simplepeer-transport-service.d.ts.map +1 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts +7 -1
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.browser.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.d.ts +3 -1
- package/dist/types/src/transport/tcp-transport.d.ts.map +1 -1
- package/dist/types/src/transport/transport.d.ts +17 -0
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/dist/types/src/wire-protocol.d.ts +1 -1
- package/dist/types/src/wire-protocol.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/connection-log.ts +14 -1
- package/src/swarm/connection.ts +23 -4
- package/src/topology/mmst-topology.ts +35 -7
- package/src/transport/datachannel/rtc-peer-connection.ts +20 -12
- package/src/transport/libdatachannel-transport.test.ts +0 -4
- package/src/transport/libdatachannel-transport.ts +37 -1
- package/src/transport/memory-transport.ts +14 -1
- package/src/transport/simplepeer-transport-proxy.ts +9 -1
- package/src/transport/simplepeer-transport-service.ts +14 -0
- package/src/transport/simplepeer-transport.ts +66 -2
- package/src/transport/tcp-transport.browser.ts +9 -1
- package/src/transport/tcp-transport.ts +19 -1
- package/src/transport/transport.ts +19 -0
- package/src/wire-protocol.ts +3 -3
- package/dist/lib/browser/chunk-4HITD6WI.mjs.map +0 -7
- package/dist/lib/node/chunk-6AD7QA4X.cjs.map +0 -7
- package/dist/lib/node/chunk-XE5JOIGD.cjs.map +0 -7
|
@@ -2,7 +2,7 @@ import { Event } from '@dxos/async';
|
|
|
2
2
|
import { ErrorStream } from '@dxos/debug';
|
|
3
3
|
import { PublicKey } from '@dxos/keys';
|
|
4
4
|
import { type SignalMessage, type SignalMessenger } from '../signal';
|
|
5
|
-
import { type Transport, type TransportFactory } from '../transport';
|
|
5
|
+
import { type Transport, type TransportFactory, type TransportStats } from '../transport';
|
|
6
6
|
import { type WireProtocol } from '../wire-protocol';
|
|
7
7
|
interface ConnectionCallbacks {
|
|
8
8
|
/**
|
|
@@ -70,10 +70,12 @@ export declare class Connection {
|
|
|
70
70
|
readonly stateChanged: Event<ConnectionState>;
|
|
71
71
|
readonly errors: ErrorStream;
|
|
72
72
|
_instanceId: string;
|
|
73
|
+
readonly transportStats: Event<TransportStats>;
|
|
73
74
|
private readonly _signalSendTask;
|
|
74
75
|
private _signallingDelay;
|
|
75
76
|
constructor(topic: PublicKey, ownId: PublicKey, // TODO(burdon): peerID?
|
|
76
77
|
remoteId: PublicKey, sessionId: PublicKey, initiator: boolean, _signalMessaging: SignalMessenger, _protocol: WireProtocol, _transportFactory: TransportFactory, _callbacks?: ConnectionCallbacks | undefined);
|
|
78
|
+
get sessionIdString(): string;
|
|
77
79
|
get state(): ConnectionState;
|
|
78
80
|
get transport(): Transport | undefined;
|
|
79
81
|
get protocol(): WireProtocol;
|
|
@@ -91,6 +93,7 @@ export declare class Connection {
|
|
|
91
93
|
signal(msg: SignalMessage): Promise<void>;
|
|
92
94
|
initiate(): void;
|
|
93
95
|
private _changeState;
|
|
96
|
+
private _emitTransportStats;
|
|
94
97
|
}
|
|
95
98
|
export {};
|
|
96
99
|
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAA2D,MAAM,aAAa,CAAC;AAE3G,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAavC,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AAC,YAAY,yBAAgC;IACrD,QAAQ,CAAC,MAAM,cAAqB;IAE7B,WAAW,SAA8B;IAEhD,SAAgB,cAAc,wBAA+B;IAE7D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAE7B;IAEH,OAAO,CAAC,gBAAgB,CAA6B;gBAGnC,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAAE,wBAAwB;IAC1C,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,OAAO,EACjB,gBAAgB,EAAE,eAAe,EACjC,SAAS,EAAE,YAAY,EACvB,iBAAiB,EAAE,gBAAgB,EACnC,UAAU,CAAC,iCAAqB;IAWnD,IACI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,KAAK,oBAER;IAED,IAAI,SAAS,0BAEZ;IAED,IAAI,QAAQ,iBAEX;IAED;;OAEG;IACG,cAAc;IA6Fd,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IAuCjB,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IAsDvB,OAAO,CAAC,WAAW;YAKL,kBAAkB;IAiChC;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,aAAa;IA2B/B,QAAQ;IAIR,OAAO,CAAC,YAAY;YAON,mBAAmB;CAMlC"}
|
|
@@ -20,6 +20,7 @@ export declare class MMSTTopology implements Topology {
|
|
|
20
20
|
private readonly _sampleSize;
|
|
21
21
|
private _controller?;
|
|
22
22
|
private _sampleCollected;
|
|
23
|
+
private _lastAction;
|
|
23
24
|
constructor({ originateConnections, maxPeers, sampleSize }?: MMSTTopologyOptions);
|
|
24
25
|
init(controller: SwarmController): void;
|
|
25
26
|
update(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mmst-topology.d.ts","sourceRoot":"","sources":["../../../../src/topology/mmst-topology.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"mmst-topology.d.ts","sourceRoot":"","sources":["../../../../src/topology/mmst-topology.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKjE,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,YAAa,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,WAAW,CAAC,CAAkB;IAEtC,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,WAAW,CAAe;gBAEtB,EAAE,oBAAwB,EAAE,QAAY,EAAE,UAAe,EAAE,GAAE,mBAAwB;IAMjG,IAAI,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAKvC,MAAM,IAAI,IAAI;IAWR,OAAO,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ1C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,OAAO,CAAC,aAAa;IA+CrB,QAAQ;CAGT"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SelectedCandidateInfo } from 'node-datachannel';
|
|
1
2
|
export declare class PeerConnection extends EventTarget implements RTCPeerConnection {
|
|
2
3
|
#private;
|
|
3
4
|
static generateCertificate(keygenAlgorithm: AlgorithmIdentifier): Promise<RTCCertificate>;
|
|
@@ -24,9 +25,15 @@ export declare class PeerConnection extends EventTarget implements RTCPeerConnec
|
|
|
24
25
|
get pendingRemoteDescription(): RTCSessionDescription | null;
|
|
25
26
|
get remoteDescription(): RTCSessionDescription | null;
|
|
26
27
|
addIceCandidate(candidate?: RTCIceCandidateInit): Promise<void>;
|
|
28
|
+
getSelectedCandidatePair(): {
|
|
29
|
+
local: SelectedCandidateInfo;
|
|
30
|
+
remote: SelectedCandidateInfo;
|
|
31
|
+
} | null;
|
|
27
32
|
addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender;
|
|
28
33
|
addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
|
|
29
34
|
close(): void;
|
|
35
|
+
bytesSent(): number;
|
|
36
|
+
bytesReceived(): number;
|
|
30
37
|
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
31
38
|
createOffer(options?: RTCOfferOptions): Promise<RTCSessionDescriptionInit>;
|
|
32
39
|
createOffer(successCallback: RTCSessionDescriptionCallback, failureCallback: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rtc-peer-connection.d.ts","sourceRoot":"","sources":["../../../../../src/transport/datachannel/rtc-peer-connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rtc-peer-connection.d.ts","sourceRoot":"","sources":["../../../../../src/transport/datachannel/rtc-peer-connection.ts"],"names":[],"mappings":"AAIA,OAAa,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAQpE,qBAAa,cAAe,SAAQ,WAAY,YAAW,iBAAiB;;WAC7D,mBAAmB,CAAC,eAAe,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAI/F,uBAAuB,EAAE,OAAO,GAAG,IAAI,CAAC;IACxC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAC;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,YAAY,IAAI,cAAc,EAAE;IAIhC,UAAU,IAAI,YAAY,EAAE;IAItB,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC;IAI3E,eAAe,IAAI,iBAAiB,EAAE;IAItC,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIvC,UAAU,IAAI,IAAI;IAIlB,gBAAgB,CAAC,aAAa,GAAE,gBAAqB,GAAG,IAAI;IAItD,mBAAmB,CAAC,WAAW,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAehF,oBAAoB,CAAC,WAAW,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQlF;AAED,OAAO,EAAE,cAAc,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Event } from '@dxos/async';
|
|
3
3
|
import { ErrorStream } from '@dxos/debug';
|
|
4
4
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
5
|
-
import { type Transport, type TransportFactory } from './transport';
|
|
5
|
+
import { type Transport, type TransportFactory, type TransportStats } from './transport';
|
|
6
6
|
export type LibDataChannelTransportParams = {
|
|
7
7
|
initiator: boolean;
|
|
8
8
|
stream: NodeJS.ReadWriteStream;
|
|
@@ -28,6 +28,8 @@ export declare class LibDataChannelTransport implements Transport {
|
|
|
28
28
|
private handleChannel;
|
|
29
29
|
private _close;
|
|
30
30
|
signal(signal: Signal): void;
|
|
31
|
+
getDetails(): Promise<string>;
|
|
32
|
+
getStats(): Promise<TransportStats>;
|
|
31
33
|
destroy(): Promise<void>;
|
|
32
34
|
private _disconnectStreams;
|
|
33
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libdatachannel-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/libdatachannel-transport.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,KAAK,EAAyB,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,EAAE,6BAA6B;IA+ElE,OAAO,CAAC,aAAa;YA2DP,MAAM;IASpB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAiDtB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAe7B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAsBnC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIhB,kBAAkB;CAGjC;AAED,eAAO,MAAM,oCAAoC,kBAAmB,GAAG,KAAG,gBAMxE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
2
|
import { ErrorStream } from '@dxos/debug';
|
|
3
3
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
4
|
-
import { type Transport, type TransportFactory, type TransportOptions } from './transport';
|
|
4
|
+
import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from './transport';
|
|
5
5
|
export declare const MemoryTransportFactory: TransportFactory;
|
|
6
6
|
/**
|
|
7
7
|
* Fake transport.
|
|
@@ -22,5 +22,7 @@ export declare class MemoryTransport implements Transport {
|
|
|
22
22
|
constructor(options: TransportOptions);
|
|
23
23
|
destroy(): Promise<void>;
|
|
24
24
|
signal({ payload }: Signal): void;
|
|
25
|
+
getDetails(): Promise<string>;
|
|
26
|
+
getStats(): Promise<TransportStats>;
|
|
25
27
|
}
|
|
26
28
|
//# sourceMappingURL=memory-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"memory-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/memory-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAkBhH,eAAO,MAAM,sBAAsB,EAAE,gBAEpC,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAuBnC,OAAO,CAAC,QAAQ,CAAC,OAAO;IArBpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA8D;IAElG,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAG3C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAElD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IAEpD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAE5E,OAAO,CAAC,UAAU,CAAS;IAG3B,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,iBAAiB,CAAC,CAAkB;gBAEf,OAAO,EAAE,gBAAgB;IA4DhD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkC9B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM;IAapB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;CAQ1C"}
|
|
@@ -3,7 +3,7 @@ import { Event } from '@dxos/async';
|
|
|
3
3
|
import { ErrorStream } from '@dxos/debug';
|
|
4
4
|
import { type BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
5
5
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
6
|
-
import { type Transport, type TransportFactory, type TransportOptions } from './transport';
|
|
6
|
+
import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from './transport';
|
|
7
7
|
export type SimplePeerTransportProxyParams = {
|
|
8
8
|
initiator: boolean;
|
|
9
9
|
stream: NodeJS.ReadWriteStream;
|
|
@@ -25,6 +25,8 @@ export declare class SimplePeerTransportProxy implements Transport {
|
|
|
25
25
|
private _handleData;
|
|
26
26
|
private _handleSignal;
|
|
27
27
|
signal(signal: Signal): void;
|
|
28
|
+
getDetails(): Promise<string>;
|
|
29
|
+
getStats(): Promise<TransportStats>;
|
|
28
30
|
destroy(): Promise<void>;
|
|
29
31
|
/**
|
|
30
32
|
* Called when underlying proxy service becomes unavailable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplepeer-transport-proxy.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport-proxy.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAW1C,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC/G,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAGpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"simplepeer-transport-proxy.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport-proxy.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;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,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAShE,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS;CAatD"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Stream } from '@dxos/codec-protobuf';
|
|
2
|
-
import { type BridgeService, type ConnectionRequest, type SignalRequest, type DataRequest, type BridgeEvent, type CloseRequest } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
2
|
+
import { type BridgeService, type ConnectionRequest, type SignalRequest, type DataRequest, type BridgeEvent, type CloseRequest, type DetailsRequest, type DetailsResponse, type StatsRequest, type StatsResponse } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
3
3
|
export declare class SimplePeerTransportService implements BridgeService {
|
|
4
4
|
private readonly _webrtcConfig?;
|
|
5
5
|
private readonly transports;
|
|
6
6
|
constructor(_webrtcConfig?: any);
|
|
7
7
|
open(request: ConnectionRequest): Stream<BridgeEvent>;
|
|
8
8
|
sendSignal({ proxyId, signal }: SignalRequest): Promise<void>;
|
|
9
|
+
getDetails({ proxyId }: DetailsRequest): Promise<DetailsResponse>;
|
|
10
|
+
getStats({ proxyId }: StatsRequest): Promise<StatsResponse>;
|
|
9
11
|
sendData({ proxyId, payload }: DataRequest): Promise<void>;
|
|
10
12
|
close({ proxyId }: CloseRequest): Promise<void>;
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplepeer-transport-service.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport-service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"simplepeer-transport-service.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport-service.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAC;AAYhD,qBAAa,0BAA2B,YAAW,aAAa;IAGlD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC;IAF3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6D;gBAE3D,aAAa,CAAC,KAAK;IAEhD,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAAC,WAAW,CAAC;IA2E/C,UAAU,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7D,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAKjE,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAK3D,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAc1D,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,YAAY;CAQtC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Event } from '@dxos/async';
|
|
3
3
|
import { ErrorStream } from '@dxos/debug';
|
|
4
4
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
5
|
-
import { type Transport, type TransportFactory } from './transport';
|
|
5
|
+
import { type Transport, type TransportFactory, type TransportStats } from './transport';
|
|
6
6
|
export type SimplePeerTransportParams = {
|
|
7
7
|
initiator: boolean;
|
|
8
8
|
stream: NodeJS.ReadWriteStream;
|
|
@@ -21,7 +21,13 @@ export declare class SimplePeerTransport implements Transport {
|
|
|
21
21
|
readonly connected: Event<void>;
|
|
22
22
|
readonly errors: ErrorStream;
|
|
23
23
|
private readonly _instanceId;
|
|
24
|
+
/**
|
|
25
|
+
* @params opts.config formatted as per https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection
|
|
26
|
+
*/
|
|
24
27
|
constructor(params: SimplePeerTransportParams);
|
|
28
|
+
getStats(): Promise<TransportStats>;
|
|
29
|
+
_getStats(): Promise<any>;
|
|
30
|
+
getDetails(): Promise<string>;
|
|
25
31
|
destroy(): Promise<void>;
|
|
26
32
|
signal(signal: Signal): void;
|
|
27
33
|
private _disconnectStreams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplepeer-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"simplepeer-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/simplepeer-transport.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAGzF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAC/B,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAoB,YAAW,SAAS;IAcvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAbnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IAEvB,QAAQ,CAAC,MAAM,cAAe;IAC9B,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,MAAM,cAAqB;IAEpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAE1D;;OAEG;gBAC0B,MAAM,EAAE,yBAAyB;IAyFxD,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAsBnC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC;IAwBzB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAa7B,OAAO;IAab,MAAM,CAAC,MAAM,EAAE,MAAM;IASrB,OAAO,CAAC,kBAAkB;CAM3B;AAED,eAAO,MAAM,gCAAgC,kBAAmB,GAAG,KAAG,gBAMpE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
2
|
import { ErrorStream } from '@dxos/debug';
|
|
3
|
-
import { type Transport, type TransportFactory } from './transport';
|
|
3
|
+
import { type Transport, type TransportFactory, type TransportStats } from './transport';
|
|
4
4
|
export declare const TcpTransportFactory: TransportFactory;
|
|
5
5
|
export declare class TcpTransport implements Transport {
|
|
6
6
|
readonly closed: Event<void>;
|
|
@@ -8,5 +8,7 @@ export declare class TcpTransport implements Transport {
|
|
|
8
8
|
readonly errors: ErrorStream;
|
|
9
9
|
destroy(): Promise<void>;
|
|
10
10
|
signal(): void;
|
|
11
|
+
getStats(): Promise<TransportStats>;
|
|
12
|
+
getDetails(): Promise<string>;
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=tcp-transport.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-transport.browser.d.ts","sourceRoot":"","sources":["../../../../src/transport/tcp-transport.browser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tcp-transport.browser.d.ts","sourceRoot":"","sources":["../../../../src/transport/tcp-transport.browser.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAIzF,eAAO,MAAM,mBAAmB,EAAE,gBAEjC,CAAC;AAEF,qBAAa,YAAa,YAAW,SAAS;IAC5C,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAErC,OAAO;IAIb,MAAM;IAIA,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAInC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;CAGpC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
2
|
import { ErrorStream } from '@dxos/debug';
|
|
3
3
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
4
|
-
import { type Transport, type TransportFactory, type TransportOptions } from './transport';
|
|
4
|
+
import { type Transport, type TransportFactory, type TransportOptions, type TransportStats } from './transport';
|
|
5
5
|
export declare const TcpTransportFactory: TransportFactory;
|
|
6
6
|
/**
|
|
7
7
|
* Fake transport.
|
|
@@ -18,6 +18,8 @@ export declare class TcpTransport implements Transport {
|
|
|
18
18
|
constructor(options: TransportOptions);
|
|
19
19
|
destroy(): Promise<void>;
|
|
20
20
|
signal({ payload }: Signal): void;
|
|
21
|
+
getDetails(): Promise<string>;
|
|
22
|
+
getStats(): Promise<TransportStats>;
|
|
21
23
|
private _handleSocket;
|
|
22
24
|
}
|
|
23
25
|
//# sourceMappingURL=tcp-transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/tcp-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tcp-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/tcp-transport.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhH,eAAO,MAAM,mBAAmB,EAAE,gBAEjC,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAa,YAAW,SAAS;IAYhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAXpC,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,OAAO,CAAC,CAAqB;IAErC,SAAgB,MAAM,cAAqB;IAC3C,SAAgB,SAAS,cAAqB;IAC9C,SAAgB,MAAM,cAAqB;IAE3C,OAAO,CAAC,UAAU,CAAS;IAE3B,OAAO,CAAC,UAAU,CAAS;gBAEE,OAAO,EAAE,gBAAgB;IAsChD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM;IAWpB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAS7B,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IASzC,OAAO,CAAC,aAAa;CAiBtB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type Event } from '@dxos/async';
|
|
3
3
|
import { type ErrorStream } from '@dxos/debug';
|
|
4
|
+
import { type PublicKey } from '@dxos/keys';
|
|
4
5
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
5
6
|
export declare enum TransportKind {
|
|
6
7
|
SIMPLE_PEER = "SIMPLE_PEER",
|
|
@@ -16,6 +17,14 @@ export interface Transport {
|
|
|
16
17
|
closed: Event;
|
|
17
18
|
connected: Event;
|
|
18
19
|
errors: ErrorStream;
|
|
20
|
+
/**
|
|
21
|
+
* Transport-specfic stats.
|
|
22
|
+
*/
|
|
23
|
+
getStats(): Promise<TransportStats>;
|
|
24
|
+
/**
|
|
25
|
+
* Transport-specfic connection details.
|
|
26
|
+
*/
|
|
27
|
+
getDetails(): Promise<string>;
|
|
19
28
|
destroy(): Promise<void>;
|
|
20
29
|
signal(signal: Signal): void;
|
|
21
30
|
}
|
|
@@ -33,6 +42,7 @@ export type TransportOptions = {
|
|
|
33
42
|
*/
|
|
34
43
|
sendSignal: (signal: Signal) => Promise<void>;
|
|
35
44
|
timeout?: number;
|
|
45
|
+
sessionId?: PublicKey;
|
|
36
46
|
};
|
|
37
47
|
/**
|
|
38
48
|
*
|
|
@@ -40,4 +50,11 @@ export type TransportOptions = {
|
|
|
40
50
|
export interface TransportFactory {
|
|
41
51
|
createTransport(options: TransportOptions): Transport;
|
|
42
52
|
}
|
|
53
|
+
export type TransportStats = {
|
|
54
|
+
bytesSent: number;
|
|
55
|
+
bytesReceived: number;
|
|
56
|
+
packetsSent: number;
|
|
57
|
+
packetsReceived: number;
|
|
58
|
+
rawStats?: any;
|
|
59
|
+
};
|
|
43
60
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/transport.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAEpE,oBAAY,aAAa;IACvB,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,MAAM,WAAW;IACjB,GAAG,QAAQ;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,WAAW,CAAC;IAEpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAE/B;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9C,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceR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,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC"}
|
|
@@ -15,7 +15,7 @@ export type WireProtocolProvider = (params: WireProtocolParams) => WireProtocol;
|
|
|
15
15
|
*/
|
|
16
16
|
export interface WireProtocol {
|
|
17
17
|
stream: Duplex;
|
|
18
|
-
open(): Promise<void>;
|
|
18
|
+
open(sessionId?: PublicKey): Promise<void>;
|
|
19
19
|
close(): Promise<void>;
|
|
20
20
|
abort(): Promise<void>;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire-protocol.d.ts","sourceRoot":"","sources":["../../../src/wire-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,SAAS,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IAEf,IAAI,
|
|
1
|
+
{"version":3,"file":"wire-protocol.d.ts","sourceRoot":"","sources":["../../../src/wire-protocol.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,SAAS,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IAEf,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,4BACf,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAClD,oBAiBF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/network-manager",
|
|
3
|
-
"version": "0.3.9-main.
|
|
3
|
+
"version": "0.3.9-main.4e30508",
|
|
4
4
|
"description": "Network Manager",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
"tiny-invariant": "^1.3.1",
|
|
32
32
|
"ws": "^8.14.2",
|
|
33
33
|
"xor-distance": "^2.0.0",
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/context": "0.3.9-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/credentials": "0.3.9-main.
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/log": "0.3.9-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/protocols": "0.3.9-main.
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/util": "0.3.9-main.
|
|
34
|
+
"@dxos/async": "0.3.9-main.4e30508",
|
|
35
|
+
"@dxos/context": "0.3.9-main.4e30508",
|
|
36
|
+
"@dxos/codec-protobuf": "0.3.9-main.4e30508",
|
|
37
|
+
"@dxos/credentials": "0.3.9-main.4e30508",
|
|
38
|
+
"@dxos/crypto": "0.3.9-main.4e30508",
|
|
39
|
+
"@dxos/invariant": "0.3.9-main.4e30508",
|
|
40
|
+
"@dxos/debug": "0.3.9-main.4e30508",
|
|
41
|
+
"@dxos/keys": "0.3.9-main.4e30508",
|
|
42
|
+
"@dxos/log": "0.3.9-main.4e30508",
|
|
43
|
+
"@dxos/node-std": "0.3.9-main.4e30508",
|
|
44
|
+
"@dxos/messaging": "0.3.9-main.4e30508",
|
|
45
|
+
"@dxos/protocols": "0.3.9-main.4e30508",
|
|
46
|
+
"@dxos/teleport": "0.3.9-main.4e30508",
|
|
47
|
+
"@dxos/rpc": "0.3.9-main.4e30508",
|
|
48
|
+
"@dxos/util": "0.3.9-main.4e30508"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@swc-node/register": "1.5.4",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"earljs": "~0.1.10",
|
|
56
56
|
"fast-check": "~3.3.0",
|
|
57
57
|
"typescript": "^5.2.2",
|
|
58
|
-
"@dxos/signal": "0.3.9-main.
|
|
58
|
+
"@dxos/signal": "0.3.9-main.4e30508"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
package/src/connection-log.ts
CHANGED
|
@@ -64,7 +64,7 @@ export class ConnectionLog {
|
|
|
64
64
|
info.connections!.push(connectionInfo);
|
|
65
65
|
this.update.emit();
|
|
66
66
|
|
|
67
|
-
connection.stateChanged.on((state) => {
|
|
67
|
+
connection.stateChanged.on(async (state) => {
|
|
68
68
|
connectionInfo.state = state;
|
|
69
69
|
connectionInfo.closeReason = connection.closeReason;
|
|
70
70
|
connectionInfo.lastUpdate = new Date();
|
|
@@ -72,6 +72,12 @@ export class ConnectionLog {
|
|
|
72
72
|
type: EventType.CONNECTION_STATE_CHANGED,
|
|
73
73
|
newState: state,
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
if (state === ConnectionState.CONNECTED) {
|
|
77
|
+
const details = await connection.transport?.getDetails();
|
|
78
|
+
connectionInfo.transportDetails = details;
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
this.update.emit();
|
|
76
82
|
});
|
|
77
83
|
|
|
@@ -83,6 +89,13 @@ export class ConnectionLog {
|
|
|
83
89
|
this.update.emit();
|
|
84
90
|
});
|
|
85
91
|
|
|
92
|
+
connection.transportStats?.on((stats) => {
|
|
93
|
+
connectionInfo.transportBytesSent = stats.bytesSent;
|
|
94
|
+
connectionInfo.transportBytesReceived = stats.bytesReceived;
|
|
95
|
+
connectionInfo.transportPacketsSent = stats.packetsSent;
|
|
96
|
+
connectionInfo.transportPacketsReceived = stats.packetsReceived;
|
|
97
|
+
});
|
|
98
|
+
|
|
86
99
|
gcSwarm(info);
|
|
87
100
|
|
|
88
101
|
// connection.protocol.protocol?.error.on((error) => {
|
package/src/swarm/connection.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2021 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { DeferredTask, Event, sleep, scheduleTask, synchronized } from '@dxos/async';
|
|
5
|
+
import { DeferredTask, Event, sleep, scheduleTask, scheduleTaskInterval, synchronized } from '@dxos/async';
|
|
6
6
|
import { Context, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { ErrorStream } from '@dxos/debug';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
10
|
+
import { log, logInfo } from '@dxos/log';
|
|
11
11
|
import {
|
|
12
12
|
CancelledError,
|
|
13
13
|
ProtocolError,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
import { type Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
21
21
|
|
|
22
22
|
import { type SignalMessage, type SignalMessenger } from '../signal';
|
|
23
|
-
import { type Transport, type TransportFactory } from '../transport';
|
|
23
|
+
import { type Transport, type TransportFactory, type TransportStats } from '../transport';
|
|
24
24
|
import { type WireProtocol } from '../wire-protocol';
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -34,6 +34,8 @@ const STARTING_SIGNALLING_DELAY = 10;
|
|
|
34
34
|
*/
|
|
35
35
|
const TRANSPORT_CONNECTION_TIMEOUT = 10_000;
|
|
36
36
|
|
|
37
|
+
const TRANSPORT_STATS_INTERVAL = 5_000;
|
|
38
|
+
|
|
37
39
|
/**
|
|
38
40
|
* Maximum delay between signal batches.
|
|
39
41
|
*/
|
|
@@ -110,6 +112,8 @@ export class Connection {
|
|
|
110
112
|
|
|
111
113
|
public _instanceId = PublicKey.random().toHex();
|
|
112
114
|
|
|
115
|
+
public readonly transportStats = new Event<TransportStats>();
|
|
116
|
+
|
|
113
117
|
private readonly _signalSendTask = new DeferredTask(this._ctx, async () => {
|
|
114
118
|
await this._flushSignalBuffer();
|
|
115
119
|
});
|
|
@@ -136,6 +140,11 @@ export class Connection {
|
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
142
|
|
|
143
|
+
@logInfo
|
|
144
|
+
get sessionIdString(): string {
|
|
145
|
+
return this.sessionId.truncate();
|
|
146
|
+
}
|
|
147
|
+
|
|
139
148
|
get state() {
|
|
140
149
|
return this._state;
|
|
141
150
|
}
|
|
@@ -165,7 +174,7 @@ export class Connection {
|
|
|
165
174
|
this._changeState(ConnectionState.CONNECTING);
|
|
166
175
|
|
|
167
176
|
// TODO(dmaretskyi): Initialize only after the transport has established connection.
|
|
168
|
-
this._protocol.open().catch((err) => {
|
|
177
|
+
this._protocol.open(this.sessionId).catch((err) => {
|
|
169
178
|
this.errors.raise(err);
|
|
170
179
|
});
|
|
171
180
|
|
|
@@ -191,12 +200,15 @@ export class Connection {
|
|
|
191
200
|
initiator: this.initiator,
|
|
192
201
|
stream: this._protocol.stream,
|
|
193
202
|
sendSignal: async (signal) => this._sendSignal(signal),
|
|
203
|
+
sessionId: this.sessionId,
|
|
194
204
|
});
|
|
195
205
|
|
|
196
206
|
this._transport.connected.once(async () => {
|
|
197
207
|
this._changeState(ConnectionState.CONNECTED);
|
|
198
208
|
await this.connectedTimeoutContext.dispose();
|
|
199
209
|
this._callbacks?.onConnected?.();
|
|
210
|
+
|
|
211
|
+
scheduleTaskInterval(this._ctx, async () => this._emitTransportStats(), TRANSPORT_STATS_INTERVAL);
|
|
200
212
|
});
|
|
201
213
|
|
|
202
214
|
this._transport.closed.once(() => {
|
|
@@ -412,4 +424,11 @@ export class Connection {
|
|
|
412
424
|
this._state = state;
|
|
413
425
|
this.stateChanged.emit(state);
|
|
414
426
|
}
|
|
427
|
+
|
|
428
|
+
private async _emitTransportStats() {
|
|
429
|
+
const stats = await this.transport?.getStats();
|
|
430
|
+
if (stats) {
|
|
431
|
+
this.transportStats.emit(stats);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
415
434
|
}
|
|
@@ -10,6 +10,9 @@ import { log } from '@dxos/log';
|
|
|
10
10
|
|
|
11
11
|
import { type SwarmController, type Topology } from './topology';
|
|
12
12
|
|
|
13
|
+
const MIN_UPDATE_INTERVAL = 1000 * 10;
|
|
14
|
+
const MAX_CHANGES_PER_UPDATE = 1;
|
|
15
|
+
|
|
13
16
|
export interface MMSTTopologyOptions {
|
|
14
17
|
/**
|
|
15
18
|
* Number of connections the peer will originate by itself.
|
|
@@ -36,6 +39,8 @@ export class MMSTTopology implements Topology {
|
|
|
36
39
|
|
|
37
40
|
private _sampleCollected = false;
|
|
38
41
|
|
|
42
|
+
private _lastAction = new Date(0);
|
|
43
|
+
|
|
39
44
|
constructor({ originateConnections = 2, maxPeers = 4, sampleSize = 10 }: MMSTTopologyOptions = {}) {
|
|
40
45
|
this._originateConnections = originateConnections;
|
|
41
46
|
this._maxPeers = maxPeers;
|
|
@@ -52,7 +57,7 @@ export class MMSTTopology implements Topology {
|
|
|
52
57
|
const { connected, candidates } = this._controller.getState();
|
|
53
58
|
// Run the algorithms if we have first candidates, ran it before, or have more connections than needed.
|
|
54
59
|
if (this._sampleCollected || connected.length > this._maxPeers || candidates.length > 0) {
|
|
55
|
-
log('Running the algorithm.');
|
|
60
|
+
log.info('Running the algorithm.');
|
|
56
61
|
this._sampleCollected = true;
|
|
57
62
|
this._runAlgorithm();
|
|
58
63
|
}
|
|
@@ -74,22 +79,45 @@ export class MMSTTopology implements Topology {
|
|
|
74
79
|
invariant(this._controller, 'Not initialized');
|
|
75
80
|
const { connected, candidates, ownPeerId } = this._controller.getState();
|
|
76
81
|
|
|
82
|
+
// TODO(nf): does this rate limiting/flap dampening logic belong here or in the SwarmController?
|
|
77
83
|
if (connected.length > this._maxPeers) {
|
|
78
84
|
// Disconnect extra peers.
|
|
85
|
+
log.info(`disconnect ${connected.length - this._maxPeers} peers.`);
|
|
79
86
|
const sorted = sortByXorDistance(connected, ownPeerId)
|
|
80
87
|
.reverse()
|
|
81
88
|
.slice(0, this._maxPeers - connected.length);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
invariant(sorted.length === 0);
|
|
90
|
+
|
|
91
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
92
|
+
log(`want to disconnect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
96
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
97
|
+
log.info(`Disconnect ${peer}.`);
|
|
98
|
+
this._controller.disconnect(peer);
|
|
99
|
+
}
|
|
100
|
+
this._lastAction = new Date();
|
|
101
|
+
} else {
|
|
102
|
+
log.info('rate limited discconnect');
|
|
85
103
|
}
|
|
86
104
|
} else if (connected.length < this._originateConnections) {
|
|
87
105
|
// Connect new peers to reach desired quota.
|
|
106
|
+
log.info(`connect ${this._originateConnections - connected.length} peers.`);
|
|
88
107
|
const sample = candidates.sort(() => Math.random() - 0.5).slice(0, this._sampleSize);
|
|
89
108
|
const sorted = sortByXorDistance(sample, ownPeerId).slice(0, this._originateConnections - connected.length);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
|
|
110
|
+
if (sorted.length > MAX_CHANGES_PER_UPDATE) {
|
|
111
|
+
log(`want to connect ${sorted.length} peers but limited to ${MAX_CHANGES_PER_UPDATE}`);
|
|
112
|
+
}
|
|
113
|
+
if (Date.now() - this._lastAction.getTime() > MIN_UPDATE_INTERVAL) {
|
|
114
|
+
for (const peer of sorted.slice(0, MAX_CHANGES_PER_UPDATE)) {
|
|
115
|
+
log.info(`Connect ${peer}.`);
|
|
116
|
+
this._controller.connect(peer);
|
|
117
|
+
}
|
|
118
|
+
this._lastAction = new Date();
|
|
119
|
+
} else {
|
|
120
|
+
log.info('rate limited connect');
|
|
93
121
|
}
|
|
94
122
|
}
|
|
95
123
|
}
|