@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.0

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.
Files changed (231) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
  3. package/dist/src/connection/ConnectionLockRpcLocal.js +8 -8
  4. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  5. package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
  6. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  7. package/dist/src/connection/ConnectionManager.d.ts +4 -6
  8. package/dist/src/connection/ConnectionManager.js +128 -103
  9. package/dist/src/connection/ConnectionManager.js.map +1 -1
  10. package/dist/src/connection/ConnectorFacade.d.ts +15 -14
  11. package/dist/src/connection/ConnectorFacade.js +70 -52
  12. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  13. package/dist/src/connection/Handshaker.d.ts +9 -2
  14. package/dist/src/connection/Handshaker.js +117 -27
  15. package/dist/src/connection/Handshaker.js.map +1 -1
  16. package/dist/src/connection/ManagedConnection.d.ts +13 -38
  17. package/dist/src/connection/ManagedConnection.js +31 -252
  18. package/dist/src/connection/ManagedConnection.js.map +1 -1
  19. package/dist/src/connection/OutputBuffer.d.ts +9 -0
  20. package/dist/src/connection/OutputBuffer.js +26 -0
  21. package/dist/src/connection/OutputBuffer.js.map +1 -0
  22. package/dist/src/connection/PendingConnection.d.ts +19 -0
  23. package/dist/src/connection/PendingConnection.js +59 -0
  24. package/dist/src/connection/PendingConnection.js.map +1 -0
  25. package/dist/src/connection/connectivityChecker.js +3 -3
  26. package/dist/src/connection/connectivityChecker.js.map +1 -1
  27. package/dist/src/connection/connectivityRequestHandler.js +2 -2
  28. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  29. package/dist/src/connection/simulator/Simulator.d.ts +1 -3
  30. package/dist/src/connection/simulator/Simulator.js +1 -4
  31. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  32. package/dist/src/connection/simulator/SimulatorConnection.js +1 -2
  33. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
  34. package/dist/src/connection/simulator/SimulatorConnector.d.ts +3 -3
  35. package/dist/src/connection/simulator/SimulatorConnector.js +28 -21
  36. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  37. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -6
  38. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +3 -20
  39. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  40. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +11 -6
  41. package/dist/src/connection/webrtc/WebrtcConnector.js +57 -42
  42. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  43. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +8 -10
  44. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +21 -44
  45. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  46. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +8 -2
  47. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -1
  48. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +3 -3
  49. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +8 -8
  50. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
  51. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +1 -1
  52. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -1
  53. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +26 -0
  54. package/dist/src/connection/websocket/WebsocketClientConnector.js +86 -0
  55. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -0
  56. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +19 -0
  57. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +23 -0
  58. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -0
  59. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +5 -0
  60. package/dist/src/connection/websocket/{WebsocketConnectorRpcRemote.js → WebsocketClientConnectorRpcRemote.js} +4 -4
  61. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -0
  62. package/dist/src/connection/websocket/WebsocketServer.d.ts +8 -5
  63. package/dist/src/connection/websocket/WebsocketServer.js +11 -11
  64. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
  65. package/dist/src/connection/websocket/{WebsocketConnector.d.ts → WebsocketServerConnector.d.ts} +16 -21
  66. package/dist/src/connection/websocket/{WebsocketConnector.js → WebsocketServerConnector.js} +112 -160
  67. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -0
  68. package/dist/src/dht/DhtNode.d.ts +4 -4
  69. package/dist/src/dht/DhtNode.js +85 -84
  70. package/dist/src/dht/DhtNode.js.map +1 -1
  71. package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
  72. package/dist/src/dht/DhtNodeRpcLocal.js +9 -9
  73. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  74. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  75. package/dist/src/dht/ExternalApiRpcLocal.js +5 -5
  76. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  77. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  78. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  79. package/dist/src/dht/PeerManager.d.ts +4 -4
  80. package/dist/src/dht/PeerManager.js +22 -22
  81. package/dist/src/dht/PeerManager.js.map +1 -1
  82. package/dist/src/dht/contact/SortedContactList.d.ts +3 -3
  83. package/dist/src/dht/contact/SortedContactList.js +9 -9
  84. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  85. package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -3
  86. package/dist/src/dht/discovery/DiscoverySession.js +21 -21
  87. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  88. package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -3
  89. package/dist/src/dht/discovery/PeerDiscovery.js +46 -44
  90. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  91. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +3 -3
  92. package/dist/src/dht/discovery/RingDiscoverySession.js +19 -19
  93. package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
  94. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
  95. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +33 -33
  96. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  97. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +3 -3
  98. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +8 -8
  99. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
  100. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +4 -4
  101. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +24 -24
  102. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  103. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -4
  104. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -5
  105. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
  106. package/dist/src/dht/routing/Router.d.ts +3 -3
  107. package/dist/src/dht/routing/Router.js +20 -20
  108. package/dist/src/dht/routing/Router.js.map +1 -1
  109. package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -3
  110. package/dist/src/dht/routing/RouterRpcLocal.js +16 -16
  111. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  112. package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
  113. package/dist/src/dht/routing/RoutingSession.js +24 -24
  114. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  115. package/dist/src/dht/store/StoreManager.d.ts +3 -3
  116. package/dist/src/dht/store/StoreManager.js +25 -25
  117. package/dist/src/dht/store/StoreManager.js.map +1 -1
  118. package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
  119. package/dist/src/dht/store/StoreRpcLocal.js +12 -12
  120. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  121. package/dist/src/exports.d.ts +3 -0
  122. package/dist/src/exports.js +5 -1
  123. package/dist/src/exports.js.map +1 -1
  124. package/dist/src/proto/google/protobuf/any.d.ts +5 -8
  125. package/dist/src/proto/google/protobuf/any.js.map +1 -1
  126. package/dist/src/proto/google/protobuf/empty.d.ts +1 -0
  127. package/dist/src/proto/google/protobuf/empty.js.map +1 -1
  128. package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -10
  129. package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
  130. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
  131. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
  132. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  133. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +3 -3
  134. package/dist/src/proto/packages/dht/protos/DhtRpc.js +4 -4
  135. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  136. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
  137. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
  138. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -2
  139. package/dist/src/transport/ListeningRpcCommunicator.js +2 -2
  140. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  141. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -2
  142. package/dist/src/transport/RoutingRpcCommunicator.js +2 -2
  143. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  144. package/package.json +7 -7
  145. package/protos/DhtRpc.proto +1 -1
  146. package/src/connection/ConnectionLockRpcLocal.ts +9 -9
  147. package/src/connection/ConnectionLockRpcRemote.ts +1 -1
  148. package/src/connection/ConnectionManager.ts +153 -111
  149. package/src/connection/ConnectorFacade.ts +84 -61
  150. package/src/connection/Handshaker.ts +131 -27
  151. package/src/connection/ManagedConnection.ts +41 -304
  152. package/src/connection/OutputBuffer.ts +28 -0
  153. package/src/connection/PendingConnection.ts +68 -0
  154. package/src/connection/connectivityChecker.ts +2 -2
  155. package/src/connection/connectivityRequestHandler.ts +1 -1
  156. package/src/connection/simulator/Simulator.ts +1 -5
  157. package/src/connection/simulator/SimulatorConnection.ts +1 -2
  158. package/src/connection/simulator/SimulatorConnector.ts +34 -33
  159. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -6
  160. package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -24
  161. package/src/connection/webrtc/WebrtcConnector.ts +73 -62
  162. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +26 -56
  163. package/src/connection/websocket/AbstractWebsocketClientConnection.ts +8 -2
  164. package/src/connection/websocket/AutoCertifierClientFacade.ts +11 -11
  165. package/src/connection/websocket/NodeWebsocketClientConnection.ts +1 -1
  166. package/src/connection/websocket/WebsocketClientConnector.ts +119 -0
  167. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +39 -0
  168. package/src/connection/websocket/{WebsocketConnectorRpcRemote.ts → WebsocketClientConnectorRpcRemote.ts} +2 -2
  169. package/src/connection/websocket/WebsocketServer.ts +18 -14
  170. package/src/connection/websocket/{WebsocketConnector.ts → WebsocketServerConnector.ts} +128 -205
  171. package/src/dht/DhtNode.ts +90 -89
  172. package/src/dht/DhtNodeRpcLocal.ts +11 -11
  173. package/src/dht/ExternalApiRpcLocal.ts +6 -6
  174. package/src/dht/ExternalApiRpcRemote.ts +2 -2
  175. package/src/dht/PeerManager.ts +24 -24
  176. package/src/dht/contact/SortedContactList.ts +10 -10
  177. package/src/dht/discovery/DiscoverySession.ts +24 -24
  178. package/src/dht/discovery/PeerDiscovery.ts +47 -45
  179. package/src/dht/discovery/RingDiscoverySession.ts +23 -23
  180. package/src/dht/recursive-operation/RecursiveOperationManager.ts +36 -36
  181. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +9 -9
  182. package/src/dht/recursive-operation/RecursiveOperationSession.ts +25 -25
  183. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +7 -7
  184. package/src/dht/routing/Router.ts +21 -21
  185. package/src/dht/routing/RouterRpcLocal.ts +17 -17
  186. package/src/dht/routing/RoutingSession.ts +26 -26
  187. package/src/dht/store/StoreManager.ts +27 -27
  188. package/src/dht/store/StoreRpcLocal.ts +13 -13
  189. package/src/exports.ts +3 -0
  190. package/src/proto/google/protobuf/any.ts +6 -9
  191. package/src/proto/google/protobuf/empty.ts +2 -1
  192. package/src/proto/google/protobuf/timestamp.ts +2 -11
  193. package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
  194. package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
  195. package/src/proto/packages/dht/protos/DhtRpc.ts +4 -4
  196. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
  197. package/src/transport/ListeningRpcCommunicator.ts +3 -3
  198. package/src/transport/RoutingRpcCommunicator.ts +3 -3
  199. package/test/end-to-end/Layer0Webrtc.test.ts +0 -10
  200. package/test/integration/ConnectionManager.test.ts +3 -2
  201. package/test/integration/GeoIpConnectivityChecking.test.ts +1 -1
  202. package/test/integration/SimultaneousConnections.test.ts +2 -2
  203. package/test/integration/WebrtcConnectionManagement.test.ts +2 -10
  204. package/test/integration/{WebsocketConnectorRpc.test.ts → WebsocketClientConnectorRpc.test.ts} +9 -9
  205. package/test/integration/WebsocketConnectionManagement.test.ts +11 -29
  206. package/test/unit/ConnectionManager.test.ts +64 -0
  207. package/test/unit/DiscoverySession.test.ts +1 -1
  208. package/test/unit/Handshaker.test.ts +169 -0
  209. package/test/unit/ManagedConnection.test.ts +58 -0
  210. package/test/unit/PendingConnection.test.ts +57 -0
  211. package/test/unit/WebrtcConnector.test.ts +56 -0
  212. package/test/unit/{WebsocketConnector.test.ts → WebsocketClientConnector.test.ts} +56 -11
  213. package/test/unit/WebsocketServerConnector.test.ts +102 -0
  214. package/test/utils/FakeConnectorFacade.ts +41 -0
  215. package/test/utils/mock/MockConnection.ts +26 -0
  216. package/test/utils/utils.ts +2 -2
  217. package/dist/src/connection/IConnectionSource.d.ts +0 -4
  218. package/dist/src/connection/IConnectionSource.js +0 -3
  219. package/dist/src/connection/IConnectionSource.js.map +0 -1
  220. package/dist/src/connection/webrtc/ManagedWebrtcConnection.d.ts +0 -7
  221. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js +0 -20
  222. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js.map +0 -1
  223. package/dist/src/connection/websocket/WebsocketConnector.js.map +0 -1
  224. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +0 -19
  225. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +0 -23
  226. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +0 -1
  227. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +0 -5
  228. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +0 -1
  229. package/src/connection/IConnectionSource.ts +0 -6
  230. package/src/connection/webrtc/ManagedWebrtcConnection.ts +0 -27
  231. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +0 -39
