@dxos/network-manager 0.1.58-main.47053bc → 0.1.58-main.4cbb52d
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-O2SMNRBC.mjs → chunk-CNQ55TFQ.mjs} +18 -19
- package/dist/lib/browser/chunk-CNQ55TFQ.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 +155 -22
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +44 -45
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +202 -70
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/types/src/swarm/connection-limiter.d.ts +1 -1
- package/dist/types/src/swarm/connection-limiter.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -1
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/tests/tcp-transport.test.d.ts +2 -0
- package/dist/types/src/tests/tcp-transport.test.d.ts.map +1 -0
- package/dist/types/src/transport/simplepeer-transport.d.ts.map +1 -1
- package/dist/types/src/transport/tcp-transport.d.ts +23 -0
- package/dist/types/src/transport/tcp-transport.d.ts.map +1 -0
- package/dist/types/src/transport/transport.d.ts +2 -1
- package/dist/types/src/transport/transport.d.ts.map +1 -1
- package/package.json +17 -18
- package/src/swarm/connection-limiter.ts +2 -2
- package/src/swarm/connection.ts +5 -5
- package/src/swarm/peer.ts +1 -1
- package/src/testing/test-builder.ts +5 -1
- package/src/tests/tcp-transport.test.ts +67 -0
- package/src/transport/simplepeer-transport-proxy.ts +4 -4
- package/src/transport/simplepeer-transport.ts +1 -2
- package/src/transport/tcp-transport.ts +107 -0
- package/src/transport/transport.ts +1 -0
- package/dist/lib/browser/chunk-O2SMNRBC.mjs.map +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeferredTask } from '@dxos/async';
|
|
2
2
|
import { PublicKey } from '@dxos/keys';
|
|
3
|
-
export declare const MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
3
|
+
export declare const MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
4
4
|
export type ConnectionLimiterOptions = {
|
|
5
5
|
maxConcurrentInitConnections?: number;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-limiter.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection-limiter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"connection-limiter.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection-limiter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,eAAO,MAAM,qCAAqC,KAAK,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,4BAA4B,CAAC,EAAE,MAAM,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC/C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAE/B;IAEF,sBAAsB,eAMnB;gBAES,EAAE,4BAAoE,EAAE,GAAE,wBAA6B;IAInH;;OAEG;IACG,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS;CASpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAAuB,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,EAAuB,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAahD,UAAU,mBAAmB;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB;;OAEG;IACH,OAAO,YAAY;IAEnB;;;OAGG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,UAAU,eAAe;IAEzB;;OAEG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,MAAM,WAAW;IAEjB,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,qBAAa,UAAU;aAsBH,KAAK,EAAE,SAAS;aAChB,KAAK,EAAE,SAAS;aAChB,QAAQ,EAAE,SAAS;aACnB,SAAS,EAAE,SAAS;aACpB,SAAS,EAAE,OAAO;IAClC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IA7B9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IAEtC,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,UAAU,CAAwB;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,qBAAqB,CAAgB;IAC7C,OAAO,CAAC,qBAAqB,CAAgB;IAE7C,QAAQ,CAAC,YAAY,yBAAgC;IACrD,QAAQ,CAAC,MAAM,cAAqB;IAE7B,WAAW,SAA8B;IAEhD,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,IAAI,KAAK,oBAER;IAED,IAAI,SAAS,0BAEZ;IAED,IAAI,QAAQ,iBAEX;IAED;;OAEG;IACG,cAAc;IA4Ed,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IAsCjB,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK;IAuCvB,OAAO,CAAC,WAAW;YAKL,kBAAkB;IAgChC;;OAEG;IACG,MAAM,CAAC,GAAG,EAAE,aAAa;IA2B/B,QAAQ;IAIR,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Event } from '@dxos/async';
|
|
2
|
-
import { SystemError } from '@dxos/errors';
|
|
3
2
|
import { PublicKey } from '@dxos/keys';
|
|
3
|
+
import { SystemError } from '@dxos/protocols';
|
|
4
4
|
import { Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
5
5
|
import { OfferMessage, SignalMessage, SignalMessenger } from '../signal';
|
|
6
6
|
import { TransportFactory } from '../transport';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../../../src/swarm/peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../../../src/swarm/peer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAkB,WAAW,EAAgB,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,qBAAa,wBAAyB,SAAQ,WAAW;;CAIxD;AAED,UAAU,aAAa;IACrB;;OAEG;IACH,WAAW,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAE9C;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,OA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AAC,MAAM,GAAE,SAA8B;CAGlD;AAED;;GAEG;AACH,qBAAa,QAAQ;IAiBjB,OAAO,CAAC,QAAQ,CAAC,WAAW;aACZ,MAAM,EAAE,SAAS;aACjB,SAAS,CAAC;IAlB5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkE;IAY1F,OAAO,CAAC,MAAM,CAAC,CAAoB;IACnC,OAAO,CAAC,QAAQ,CAAC,CAAoB;gBAGlB,WAAW,EAAE,WAAW,EACzB,MAAM,EAAE,SAAS,EACjB,SAAS,CAAC,2BAAe;IAc3C,oBAAoB,CAAC,SAAS,EAAE,aAAa;IAgEvC,IAAI;IAMJ,KAAK;IASX,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,mBAAmB;IAS/C,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,gBAAgB,GAAE,4BAAuC,GAAG,mBAAmB;IAWvG,SAAS;IAIT,QAAQ;CAGf;AAGD,qBAAa,mBAAmB;IAI5B,QAAQ,CAAC,IAAI,EAAE,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS;IACzB,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B;IALzD,QAAQ,EAAE,gBAAgB,CAAC;gBAGhB,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,EAChB,gBAAgB,EAAE,4BAA4B;IASnD,IAAI,CAAC,QAAQ,yBAA+B;IAW5C,KAAK;CAIZ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcp-transport.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/tcp-transport.test.ts"],"names":[],"mappings":""}
|
|
@@ -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;
|
|
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,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1D,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;IAUvC,OAAO,CAAC,QAAQ,CAAC,MAAM;IATnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,QAAQ,CAAC,MAAM,cAAe;IAC9B,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,MAAM,cAAqB;IAEpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;gBAE7B,MAAM,EAAE,yBAAyB;IAkFxD,OAAO;IASb,MAAM,CAAC,MAAM,EAAE,MAAM;YASP,kBAAkB;CAIjC;AAED,eAAO,MAAM,gCAAgC,kBAAmB,GAAG,KAAG,gBAMpE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Event } from '@dxos/async';
|
|
2
|
+
import { ErrorStream } from '@dxos/debug';
|
|
3
|
+
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
4
|
+
import { Transport, TransportFactory, TransportOptions } from './transport';
|
|
5
|
+
export declare const TcpTransportFactory: TransportFactory;
|
|
6
|
+
/**
|
|
7
|
+
* Fake transport.
|
|
8
|
+
*/
|
|
9
|
+
export declare class TcpTransport implements Transport {
|
|
10
|
+
private readonly options;
|
|
11
|
+
private _server?;
|
|
12
|
+
private _socket?;
|
|
13
|
+
readonly closed: Event<void>;
|
|
14
|
+
readonly connected: Event<void>;
|
|
15
|
+
readonly errors: ErrorStream;
|
|
16
|
+
private _destroyed;
|
|
17
|
+
private _connected;
|
|
18
|
+
constructor(options: TransportOptions);
|
|
19
|
+
destroy(): Promise<void>;
|
|
20
|
+
signal({ payload }: Signal): void;
|
|
21
|
+
private _handleSocket;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=tcp-transport.d.ts.map
|
|
@@ -0,0 +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,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE5E,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;IAW1B,OAAO,CAAC,aAAa;CAiBtB"}
|
|
@@ -6,7 +6,8 @@ export declare enum TransportKind {
|
|
|
6
6
|
SIMPLE_PEER = "SIMPLE_PEER",
|
|
7
7
|
LIBDATACHANNEL = "LIBDATACHANNEL",
|
|
8
8
|
SIMPLE_PEER_PROXY = "SIMPLE_PEER_PROXY",
|
|
9
|
-
MEMORY = "MEMORY"
|
|
9
|
+
MEMORY = "MEMORY",
|
|
10
|
+
TCP = "TCP"
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* Abstraction over a P2P connection transport. Currently either WebRTC or in-memory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/transport.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,oBAAY,aAAa;IACvB,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,iBAAiB,sBAAsB;IACvC,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/transport.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,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;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/network-manager",
|
|
3
|
-
"version": "0.1.58-main.
|
|
3
|
+
"version": "0.1.58-main.4cbb52d",
|
|
4
4
|
"description": "Network Manager",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,22 +30,21 @@
|
|
|
30
30
|
"tiny-invariant": "^1.3.1",
|
|
31
31
|
"ws": "^7.4.4",
|
|
32
32
|
"xor-distance": "^2.0.0",
|
|
33
|
-
"@dxos/async": "0.1.58-main.
|
|
34
|
-
"@dxos/codec-protobuf": "0.1.58-main.
|
|
35
|
-
"@dxos/context": "0.1.58-main.
|
|
36
|
-
"@dxos/credentials": "0.1.58-main.
|
|
37
|
-
"@dxos/crypto": "0.1.58-main.
|
|
38
|
-
"@dxos/debug": "0.1.58-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/util": "0.1.58-main.47053bc"
|
|
33
|
+
"@dxos/async": "0.1.58-main.4cbb52d",
|
|
34
|
+
"@dxos/codec-protobuf": "0.1.58-main.4cbb52d",
|
|
35
|
+
"@dxos/context": "0.1.58-main.4cbb52d",
|
|
36
|
+
"@dxos/credentials": "0.1.58-main.4cbb52d",
|
|
37
|
+
"@dxos/crypto": "0.1.58-main.4cbb52d",
|
|
38
|
+
"@dxos/debug": "0.1.58-main.4cbb52d",
|
|
39
|
+
"@dxos/invariant": "0.1.58-main.4cbb52d",
|
|
40
|
+
"@dxos/keys": "0.1.58-main.4cbb52d",
|
|
41
|
+
"@dxos/log": "0.1.58-main.4cbb52d",
|
|
42
|
+
"@dxos/messaging": "0.1.58-main.4cbb52d",
|
|
43
|
+
"@dxos/node-std": "0.1.58-main.4cbb52d",
|
|
44
|
+
"@dxos/protocols": "0.1.58-main.4cbb52d",
|
|
45
|
+
"@dxos/rpc": "0.1.58-main.4cbb52d",
|
|
46
|
+
"@dxos/teleport": "0.1.58-main.4cbb52d",
|
|
47
|
+
"@dxos/util": "0.1.58-main.4cbb52d"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@swc-node/register": "1.5.4",
|
|
@@ -55,7 +54,7 @@
|
|
|
55
54
|
"earljs": "~0.1.10",
|
|
56
55
|
"fast-check": "~3.3.0",
|
|
57
56
|
"typescript": "^5.2.2",
|
|
58
|
-
"@dxos/signal": "0.1.58-main.
|
|
57
|
+
"@dxos/signal": "0.1.58-main.4cbb52d"
|
|
59
58
|
},
|
|
60
59
|
"publishConfig": {
|
|
61
60
|
"access": "public"
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { DeferredTask } from '@dxos/async';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
|
-
import { CancelledError } from '@dxos/errors';
|
|
8
7
|
import { invariant } from '@dxos/invariant';
|
|
9
8
|
import { PublicKey } from '@dxos/keys';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
10
|
+
import { CancelledError } from '@dxos/protocols';
|
|
11
11
|
import { ComplexMap } from '@dxos/util';
|
|
12
12
|
|
|
13
|
-
export const MAX_CONCURRENT_INITIATING_CONNECTIONS =
|
|
13
|
+
export const MAX_CONCURRENT_INITIATING_CONNECTIONS = 50;
|
|
14
14
|
|
|
15
15
|
export type ConnectionLimiterOptions = {
|
|
16
16
|
maxConcurrentInitConnections?: number;
|
package/src/swarm/connection.ts
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
import { DeferredTask, Event, sleep, synchronized } from '@dxos/async';
|
|
6
6
|
import { Context, cancelWithContext } from '@dxos/context';
|
|
7
7
|
import { ErrorStream } from '@dxos/debug';
|
|
8
|
+
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { PublicKey } from '@dxos/keys';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
8
11
|
import {
|
|
9
12
|
CancelledError,
|
|
10
13
|
ProtocolError,
|
|
11
14
|
ConnectionResetError,
|
|
12
15
|
ConnectivityError,
|
|
13
16
|
UnknownProtocolError,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { PublicKey } from '@dxos/keys';
|
|
17
|
-
import { log } from '@dxos/log';
|
|
18
|
-
import { trace } from '@dxos/protocols';
|
|
17
|
+
trace,
|
|
18
|
+
} from '@dxos/protocols';
|
|
19
19
|
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
20
20
|
|
|
21
21
|
import { SignalMessage, SignalMessenger } from '../signal';
|
package/src/swarm/peer.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { Event, scheduleTask, synchronized } from '@dxos/async';
|
|
6
6
|
import { Context } from '@dxos/context';
|
|
7
|
-
import { CancelledError, SystemError, TimeoutError } from '@dxos/errors';
|
|
8
7
|
import { invariant } from '@dxos/invariant';
|
|
9
8
|
import { PublicKey } from '@dxos/keys';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
10
|
+
import { CancelledError, SystemError, TimeoutError } from '@dxos/protocols';
|
|
11
11
|
import { Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
12
12
|
|
|
13
13
|
import { OfferMessage, SignalMessage, SignalMessenger } from '../signal';
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
createLibDataChannelTransportFactory,
|
|
28
28
|
TransportKind,
|
|
29
29
|
} from '../transport';
|
|
30
|
+
import { TcpTransportFactory } from '../transport/tcp-transport';
|
|
30
31
|
import { TestWireProtocol, type TestTeleportExtensionFactory } from './test-wire-protocol';
|
|
31
32
|
|
|
32
33
|
// Signal server will be started by the setup script.
|
|
@@ -105,6 +106,9 @@ export class TestPeer {
|
|
|
105
106
|
switch (transport) {
|
|
106
107
|
case TransportKind.MEMORY:
|
|
107
108
|
throw new Error('Memory transport not supported with signal server.');
|
|
109
|
+
case TransportKind.TCP:
|
|
110
|
+
transportFactory = TcpTransportFactory;
|
|
111
|
+
break;
|
|
108
112
|
case TransportKind.SIMPLE_PEER:
|
|
109
113
|
transportFactory = createSimplePeerTransportFactory();
|
|
110
114
|
break;
|
|
@@ -146,7 +150,7 @@ export class TestPeer {
|
|
|
146
150
|
throw new Error(`Unsupported transport: ${transport}`);
|
|
147
151
|
}
|
|
148
152
|
} else {
|
|
149
|
-
if (transport !== TransportKind.MEMORY) {
|
|
153
|
+
if (transport !== TransportKind.MEMORY && transport !== TransportKind.TCP) {
|
|
150
154
|
log.warn(`specified transport ${transport} but no signalling configured, using memory transport instead`);
|
|
151
155
|
}
|
|
152
156
|
log.info(`using ${transport} transport without signal server.`);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2021 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { randomBytes } from 'crypto';
|
|
6
|
+
|
|
7
|
+
import { PublicKey } from '@dxos/keys';
|
|
8
|
+
import { test } from '@dxos/test';
|
|
9
|
+
import { range } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { TestBuilder } from '../testing';
|
|
12
|
+
import { FullyConnectedTopology } from '../topology';
|
|
13
|
+
import { TransportKind } from '../transport';
|
|
14
|
+
import { basicTestSuite } from './basic-test-suite';
|
|
15
|
+
import { exchangeMessages, joinSwarm, leaveSwarm, openAndCloseAfterTest } from './utils';
|
|
16
|
+
|
|
17
|
+
describe('Tcp transport', () => {
|
|
18
|
+
const testBuilder = new TestBuilder({
|
|
19
|
+
transport: TransportKind.TCP,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
basicTestSuite(testBuilder);
|
|
23
|
+
|
|
24
|
+
test
|
|
25
|
+
.skip('load', async () => {
|
|
26
|
+
const NUM_PAIRS = 100;
|
|
27
|
+
const NUM_ROUNDS = 10_000;
|
|
28
|
+
const PACKET_SIZE = 1_000;
|
|
29
|
+
|
|
30
|
+
const pairs = await Promise.all(
|
|
31
|
+
range(NUM_PAIRS).map(async () => {
|
|
32
|
+
const peer1 = testBuilder.createPeer();
|
|
33
|
+
const peer2 = testBuilder.createPeer();
|
|
34
|
+
await openAndCloseAfterTest([peer1, peer2]);
|
|
35
|
+
|
|
36
|
+
const topic = PublicKey.random();
|
|
37
|
+
const [swarm1, swarm2] = await joinSwarm([peer1, peer2], topic, () => new FullyConnectedTopology());
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
peer1,
|
|
41
|
+
peer2,
|
|
42
|
+
topic,
|
|
43
|
+
swarm1,
|
|
44
|
+
swarm2,
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const message = randomBytes(PACKET_SIZE / 2).toString('hex');
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < NUM_ROUNDS; i++) {
|
|
52
|
+
// console.log(`Round ${i}/${NUM_ROUNDS}`);
|
|
53
|
+
await Promise.all(
|
|
54
|
+
pairs.map(async ({ swarm1, swarm2 }) => {
|
|
55
|
+
await exchangeMessages(swarm1, swarm2, message);
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await Promise.all(
|
|
61
|
+
pairs.map(async ({ peer1, peer2, topic }) => {
|
|
62
|
+
await leaveSwarm([peer1, peer2], topic);
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
})
|
|
66
|
+
.timeout(1_000_000);
|
|
67
|
+
});
|
|
@@ -8,16 +8,16 @@ import { Event } from '@dxos/async';
|
|
|
8
8
|
import { Stream } from '@dxos/codec-protobuf';
|
|
9
9
|
import { Context } from '@dxos/context';
|
|
10
10
|
import { ErrorStream } from '@dxos/debug';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { PublicKey } from '@dxos/keys';
|
|
13
|
+
import { log } from '@dxos/log';
|
|
11
14
|
import {
|
|
12
15
|
ConnectionResetError,
|
|
13
16
|
TimeoutError,
|
|
14
17
|
ProtocolError,
|
|
15
18
|
ConnectivityError,
|
|
16
19
|
UnknownProtocolError,
|
|
17
|
-
} from '@dxos/
|
|
18
|
-
import { invariant } from '@dxos/invariant';
|
|
19
|
-
import { PublicKey } from '@dxos/keys';
|
|
20
|
-
import { log } from '@dxos/log';
|
|
20
|
+
} from '@dxos/protocols';
|
|
21
21
|
import { ConnectionState, BridgeEvent, BridgeService } from '@dxos/protocols/proto/dxos/mesh/bridge';
|
|
22
22
|
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
23
23
|
import { arrayToBuffer } from '@dxos/util';
|
|
@@ -8,10 +8,9 @@ import invariant from 'tiny-invariant';
|
|
|
8
8
|
|
|
9
9
|
import { Event } from '@dxos/async';
|
|
10
10
|
import { ErrorStream, raise } from '@dxos/debug';
|
|
11
|
-
import { ConnectionResetError, ConnectivityError, ProtocolError, UnknownProtocolError } from '@dxos/errors';
|
|
12
11
|
import { PublicKey } from '@dxos/keys';
|
|
13
12
|
import { log } from '@dxos/log';
|
|
14
|
-
import { trace } from '@dxos/protocols';
|
|
13
|
+
import { ConnectionResetError, ConnectivityError, ProtocolError, UnknownProtocolError, trace } from '@dxos/protocols';
|
|
15
14
|
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
16
15
|
|
|
17
16
|
import { Transport, TransportFactory } from './transport';
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2020 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { AddressInfo, Socket, type Server } from 'node:net';
|
|
6
|
+
|
|
7
|
+
import { Event } from '@dxos/async';
|
|
8
|
+
import { ErrorStream } from '@dxos/debug';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
11
|
+
|
|
12
|
+
import { Transport, TransportFactory, TransportOptions } from './transport';
|
|
13
|
+
|
|
14
|
+
export const TcpTransportFactory: TransportFactory = {
|
|
15
|
+
createTransport: (params) => new TcpTransport(params),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Fake transport.
|
|
20
|
+
*/
|
|
21
|
+
export class TcpTransport implements Transport {
|
|
22
|
+
private _server?: Server = undefined;
|
|
23
|
+
private _socket?: Socket = undefined;
|
|
24
|
+
|
|
25
|
+
public readonly closed = new Event<void>();
|
|
26
|
+
public readonly connected = new Event<void>();
|
|
27
|
+
public readonly errors = new ErrorStream();
|
|
28
|
+
|
|
29
|
+
private _destroyed = false;
|
|
30
|
+
|
|
31
|
+
private _connected = false;
|
|
32
|
+
|
|
33
|
+
constructor(private readonly options: TransportOptions) {
|
|
34
|
+
log('creating');
|
|
35
|
+
|
|
36
|
+
// Initiator will send a signal, the receiver will receive the unique ID and connect the streams.
|
|
37
|
+
if (this.options.initiator) {
|
|
38
|
+
// prettier-ignore
|
|
39
|
+
setTimeout(async () => {
|
|
40
|
+
const { Server } = await import('node:net');
|
|
41
|
+
this._server = new Server(socket => {
|
|
42
|
+
log('new connection');
|
|
43
|
+
if (this._connected) {
|
|
44
|
+
socket.destroy();
|
|
45
|
+
}
|
|
46
|
+
this._handleSocket(socket);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
this._server.on('listening', () => {
|
|
50
|
+
const { port } = this._server!.address() as AddressInfo;
|
|
51
|
+
log('listening', { port });
|
|
52
|
+
void this.options.sendSignal({
|
|
53
|
+
payload: { port }
|
|
54
|
+
}).catch(err => {
|
|
55
|
+
if (!this._destroyed) {
|
|
56
|
+
this.errors.raise(err);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
this._server.on('error', err => {
|
|
63
|
+
this.errors.raise(err);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
this._server.listen(0);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async destroy(): Promise<void> {
|
|
72
|
+
log('closing');
|
|
73
|
+
this._socket?.destroy();
|
|
74
|
+
this._server?.close();
|
|
75
|
+
|
|
76
|
+
this._destroyed = true;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
signal({ payload }: Signal) {
|
|
80
|
+
log('received signal', { payload });
|
|
81
|
+
if (this.options.initiator || this._connected) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const socket = new Socket();
|
|
86
|
+
this._handleSocket(socket);
|
|
87
|
+
socket.connect({ port: payload.port, host: 'localhost' });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private _handleSocket(socket: Socket) {
|
|
91
|
+
log('handling socket', { remotePort: socket.remotePort, localPort: socket.localPort });
|
|
92
|
+
this._socket = socket;
|
|
93
|
+
this.connected.emit();
|
|
94
|
+
this.options.stream.pipe(this._socket!).pipe(this.options.stream);
|
|
95
|
+
|
|
96
|
+
this._socket.on('connect', () => {
|
|
97
|
+
log('connected to', { port: this._socket?.remotePort });
|
|
98
|
+
this._connected = true;
|
|
99
|
+
});
|
|
100
|
+
this._socket.on('error', (err) => {
|
|
101
|
+
this.errors.raise(err);
|
|
102
|
+
});
|
|
103
|
+
this._socket.on('close', () => {
|
|
104
|
+
this.closed.emit();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|