@@ -1,50 +1,25 @@
1
- import { ConnectionEvents, ConnectionID, ConnectionType, IConnection } from './IConnection';
2
- import { HandshakeError, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
1
+ import { ConnectionID, IConnection } from './IConnection';
2
+ import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
3
3
  import EventEmitter from 'eventemitter3';
4
4
  import { DhtAddress } from '../identifiers';
5
5
  export interface ManagedConnectionEvents {
6
6
  managedData: (bytes: Uint8Array, remotePeerDescriptor: PeerDescriptor) => void;
7
- handshakeRequest: (source: PeerDescriptor, version: string, target?: PeerDescriptor) => void;
8
- handshakeCompleted: (peerDescriptor: PeerDescriptor) => void;
9
- handshakeFailed: () => void;
7
+ disconnected: (gracefulLeave: boolean) => void;
10
8
  }
11
- export type Events = ManagedConnectionEvents & ConnectionEvents;
12
- export declare class ManagedConnection extends EventEmitter<Events> {
13
- private implementation?;
14
- private outputBufferEmitter;
15
- private outputBuffer;
16
- private inputBuffer;
9
+ export type Events = ManagedConnectionEvents;
10
+ export declare class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
11
+ private connection;
17
12
  connectionId: ConnectionID;
18
- private remotePeerDescriptor?;
19
- connectionType: ConnectionType;
20
- private handshaker?;
21
- private handshakeCompleted;
13
+ private remotePeerDescriptor;
22
14
  private lastUsedTimestamp;
15
+ private replacedAsDuplicate;
23
16
  private stopped;
24
- private bufferSentbyOtherConnection;
25
- private closing;
26
- replacedByOtherConnection: boolean;
27
- private localPeerDescriptor;
28
- protected outgoingConnection?: IConnection;
29
- protected incomingConnection?: IConnection;
30
- private created;
31
- constructor(localPeerDescriptor: PeerDescriptor, connectionType: ConnectionType, outgoingConnection?: IConnection, incomingConnection?: IConnection, targetPeerDescriptor?: PeerDescriptor);
32
- on(event: keyof Events, fn: (...args: any) => void, context?: any): this;
33
- once(event: keyof Events, fn: (...args: any) => void, context?: any): this;
17
+ constructor(peerDescriptor: PeerDescriptor, connection: IConnection);
18
+ private onDisconnected;
19
+ replaceAsDuplicate(): void;
20
+ send(data: Uint8Array): void;
21
+ close(gracefulLeave: boolean): Promise<void>;
34
22
  getNodeId(): DhtAddress;
35
23
  getLastUsedTimestamp(): number;
36
- setRemotePeerDescriptor(peerDescriptor: PeerDescriptor): void;
37
24
  getPeerDescriptor(): PeerDescriptor | undefined;
38
- private onHandshakeCompleted;
39
- attachImplementation(impl: IConnection): void;
40
- private onDisconnected;
41
- send(data: Uint8Array, connect: boolean): Promise<void>;
42
- sendNoWait(data: Uint8Array): void;
43
- reportBufferSentByOtherConnection(): void;
44
- acceptHandshake(): void;
45
- rejectHandshake(error: HandshakeError): void;
46
- close(gracefulLeave: boolean): Promise<void>;
47
- destroy(): void;
48
- isHandshakeCompleted(): boolean;
49
- stealOutputBuffer(): Uint8Array[];
50
25
  }
@@ -28,289 +28,68 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ManagedConnection = void 0;
30
30
  const Err = __importStar(require("../helpers/errors"));
31
- const Handshaker_1 = require("./Handshaker");
32
- const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
33
31
  const utils_1 = require("@streamr/utils");
34
32
  const eventemitter3_1 = __importDefault(require("eventemitter3"));
35
33
  const ConnectionManager_1 = require("./ConnectionManager");
36
34
  const identifiers_1 = require("../identifiers");
37
35
  const Connection_1 = require("./Connection");
38
36
  const logger = new utils_1.Logger(module);
37
+ // ManagedConnection is a component used as a wrapper for IConnection after they have been successfully handshaked.
38
+ // Should only be used in the ConnectionManager.
39
39
  class ManagedConnection extends eventemitter3_1.default {
40
- implementation;
41
- outputBufferEmitter = new eventemitter3_1.default();
42
- outputBuffer = [];
43
- inputBuffer = [];
40
+ connection;
44
41
  connectionId;
45
42
  remotePeerDescriptor;
46
- connectionType;
47
- handshaker;
48
- handshakeCompleted = false;
49
43
  lastUsedTimestamp = Date.now();
44
+ replacedAsDuplicate = false;
50
45
  stopped = false;
51
- bufferSentbyOtherConnection = false;
52
- closing = false;
53
- replacedByOtherConnection = false;
54
- localPeerDescriptor;
55
- outgoingConnection;
56
- incomingConnection;
57
- // TODO: Temporary debug variable, should be removed in the future.
58
- created = Date.now();
59
- constructor(localPeerDescriptor, connectionType, outgoingConnection, incomingConnection, targetPeerDescriptor) {
46
+ constructor(peerDescriptor, connection) {
60
47
  super();
61
- this.localPeerDescriptor = localPeerDescriptor;
62
- this.outgoingConnection = outgoingConnection;
63
- this.incomingConnection = incomingConnection;
64
- this.connectionType = connectionType;
65
48
  this.connectionId = (0, Connection_1.createRandomConnectionId)();
66
- this.send = this.send.bind(this);
67
- this.onDisconnected = this.onDisconnected.bind(this);
68
- logger.trace('creating ManagedConnection of type: ' + connectionType);
69
- if (incomingConnection && outgoingConnection) {
70
- throw new Err.IllegalArguments('Managed connection constructor only accepts either an incoming connection OR a outgoing connection');
71
- }
72
- if (outgoingConnection) {
73
- this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, outgoingConnection);
74
- this.handshaker.once('handshakeFailed', (error) => {
75
- if (error === DhtRpc_1.HandshakeError.INVALID_TARGET_PEER_DESCRIPTOR || error === DhtRpc_1.HandshakeError.UNSUPPORTED_VERSION) {
76
- // TODO should we have some handling for this floating promise?
77
- this.close(false);
78
- }
79
- else {
80
- logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' handshakeFailed: ' + error);
81
- this.emit('handshakeFailed');
82
- }
83
- });
84
- this.handshaker.on('handshakeCompleted', (peerDescriptor) => {
85
- logger.trace('handshake completed for outgoing connection '
86
- + ', ' + (0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor)
87
- + ' outputBuffer.length: ' + this.outputBuffer.length);
88
- this.attachImplementation(outgoingConnection);
89
- this.onHandshakeCompleted(peerDescriptor);
90
- });
91
- outgoingConnection.once('connected', () => {
92
- this.handshaker.sendHandshakeRequest(targetPeerDescriptor);
93
- this.emit('connected');
94
- });
95
- outgoingConnection.once('disconnected', this.onDisconnected);
96
- }
97
- else if (incomingConnection) {
98
- this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, incomingConnection);
99
- this.handshaker.on('handshakeRequest', (sourcePeerDescriptor, version, targetPeerDescriptor) => {
100
- this.setRemotePeerDescriptor(sourcePeerDescriptor);
101
- this.emit('handshakeRequest', sourcePeerDescriptor, version, targetPeerDescriptor);
102
- });
103
- incomingConnection.on('disconnected', this.onDisconnected);
104
- }
105
- }
106
- // eventemitter3 does not implement the standard 'newListener' event, so we need to override
107
- on(event, fn,
108
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
109
- context) {
110
- if (event === 'managedData' && this.listenerCount('managedData') === 0) {
111
- while (this.inputBuffer.length > 0) {
112
- logger.trace('emptying inputBuffer');
113
- const data = this.inputBuffer.shift();
114
- fn(data, this.getPeerDescriptor());
115
- }
116
- }
117
- super.on(event, fn, context);
118
- return this;
119
- }
120
- once(event, fn,
121
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
122
- context) {
123
- if (event === 'managedData' && this.listenerCount('managedData') === 0) {
124
- if (this.inputBuffer.length > 0) {
125
- while (this.inputBuffer.length > 0) {
126
- logger.trace('emptying inputBuffer');
127
- const data = this.inputBuffer.shift();
128
- fn(data, this.getPeerDescriptor());
129
- }
130
- }
131
- else {
132
- super.once(event, fn, context);
133
- }
134
- }
135
- else {
136
- super.once(event, fn, context);
137
- }
138
- return this;
139
- }
140
- getNodeId() {
141
- return (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
142
- }
143
- getLastUsedTimestamp() {
144
- return this.lastUsedTimestamp;
145
- }
146
- setRemotePeerDescriptor(peerDescriptor) {
147
- this.remotePeerDescriptor = peerDescriptor;
148
- }
149
- getPeerDescriptor() {
150
- return this.remotePeerDescriptor;
151
- }
152
- onHandshakeCompleted(peerDescriptor) {
153
- this.lastUsedTimestamp = Date.now();
154
- this.setRemotePeerDescriptor(peerDescriptor);
155
- this.handshakeCompleted = true;
156
- this.handshaker.stop();
157
- while (this.outputBuffer.length > 0) {
158
- logger.trace('emptying outputBuffer');
159
- this.implementation.send(this.outputBuffer.shift());
160
- }
161
- this.outputBufferEmitter.emit('bufferSent');
162
- logger.trace('emitting handshake_completed');
163
- this.emit('handshakeCompleted', peerDescriptor);
164
- }
165
- attachImplementation(impl) {
166
- logger.trace('attachImplementation()');
167
- this.implementation = impl;
168
- impl.on('data', (bytes) => {
49
+ this.connection = connection;
50
+ connection.on('data', (bytes) => {
169
51
  this.lastUsedTimestamp = Date.now();
170
- if (this.listenerCount('managedData') === 0) {
171
- this.inputBuffer.push(bytes);
172
- }
173
- else {
174
- this.emit('managedData', bytes, this.getPeerDescriptor());
175
- }
52
+ this.emit('managedData', bytes, this.getPeerDescriptor());
176
53
  });
177
- impl.on('error', (name) => {
178
- this.emit('error', name);
179
- });
180
- impl.on('connected', () => {
181
- this.lastUsedTimestamp = Date.now();
182
- logger.trace('connected emitted');
183
- this.emit('connected');
184
- });
185
- //ensure that we have subscribed to the event only once
186
- impl.off('disconnected', this.onDisconnected);
187
- impl.on('disconnected', this.onDisconnected);
54
+ connection.on('disconnected', (gracefulLeave) => this.onDisconnected(gracefulLeave));
55
+ this.lastUsedTimestamp = Date.now();
56
+ this.remotePeerDescriptor = peerDescriptor;
188
57
  }
189
58
  onDisconnected(gracefulLeave) {
190
59
  logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' onDisconnected() ' + gracefulLeave);
191
- if (this.bufferSentbyOtherConnection) {
192
- return;
60
+ if (!this.replacedAsDuplicate) {
61
+ this.emit('disconnected', gracefulLeave);
193
62
  }
194
- this.outputBufferEmitter.emit('bufferSendingFailed');
195
- this.emit('disconnected', gracefulLeave);
63
+ this.removeAllListeners();
196
64
  }
197
- async send(data, connect) {
65
+ // TODO: Can this be removed if ManagedConnections can never be duplicates?
66
+ // Handle duplicates in the ConncetorFacade and no longer have PendingConnections in ConnectionManager
67
+ replaceAsDuplicate() {
68
+ logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' replaceAsDuplicate');
69
+ this.replacedAsDuplicate = true;
70
+ }
71
+ send(data) {
198
72
  if (this.stopped) {
199
73
  throw new Err.SendFailed('ManagedConnection is stopped');
200
74
  }
201
- if (this.closing) {
202
- throw new Err.SendFailed('ManagedConnection is closing');
203
- }
204
- this.lastUsedTimestamp = Date.now();
205
- if (!connect && !this.implementation) {
206
- throw new Err.ConnectionNotOpen('Connection not open when calling send() with connect flag as false');
207
- }
208
- else if (this.implementation) {
209
- this.implementation.send(data);
210
- }
211
- else {
212
- logger.trace('adding data to outputBuffer');
213
- let result;
214
- try {
215
- result = await (0, utils_1.runAndRaceEvents3)([() => { this.outputBuffer.push(data); }], this.outputBufferEmitter, ['bufferSent', 'bufferSendingFailed'], 15000); // TODO use config option or named constant?
216
- }
217
- catch (e) {
218
- logger.debug(`Connection to ${(0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor)} timed out`, {
219
- peerDescriptor: this.remotePeerDescriptor,
220
- type: this.connectionType,
221
- lifetime: Date.now() - this.created
222
- });
223
- await this.close(false);
224
- throw new Err.SendFailed('Sending buffer timed out');
225
- }
226
- if (result.winnerName === 'bufferSendingFailed') {
227
- throw new Err.SendFailed('Sending buffer failed');
228
- }
229
- // buffer was sent successfully, return normally
230
- }
231
- }
232
- sendNoWait(data) {
233
75
  this.lastUsedTimestamp = Date.now();
234
- if (this.implementation) {
235
- this.implementation.send(data);
236
- }
237
- else {
238
- logger.trace('adding data to outputBuffer');
239
- this.outputBuffer.push(data);
240
- }
241
- }
242
- reportBufferSentByOtherConnection() {
243
- logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' reportBufferSentByOtherConnection');
244
- if (this.handshaker) {
245
- this.handshaker.removeAllListeners();
246
- }
247
- logger.trace('bufferSentByOtherConnection reported');
248
- this.bufferSentbyOtherConnection = true;
249
- this.outputBufferEmitter.emit('bufferSent');
250
- }
251
- acceptHandshake() {
252
- // This happens when connectionRequest has been made and answered
253
- if (this.implementation) {
254
- if (!this.handshaker) {
255
- this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, this.implementation);
256
- }
257
- this.handshaker.sendHandshakeResponse();
258
- }
259
- else { // This happens to when there is a regular incoming connection
260
- this.handshaker.sendHandshakeResponse();
261
- this.attachImplementation(this.incomingConnection);
262
- }
263
- this.onHandshakeCompleted(this.remotePeerDescriptor);
264
- }
265
- rejectHandshake(error) {
266
- this.handshaker.sendHandshakeResponse(error);
267
- this.destroy();
76
+ this.connection.send(data);
268
77
  }
269
78
  async close(gracefulLeave) {
270
- if (this.closing) {
79
+ if (this.stopped) {
271
80
  return;
272
81
  }
273
- if (this.replacedByOtherConnection) {
274
- logger.trace('close() called on replaced connection');
275
- }
276
- this.closing = true;
277
- this.outputBufferEmitter.emit('bufferSendingFailed');
278
- if (this.implementation) {
279
- await this.implementation?.close(gracefulLeave);
280
- }
281
- else if (this.outgoingConnection) {
282
- await this.outgoingConnection?.close(gracefulLeave);
283
- }
284
- else if (this.incomingConnection) {
285
- await this.incomingConnection?.close(gracefulLeave);
286
- }
287
- else {
288
- this.emit('disconnected', gracefulLeave);
289
- }
82
+ await this.connection.close(gracefulLeave);
83
+ this.removeAllListeners();
290
84
  }
291
- destroy() {
292
- this.closing = true;
293
- if (!this.stopped) {
294
- this.stopped = true;
295
- this.removeAllListeners();
296
- if (this.implementation) {
297
- this.implementation?.destroy();
298
- }
299
- else if (this.outgoingConnection) {
300
- this.outgoingConnection?.destroy();
301
- }
302
- else if (this.incomingConnection) {
303
- this.incomingConnection?.destroy();
304
- }
305
- }
85
+ getNodeId() {
86
+ return (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
306
87
  }
307
- isHandshakeCompleted() {
308
- return this.handshakeCompleted;
88
+ getLastUsedTimestamp() {
89
+ return this.lastUsedTimestamp;
309
90
  }
310
- stealOutputBuffer() {
311
- const ret = this.outputBuffer;
312
- this.outputBuffer = [];
313
- return ret;
91
+ getPeerDescriptor() {
92
+ return this.remotePeerDescriptor;
314
93
  }
315
94
  }
316
95
  exports.ManagedConnection = ManagedConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedConnection.ts"],"names":[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C;gBACjC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAA;YACtC,CAAC;iBAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACjC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAA;YACtC,CAAC;QACL,CAAC;IACL,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAClC,CAAC;IAED,iBAAiB;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAA;QAC7B,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,OAAO,GAAG,CAAA;IACd,CAAC;CACJ;AApUD,8CAoUC"}
1
+ {"version":3,"file":"ManagedConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAwC;AAExC,0CAAuC;AACvC,kEAAwC;AACxC,2DAA0E;AAC1E,gDAAwE;AACxE,6CAAuD;AAOvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAIjC,mHAAmH;AACnH,gDAAgD;AAChD,MAAa,iBAAkB,SAAQ,uBAAqC;IAEhE,UAAU,CAAa;IACxB,YAAY,CAAc;IACzB,oBAAoB,CAAgB;IACpC,iBAAiB,GAAW,IAAI,CAAC,GAAG,EAAE,CAAA;IACtC,mBAAmB,GAAG,KAAK,CAAA;IAC3B,OAAO,GAAG,KAAK,CAAA;IAEvB,YAAY,cAA8B,EAAE,UAAuB;QAC/D,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,YAAY,GAAG,IAAA,qCAAwB,GAAE,CAAA;QAC9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAiB,EAAE,EAAE;YACxC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACnC,IAAI,CAAC,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AC;QACD,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC7B,CAAC;IAED,SAAS;QACL,OAAO,IAAA,yCAA2B,EAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IACjE,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,iBAAiB,CAAA;IACjC,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,oBAAoB,CAAA;IACpC,CAAC;CAEJ;AAnED,8CAmEC"}
@@ -0,0 +1,9 @@
1
+ import { Defer } from '@streamr/utils';
2
+ export declare class OutputBuffer {
3
+ private readonly buffer;
4
+ private readonly deferredPromise;
5
+ push(message: Uint8Array): Defer<void>;
6
+ getBuffer(): Uint8Array[];
7
+ resolve(): void;
8
+ reject(): void;
9
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutputBuffer = void 0;
4
+ const utils_1 = require("@streamr/utils");
5
+ const errors_1 = require("../helpers/errors");
6
+ class OutputBuffer {
7
+ buffer = [];
8
+ deferredPromise = new utils_1.Defer();
9
+ push(message) {
10
+ this.buffer.push(message);
11
+ return this.deferredPromise;
12
+ }
13
+ getBuffer() {
14
+ return this.buffer;
15
+ }
16
+ resolve() {
17
+ this.buffer.length = 0;
18
+ this.deferredPromise.resolve();
19
+ }
20
+ reject() {
21
+ this.buffer.length = 0;
22
+ this.deferredPromise.reject(new errors_1.SendFailed('Could not send buffered messages'));
23
+ }
24
+ }
25
+ exports.OutputBuffer = OutputBuffer;
26
+ //# sourceMappingURL=OutputBuffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputBuffer.js","sourceRoot":"","sources":["../../../src/connection/OutputBuffer.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,8CAA8C;AAE9C,MAAa,YAAY;IAEJ,MAAM,GAAiB,EAAE,CAAA;IACzB,eAAe,GAAgB,IAAI,aAAK,EAAQ,CAAA;IAEjE,IAAI,CAAC,OAAmB;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,eAAe,CAAA;IAC/B,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;IAED,MAAM;QACF,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,mBAAU,CAAC,kCAAkC,CAAC,CAAC,CAAA;IACnF,CAAC;CAEJ;AAxBD,oCAwBC"}
@@ -0,0 +1,19 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
3
+ import { IConnection } from './IConnection';
4
+ export interface PendingConnectionEvents {
5
+ connected: (peerDescriptor: PeerDescriptor, connection: IConnection) => void;
6
+ disconnected: (gracefulLeave: boolean) => void;
7
+ }
8
+ export declare class PendingConnection extends EventEmitter<PendingConnectionEvents> {
9
+ private readonly connectingAbortController;
10
+ private remotePeerDescriptor;
11
+ private replacedAsDuplicate;
12
+ private stopped;
13
+ constructor(remotePeerDescriptor: PeerDescriptor, timeout?: number);
14
+ replaceAsDuplicate(): void;
15
+ onHandshakeCompleted(connection: IConnection): void;
16
+ close(graceful: boolean): void;
17
+ destroy(): void;
18
+ getPeerDescriptor(): PeerDescriptor;
19
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PendingConnection = void 0;
7
+ const eventemitter3_1 = __importDefault(require("eventemitter3"));
8
+ const utils_1 = require("@streamr/utils");
9
+ const ConnectionManager_1 = require("./ConnectionManager");
10
+ const logger = new utils_1.Logger(module);
11
+ // PendingConnection is used as a reference to a connection that should be opened and handshaked to a given PeerDescriptor
12
+ // It does not hold a connection internally. The public method onHandshakedCompleted should be called once a connection for the
13
+ // remotePeerDescriptor is opened and handshaked successfully.
14
+ // PendingConnections are created by the Connectors.
15
+ class PendingConnection extends eventemitter3_1.default {
16
+ connectingAbortController = new AbortController();
17
+ remotePeerDescriptor;
18
+ replacedAsDuplicate = false;
19
+ stopped = false;
20
+ constructor(remotePeerDescriptor, timeout = 15 * 1000) {
21
+ super();
22
+ this.remotePeerDescriptor = remotePeerDescriptor;
23
+ (0, utils_1.setAbortableTimeout)(() => {
24
+ this.close(false);
25
+ }, timeout, this.connectingAbortController.signal);
26
+ }
27
+ replaceAsDuplicate() {
28
+ logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' replaceAsDuplicate');
29
+ this.replacedAsDuplicate = true;
30
+ }
31
+ onHandshakeCompleted(connection) {
32
+ if (!this.replacedAsDuplicate) {
33
+ this.emit('connected', this.remotePeerDescriptor, connection);
34
+ }
35
+ }
36
+ close(graceful) {
37
+ if (this.stopped) {
38
+ return;
39
+ }
40
+ this.stopped = true;
41
+ this.connectingAbortController.abort();
42
+ if (!this.replacedAsDuplicate) {
43
+ this.emit('disconnected', graceful);
44
+ }
45
+ }
46
+ destroy() {
47
+ if (this.stopped) {
48
+ return;
49
+ }
50
+ this.stopped = true;
51
+ this.connectingAbortController.abort();
52
+ this.removeAllListeners();
53
+ }
54
+ getPeerDescriptor() {
55
+ return this.remotePeerDescriptor;
56
+ }
57
+ }
58
+ exports.PendingConnection = PendingConnection;
59
+ //# sourceMappingURL=PendingConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendingConnection.js","sourceRoot":"","sources":["../../../src/connection/PendingConnection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mBAAmB,EAAE,CAAC;YAC5B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;IACL,CAAC;IAED,OAAO;QACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAM;QACV,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,yBAAyB,CAAC,KAAK,EAAE,CAAA;QACtC,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC7B,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,oBAAoB,CAAA;IACpC,CAAC;CAEJ;AAlDD,8CAkDC"}
@@ -29,10 +29,10 @@ const uuid_1 = require("uuid");
29
29
  const Err = __importStar(require("../helpers/errors"));
30
30
  const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
31
31
  const NodeWebsocketClientConnection_1 = require("./websocket/NodeWebsocketClientConnection");
32
- const WebsocketConnector_1 = require("./websocket/WebsocketConnector");
32
+ const WebsocketClientConnector_1 = require("./websocket/WebsocketClientConnector");
33
33
  const version_1 = require("../helpers/version");
34
34
  const logger = new utils_1.Logger(module);
35
- // TODO use config option or named constant?
35
+ // TODO use options option or named constant?
36
36
  const connectAsync = async ({ url, allowSelfSignedCertificate, timeoutMs = 1000 }) => {
37
37
  const socket = new NodeWebsocketClientConnection_1.WebsocketClientConnection();
38
38
  let result;
@@ -59,7 +59,7 @@ const sendConnectivityRequest = async (request, entryPoint) => {
59
59
  port: entryPoint.websocket.port,
60
60
  tls: entryPoint.websocket.tls,
61
61
  };
62
- const url = (0, WebsocketConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityRequest');
62
+ const url = (0, WebsocketClientConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityRequest');
63
63
  logger.debug(`Attempting connectivity check with entrypoint ${url}`);
64
64
  try {
65
65
  outgoingConnection = await (0, exports.connectAsync)({
@@ -1 +1 @@
1
- {"version":3,"file":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C,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAClD,MAAM,CAAC,CAAA;IACX,CAAC;AACL,CAAC,CAAA;AArEY,QAAA,uBAAuB,2BAqEnC"}
1
+ {"version":3,"file":"connectivityChecker.js","sourceRoot":"","sources":["../../../src/connection/connectivityChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAsF;AACtF,+BAAyB;AACzB,uDAAwC;AACxC,gEAG4C;AAE5C,6FAAqF;AACrF,mFAAuF;AACvF,gDAA4D;AAE5D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,6CAA6C;AACtC,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,0BAA0B,EAAE,SAAS,GAAG,IAAI,EACV,EACpD,EAAE;IACtB,MAAM,MAAM,GAAG,IAAI,yDAAyB,EAAE,CAAA;IAC9C,IAAI,MAAoD,CAAA;IACxD,IAAI,CAAC;QACD,MAAM,GAAG,MAAM,IAAA,yBAAiB,EAAmB;YAC/C,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAA,CAAC,CAAC;SAAC,EAC9D,MAAM,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,EAC9B,SAAS,CAAC,CAAA;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAAA;IACpE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC,qCAAqC,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAjBY,QAAA,YAAY,gBAiBxB;AAEY,QAAA,+BAA+B,GAAG,6BAA6B,CAAA;AAC5E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AA;QAC9C,MAAM,CAAC,KAAK,CAAC,4BAA4B,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAChF,OAAO,MAAM,UAAU,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAClD,MAAM,CAAC,CAAA;IACX,CAAC;AACL,CAAC,CAAA;AArEY,QAAA,uBAAuB,2BAqEnC"}
@@ -6,7 +6,7 @@ const uuid_1 = require("uuid");
6
6
  const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
7
7
  const ConnectionManager_1 = require("./ConnectionManager");
8
8
  const connectivityChecker_1 = require("./connectivityChecker");
9
- const WebsocketConnector_1 = require("./websocket/WebsocketConnector");
9
+ const WebsocketClientConnector_1 = require("./websocket/WebsocketClientConnector");
10
10
  const version_1 = require("../helpers/version");
11
11
  exports.DISABLE_CONNECTIVITY_PROBE = 0;
12
12
  const logger = new utils_1.Logger(module);
@@ -75,7 +75,7 @@ const connectivityProbe = async (connectivityRequest, ipAddress, host) => {
75
75
  port: connectivityRequest.port,
76
76
  tls: connectivityRequest.tls
77
77
  };
78
- const url = (0, WebsocketConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityProbe');
78
+ const url = (0, WebsocketClientConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityProbe');
79
79
  logger.trace(`Attempting Connectivity Check to ${url}`);
80
80
  outgoingConnection = await (0, connectivityChecker_1.connectAsync)({
81
81
  url,
@@ -1 +1 @@
1
- {"version":3,"file":"connectivityRequestHandler.js","sourceRoot":"","sources":["../../../src/connection/connectivityRequestHandler.ts"],"names":[],"mappings":";;;AAAA,0CAAqD;AACrD,+BAAyB;AACzB,gEAI4C;AAC5C,2DAA6C;AAC7C,+DAAqF;AAGrF,uEAAiF;AACjF,gDAA2D;AAG9C,QAAA,0BAA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,CAAA;IACnC,CAAC;IACD,OAAO,2BAA2B,CAAA;AACtC,CAAC,CAAA"}
1
+ {"version":3,"file":"connectivityRequestHandler.js","sourceRoot":"","sources":["../../../src/connection/connectivityRequestHandler.ts"],"names":[],"mappings":";;;AAAA,0CAAqD;AACrD,+BAAyB;AACzB,gEAI4C;AAC5C,2DAA6C;AAC7C,+DAAqF;AAGrF,mFAAuF;AACvF,gDAA2D;AAG9C,QAAA,0BAA0B,GAAG,CAAC,CAAA;AAE3C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,gCAAgC,GAAG,CAAC,oBAA+C,EAAE,YAA2B,EAAQ,EAAE;IACnI,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE;QACvD,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;QACpC,IAAI,CAAC;YACD,MAAM,OAAO,GAAG,gBAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YACxC,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,KAAK,qBAAqB,EAAE,CAAC;gBACnD,MAAM,CAAC,KAAK,CAAC,gCAAgC,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;gBACxF,IAAI,CAAC;oBACD,MAAM,iCAAiC,CAAC,oBAAoB,EACxD,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;oBACnD,MAAM,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA;gBACxD,CAAC;gBAAC,OAAO,IAAI,EAAE,CAAC;oBACZ,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;gBACpE,CAAC;YACL,CAAC;QACL,CAAC;QAAC,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,CAAC,KAAK,CAAC,y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EAAE,CAAC,CAAA;QAC9B,2BAA2B,GAAG;YAC1B,IAAI;YACJ,OAAO,EAAE,2BAAO,CAAC,OAAO;YACxB,SAAS,EAAE,IAAA,oBAAY,EAAC,SAAS,CAAC;YAClC,OAAO,EAAE,gCAAsB;SAClC,CAAA;IACL,CAAC;IACD,IAAI,kBAAkB,EAAE,CAAC;QACrB,+DAA+D;QAC/D,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,2BAA2B,CAAA;AACtC,CAAC,CAAA"}
@@ -1,6 +1,4 @@
1
- import EventEmitter from 'eventemitter3';
2
1
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
3
- import { ConnectionSourceEvents } from '../IConnectionSource';
4
2
  import { SimulatorConnector } from './SimulatorConnector';
5
3
  import { SimulatorConnection } from './SimulatorConnection';
6
4
  export declare enum LatencyType {
@@ -9,7 +7,7 @@ export declare enum LatencyType {
9
7
  REAL = "REAL",
10
8
  FIXED = "FIXED"
11
9
  }
12
- export declare class Simulator extends EventEmitter<ConnectionSourceEvents> {
10
+ export declare class Simulator {
13
11
  private stopped;
14
12
  private connectors;
15
13
  private latencyTable?;