@streamr/dht 0.0.1-tatum.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.
- package/.eslintignore +5 -0
- package/.eslintrc +3 -0
- package/README.md +38 -0
- package/dist/src/connection/Connection.d.ts +11 -0
- package/dist/src/connection/Connection.js +23 -0
- package/dist/src/connection/Connection.js.map +1 -0
- package/dist/src/connection/ConnectionLockHandler.d.ts +23 -0
- package/dist/src/connection/ConnectionLockHandler.js +94 -0
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +94 -0
- package/dist/src/connection/ConnectionManager.js +554 -0
- package/dist/src/connection/ConnectionManager.js.map +1 -0
- package/dist/src/connection/ConnectivityChecker.d.ts +17 -0
- package/dist/src/connection/ConnectivityChecker.js +187 -0
- package/dist/src/connection/ConnectivityChecker.js.map +1 -0
- package/dist/src/connection/Handshaker.d.ts +19 -0
- package/dist/src/connection/Handshaker.js +77 -0
- package/dist/src/connection/Handshaker.js.map +1 -0
- package/dist/src/connection/IConnection.d.ts +38 -0
- package/dist/src/connection/IConnection.js +19 -0
- package/dist/src/connection/IConnection.js.map +1 -0
- package/dist/src/connection/IConnectionSource.d.ts +4 -0
- package/dist/src/connection/IConnectionSource.js +3 -0
- package/dist/src/connection/IConnectionSource.js.map +1 -0
- package/dist/src/connection/ManagedConnection.d.ts +60 -0
- package/dist/src/connection/ManagedConnection.js +352 -0
- package/dist/src/connection/ManagedConnection.js.map +1 -0
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebRtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -0
- package/dist/src/connection/RemoteConnectionLocker.d.ts +14 -0
- package/dist/src/connection/RemoteConnectionLocker.js +93 -0
- package/dist/src/connection/RemoteConnectionLocker.js.map +1 -0
- package/dist/src/connection/Simulator/Simulator.d.ts +42 -0
- package/dist/src/connection/Simulator/Simulator.js +325 -0
- package/dist/src/connection/Simulator/Simulator.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorConnection.d.ts +19 -0
- package/dist/src/connection/Simulator/SimulatorConnection.js +118 -0
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +17 -0
- package/dist/src/connection/Simulator/SimulatorConnector.js +72 -0
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -0
- package/dist/src/connection/Simulator/SimulatorTransport.d.ts +6 -0
- package/dist/src/connection/Simulator/SimulatorTransport.js +11 -0
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/Simulator/pings.d.ts +21 -0
- package/dist/src/connection/Simulator/pings.js +61 -0
- package/dist/src/connection/Simulator/pings.js.map +1 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.d.ts +20 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.js +9 -0
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +1 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +47 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +233 -0
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +12 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +74 -0
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +1 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.d.ts +47 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.js +227 -0
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +1 -0
- package/dist/src/connection/WebRTC/iceServerAsString.d.ts +2 -0
- package/dist/src/connection/WebRTC/iceServerAsString.js +18 -0
- package/dist/src/connection/WebRTC/iceServerAsString.js.map +1 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.d.ts +15 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.js +113 -0
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +1 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +9 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js +63 -0
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +1 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.d.ts +18 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.js +103 -0
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.d.ts +31 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.js +202 -0
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +9 -0
- package/dist/src/connection/WebSocket/WebSocketServer.js +101 -0
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +153 -0
- package/dist/src/dht/DhtNode.js +599 -0
- package/dist/src/dht/DhtNode.js.map +1 -0
- package/dist/src/dht/DhtPeer.d.ts +18 -0
- package/dist/src/dht/DhtPeer.js +74 -0
- package/dist/src/dht/DhtPeer.js.map +1 -0
- package/dist/src/dht/ExternalApi.d.ts +8 -0
- package/dist/src/dht/ExternalApi.js +26 -0
- package/dist/src/dht/ExternalApi.js.map +1 -0
- package/dist/src/dht/RemoteExternalApi.d.ts +6 -0
- package/dist/src/dht/RemoteExternalApi.js +26 -0
- package/dist/src/dht/RemoteExternalApi.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +22 -0
- package/dist/src/dht/contact/Contact.js +25 -0
- package/dist/src/dht/contact/Contact.js.map +1 -0
- package/dist/src/dht/contact/RandomContactList.d.ts +20 -0
- package/dist/src/dht/contact/RandomContactList.js +78 -0
- package/dist/src/dht/contact/RandomContactList.js.map +1 -0
- package/dist/src/dht/contact/Remote.d.ts +15 -0
- package/dist/src/dht/contact/Remote.js +24 -0
- package/dist/src/dht/contact/Remote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +35 -0
- package/dist/src/dht/contact/SortedContactList.js +156 -0
- package/dist/src/dht/contact/SortedContactList.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.d.ts +36 -0
- package/dist/src/dht/discovery/DiscoverySession.js +116 -0
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -0
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +42 -0
- package/dist/src/dht/discovery/PeerDiscovery.js +157 -0
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -0
- package/dist/src/dht/find/RecursiveFindSession.d.ts +46 -0
- package/dist/src/dht/find/RecursiveFindSession.js +142 -0
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -0
- package/dist/src/dht/find/RecursiveFinder.d.ts +54 -0
- package/dist/src/dht/find/RecursiveFinder.js +180 -0
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +6 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.js +25 -0
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -0
- package/dist/src/dht/routing/DuplicateDetector.d.ts +13 -0
- package/dist/src/dht/routing/DuplicateDetector.js +41 -0
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -0
- package/dist/src/dht/routing/RemoteRouter.d.ts +8 -0
- package/dist/src/dht/routing/RemoteRouter.js +106 -0
- package/dist/src/dht/routing/RemoteRouter.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +60 -0
- package/dist/src/dht/routing/Router.js +207 -0
- package/dist/src/dht/routing/Router.js.map +1 -0
- package/dist/src/dht/routing/RoutingSession.d.ts +42 -0
- package/dist/src/dht/routing/RoutingSession.js +178 -0
- package/dist/src/dht/routing/RoutingSession.js.map +1 -0
- package/dist/src/dht/store/DataStore.d.ts +45 -0
- package/dist/src/dht/store/DataStore.js +244 -0
- package/dist/src/dht/store/DataStore.js.map +1 -0
- package/dist/src/dht/store/LocalDataStore.d.ts +19 -0
- package/dist/src/dht/store/LocalDataStore.js +104 -0
- package/dist/src/dht/store/LocalDataStore.js.map +1 -0
- package/dist/src/dht/store/RemoteStore.d.ts +8 -0
- package/dist/src/dht/store/RemoteStore.js +44 -0
- package/dist/src/dht/store/RemoteStore.js.map +1 -0
- package/dist/src/exports.d.ts +19 -0
- package/dist/src/exports.js +41 -0
- package/dist/src/exports.js.map +1 -0
- package/dist/src/helpers/AddressTools.d.ts +2 -0
- package/dist/src/helpers/AddressTools.js +31 -0
- package/dist/src/helpers/AddressTools.js.map +1 -0
- package/dist/src/helpers/PeerID.d.ts +25 -0
- package/dist/src/helpers/PeerID.js +84 -0
- package/dist/src/helpers/PeerID.js.map +1 -0
- package/dist/src/helpers/UUID.d.ts +7 -0
- package/dist/src/helpers/UUID.js +32 -0
- package/dist/src/helpers/UUID.js.map +1 -0
- package/dist/src/helpers/debugHelpers.d.ts +3 -0
- package/dist/src/helpers/debugHelpers.js +11 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +72 -0
- package/dist/src/helpers/errors.js +95 -0
- package/dist/src/helpers/errors.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +5 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +17 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/protoClasses.d.ts +2 -0
- package/dist/src/helpers/protoClasses.js +35 -0
- package/dist/src/helpers/protoClasses.js.map +1 -0
- package/dist/src/helpers/protoToString.d.ts +2 -0
- package/dist/src/helpers/protoToString.js +20 -0
- package/dist/src/helpers/protoToString.js.map +1 -0
- package/dist/src/proto/google/protobuf/any.d.ts +173 -0
- package/dist/src/proto/google/protobuf/any.js +155 -0
- package/dist/src/proto/google/protobuf/any.js.map +1 -0
- package/dist/src/proto/google/protobuf/empty.d.ts +32 -0
- package/dist/src/proto/google/protobuf/empty.js +34 -0
- package/dist/src/proto/google/protobuf/empty.js.map +1 -0
- package/dist/src/proto/google/protobuf/timestamp.d.ts +149 -0
- package/dist/src/proto/google/protobuf/timestamp.js +136 -0
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +320 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +245 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +1089 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +710 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +145 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js +3 -0
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.d.ts +87 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +66 -0
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/src/proto/tests.d.ts +39 -0
- package/dist/src/proto/tests.js +34 -0
- package/dist/src/proto/tests.js.map +1 -0
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +12 -0
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +8 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.js +3 -0
- package/dist/src/rpc-protocol/DhtRpcOptions.js.map +1 -0
- package/dist/src/transport/ITransport.d.ts +22 -0
- package/dist/src/transport/ITransport.js +3 -0
- package/dist/src/transport/ITransport.js.map +1 -0
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +6 -0
- package/dist/src/transport/ListeningRpcCommunicator.js +14 -0
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -0
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +8 -0
- package/dist/src/transport/RoutingRpcCommunicator.js +52 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -0
- package/jest.config.js +2 -0
- package/karma.config.js +20 -0
- package/package.json +64 -0
- package/proto.sh +3 -0
- package/protos/DhtRpc.proto +330 -0
- package/protos/tests.proto +16 -0
- package/src/connection/Connection.ts +23 -0
- package/src/connection/ConnectionLockHandler.ts +105 -0
- package/src/connection/ConnectionManager.ts +676 -0
- package/src/connection/ConnectivityChecker.ts +173 -0
- package/src/connection/Handshaker.ts +92 -0
- package/src/connection/IConnection.ts +47 -0
- package/src/connection/IConnectionSource.ts +6 -0
- package/src/connection/ManagedConnection.ts +398 -0
- package/src/connection/ManagedWebRtcConnection.ts +27 -0
- package/src/connection/RemoteConnectionLocker.ts +88 -0
- package/src/connection/Simulator/Simulator.ts +399 -0
- package/src/connection/Simulator/SimulatorConnection.ts +137 -0
- package/src/connection/Simulator/SimulatorConnector.ts +104 -0
- package/src/connection/Simulator/SimulatorTransport.ts +9 -0
- package/src/connection/Simulator/pings.ts +42 -0
- package/src/connection/WebRTC/BrowserWebRtcConnection.ts +227 -0
- package/src/connection/WebRTC/IWebRtcConnection.ts +24 -0
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +256 -0
- package/src/connection/WebRTC/RemoteWebrtcConnector.ts +93 -0
- package/src/connection/WebRTC/WebRtcConnector.ts +306 -0
- package/src/connection/WebRTC/iceServerAsString.ts +15 -0
- package/src/connection/WebSocket/ClientWebSocket.ts +118 -0
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +49 -0
- package/src/connection/WebSocket/ServerWebSocket.ts +119 -0
- package/src/connection/WebSocket/WebSocketConnector.ts +264 -0
- package/src/connection/WebSocket/WebSocketServer.ts +97 -0
- package/src/dht/DhtNode.ts +776 -0
- package/src/dht/DhtPeer.ts +96 -0
- package/src/dht/ExternalApi.ts +29 -0
- package/src/dht/RemoteExternalApi.ts +25 -0
- package/src/dht/contact/Contact.ts +36 -0
- package/src/dht/contact/RandomContactList.ts +92 -0
- package/src/dht/contact/Remote.ts +40 -0
- package/src/dht/contact/SortedContactList.ts +196 -0
- package/src/dht/discovery/DiscoverySession.ts +150 -0
- package/src/dht/discovery/PeerDiscovery.ts +162 -0
- package/src/dht/find/RecursiveFindSession.ts +178 -0
- package/src/dht/find/RecursiveFinder.ts +272 -0
- package/src/dht/find/RemoteRecursiveFindSession.ts +33 -0
- package/src/dht/routing/DuplicateDetector.ts +53 -0
- package/src/dht/routing/RemoteRouter.ts +115 -0
- package/src/dht/routing/Router.ts +266 -0
- package/src/dht/routing/RoutingSession.ts +222 -0
- package/src/dht/store/DataStore.ts +321 -0
- package/src/dht/store/LocalDataStore.ts +114 -0
- package/src/dht/store/RemoteStore.ts +58 -0
- package/src/exports.ts +19 -0
- package/src/helpers/AddressTools.ts +26 -0
- package/src/helpers/PeerID.ts +95 -0
- package/src/helpers/UUID.ts +30 -0
- package/src/helpers/debugHelpers.ts +9 -0
- package/src/helpers/errors.ts +49 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +14 -0
- package/src/helpers/protoClasses.ts +63 -0
- package/src/helpers/protoToString.ts +21 -0
- package/src/proto/google/protobuf/any.ts +319 -0
- package/src/proto/google/protobuf/empty.ts +84 -0
- package/src/proto/google/protobuf/timestamp.ts +281 -0
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +373 -0
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +148 -0
- package/src/proto/packages/dht/protos/DhtRpc.ts +1399 -0
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +108 -0
- package/src/proto/tests.ts +52 -0
- package/src/rpc-protocol/DhtCallContext.ts +15 -0
- package/src/rpc-protocol/DhtRpcOptions.ts +9 -0
- package/src/transport/ITransport.ts +31 -0
- package/src/transport/ListeningRpcCommunicator.ts +14 -0
- package/src/transport/RoutingRpcCommunicator.ts +59 -0
- package/src/types/glogal.d.ts +1 -0
- package/src/types/textencoding.d.ts +7 -0
- package/test/RandomGraphSimulation.ts +52 -0
- package/test/benchmark/KademliaCorrectness.test.ts +115 -0
- package/test/benchmark/RecursiveFind.test.ts +87 -0
- package/test/benchmark/any.test.ts +28 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +32 -0
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +94 -0
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +125 -0
- package/test/data/generateGroundTruthData.ts +70 -0
- package/test/end-to-end/Layer0-Layer1.test.ts +87 -0
- package/test/end-to-end/Layer0.test.ts +60 -0
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +94 -0
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +134 -0
- package/test/end-to-end/Layer0WebRTC.test.ts +98 -0
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +69 -0
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +73 -0
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +62 -0
- package/test/integration/ConnectionLocking.test.ts +166 -0
- package/test/integration/ConnectionManager.test.ts +291 -0
- package/test/integration/DhtNodeExternalAPI.test.ts +43 -0
- package/test/integration/DhtPeer.test.ts +73 -0
- package/test/integration/DhtRpc.test.ts +131 -0
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +46 -0
- package/test/integration/DhtWithMockConnections.test.ts +46 -0
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +47 -0
- package/test/integration/Layer1-scale.test.ts +200 -0
- package/test/integration/MigrateData.test.ts +203 -0
- package/test/integration/Mock-Layer1-Layer0.test.ts +106 -0
- package/test/integration/MultipleEntryPointJoining.test.ts +105 -0
- package/test/integration/RecursiveFind.test.ts +50 -0
- package/test/integration/RemoteRouter.test.ts +83 -0
- package/test/integration/RemoteStore.test.ts +66 -0
- package/test/integration/RouteMessage.test.ts +254 -0
- package/test/integration/RpcErrors.test.ts +153 -0
- package/test/integration/ScaleDownDht.test.ts +66 -0
- package/test/integration/SimultaneousConnections.test.ts +308 -0
- package/test/integration/Store.test.ts +72 -0
- package/test/integration/StoreAndDelete.test.ts +93 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +71 -0
- package/test/integration/WebRtcConnectionManagement.test.ts +205 -0
- package/test/integration/WebRtcConnectorRpc.test.ts +145 -0
- package/test/integration/WebSocket.test.ts +64 -0
- package/test/integration/WebSocketConnectionManagement.test.ts +131 -0
- package/test/integration/WebSocketConnectorRpc.test.ts +86 -0
- package/test/kademlia-simulation/data/nodeids.json +13002 -0
- package/test/kademlia-simulation/data/orderedneighbors.json +1001 -0
- package/test/unit/AddressTools.test.ts +40 -0
- package/test/unit/DuplicateDetector.test.ts +29 -0
- package/test/unit/LocalDataStore.test.ts +107 -0
- package/test/unit/PeerID.test.ts +22 -0
- package/test/unit/ProtobufMessage.test.ts +21 -0
- package/test/unit/RandomContactList.test.ts +87 -0
- package/test/unit/RecursiveFinder.test.ts +112 -0
- package/test/unit/Router.test.ts +124 -0
- package/test/unit/SortedContactList.test.ts +127 -0
- package/test/unit/UUID.test.ts +49 -0
- package/test/unit/WebSocketServer.test.ts +42 -0
- package/test/utils/mock/RecursiveFinder.ts +19 -0
- package/test/utils/mock/Router.ts +53 -0
- package/test/utils/mock/Transport.ts +26 -0
- package/test/utils/utils.ts +311 -0
- package/tsconfig.browser.json +15 -0
- package/tsconfig.jest.json +19 -0
- package/tsconfig.json +3 -0
- package/tsconfig.node.json +18 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ManagedConnection = void 0;
|
|
30
|
+
const IConnection_1 = require("./IConnection");
|
|
31
|
+
const Err = __importStar(require("../helpers/errors"));
|
|
32
|
+
const Handshaker_1 = require("./Handshaker");
|
|
33
|
+
const utils_1 = require("@streamr/utils");
|
|
34
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
35
|
+
const peerIdFromPeerDescriptor_1 = require("../helpers/peerIdFromPeerDescriptor");
|
|
36
|
+
const logger = new utils_1.Logger(module);
|
|
37
|
+
class ManagedConnection extends eventemitter3_1.default {
|
|
38
|
+
constructor(ownPeerDescriptor, protocolVersion, connectionType, outgoingConnection, incomingConnection) {
|
|
39
|
+
super();
|
|
40
|
+
this.objectId = 0;
|
|
41
|
+
this.outputBuffer = [];
|
|
42
|
+
this.inputBuffer = [];
|
|
43
|
+
this.handshakeCompleted = false;
|
|
44
|
+
this.doNotEmitDisconnected = false;
|
|
45
|
+
this.lastUsed = Date.now();
|
|
46
|
+
this.stopped = false;
|
|
47
|
+
this.offeredAsIncoming = false;
|
|
48
|
+
this.rejectedAsIncoming = false;
|
|
49
|
+
this.bufferSentbyOtherConnection = false;
|
|
50
|
+
this.closing = false;
|
|
51
|
+
this.replacedByOtherConnection = false;
|
|
52
|
+
this.onHandshakeCompleted = (peerDescriptor) => {
|
|
53
|
+
this.lastUsed = Date.now();
|
|
54
|
+
this.setPeerDescriptor(peerDescriptor);
|
|
55
|
+
this.handshakeCompleted = true;
|
|
56
|
+
while (this.outputBuffer.length > 0) {
|
|
57
|
+
logger.trace('emptying outputBuffer objectId: ' + this.objectId);
|
|
58
|
+
this.implementation.send(this.outputBuffer.shift());
|
|
59
|
+
}
|
|
60
|
+
logger.trace('emitting handshake_completed, objectId: ' + this.objectId);
|
|
61
|
+
this.emit('handshakeCompleted', peerDescriptor);
|
|
62
|
+
};
|
|
63
|
+
this.objectId = ManagedConnection.objectCounter;
|
|
64
|
+
ManagedConnection.objectCounter++;
|
|
65
|
+
this.send = this.send.bind(this);
|
|
66
|
+
this.ownPeerDescriptor = ownPeerDescriptor;
|
|
67
|
+
this.protocolVersion = protocolVersion;
|
|
68
|
+
this.outgoingConnection = outgoingConnection;
|
|
69
|
+
this.incomingConnection = incomingConnection;
|
|
70
|
+
this.connectionType = connectionType;
|
|
71
|
+
this.connectionId = new IConnection_1.ConnectionID();
|
|
72
|
+
this.onDisconnected = this.onDisconnected.bind(this);
|
|
73
|
+
logger.trace('creating ManagedConnection of type: ' + connectionType + ' objectId: ' + this.objectId);
|
|
74
|
+
if (incomingConnection && outgoingConnection) {
|
|
75
|
+
throw new Err.IllegalArguments('Managed connection constructor only accepts either an incoming connection OR a outgoing connection');
|
|
76
|
+
}
|
|
77
|
+
if (outgoingConnection) {
|
|
78
|
+
this.handshaker = new Handshaker_1.Handshaker(this.ownPeerDescriptor, this.protocolVersion, outgoingConnection);
|
|
79
|
+
this.handshaker.once('handshakeFailed', (errorMessage) => {
|
|
80
|
+
logger.trace('IL handshake failed for outgoing connection ' + errorMessage + ' ' +
|
|
81
|
+
this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' objectid: ' + this.objectId
|
|
82
|
+
+ ' outputBuffer.length: ' + this.outputBuffer.length);
|
|
83
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' emitting handshakeFailed');
|
|
84
|
+
this.emit('handshakeFailed');
|
|
85
|
+
});
|
|
86
|
+
this.handshaker.on('handshakeCompleted', (peerDescriptor) => {
|
|
87
|
+
logger.trace('handshake completed for outgoing connection ' + this.ownPeerDescriptor.nodeName +
|
|
88
|
+
', ' + this.peerDescriptor?.nodeName + ' objectid: ' + this.objectId
|
|
89
|
+
+ ' outputBuffer.length: ' + this.outputBuffer.length);
|
|
90
|
+
this.attachImplementation(outgoingConnection);
|
|
91
|
+
this.onHandshakeCompleted(peerDescriptor);
|
|
92
|
+
});
|
|
93
|
+
outgoingConnection.once('connected', () => {
|
|
94
|
+
this.handshaker.sendHandshakeRequest();
|
|
95
|
+
this.emit('connected');
|
|
96
|
+
});
|
|
97
|
+
outgoingConnection.once('disconnected', this.onDisconnected);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (incomingConnection) {
|
|
101
|
+
this.handshaker = new Handshaker_1.Handshaker(this.ownPeerDescriptor, this.protocolVersion, incomingConnection);
|
|
102
|
+
this.handshaker.on('handshakeRequest', (peerDescriptor) => {
|
|
103
|
+
this.setPeerDescriptor(peerDescriptor);
|
|
104
|
+
this.emit('handshakeRequest', peerDescriptor);
|
|
105
|
+
});
|
|
106
|
+
incomingConnection.on('disconnected', this.onDisconnected);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// eventemitter3 does not implement the standard 'newListener' event, so we need to override
|
|
111
|
+
on(event, fn,
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
113
|
+
context) {
|
|
114
|
+
if (event === 'managedData' && this.listenerCount('managedData') === 0) {
|
|
115
|
+
while (this.inputBuffer.length > 0) {
|
|
116
|
+
logger.trace('emptying inputBuffer objectId: ' + this.objectId);
|
|
117
|
+
const data = this.inputBuffer.shift();
|
|
118
|
+
fn(data, this.getPeerDescriptor());
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
super.on(event, fn, context);
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
once(event, fn,
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
126
|
+
context) {
|
|
127
|
+
if (event === 'managedData' && this.listenerCount('managedData') === 0) {
|
|
128
|
+
if (this.inputBuffer.length > 0) {
|
|
129
|
+
while (this.inputBuffer.length > 0) {
|
|
130
|
+
logger.trace('emptying inputBuffer objectId: ' + this.objectId);
|
|
131
|
+
const data = this.inputBuffer.shift();
|
|
132
|
+
fn(data, this.getPeerDescriptor());
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
super.once(event, fn, context);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
super.once(event, fn, context);
|
|
141
|
+
}
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
get peerIdKey() {
|
|
145
|
+
return (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.peerDescriptor);
|
|
146
|
+
}
|
|
147
|
+
getLastUsed() {
|
|
148
|
+
return this.lastUsed;
|
|
149
|
+
}
|
|
150
|
+
setPeerDescriptor(peerDescriptor) {
|
|
151
|
+
this.peerDescriptor = peerDescriptor;
|
|
152
|
+
}
|
|
153
|
+
getPeerDescriptor() {
|
|
154
|
+
return this.peerDescriptor;
|
|
155
|
+
}
|
|
156
|
+
attachImplementation(impl, _peerDescriptor) {
|
|
157
|
+
logger.trace('attachImplementation() objectId: ' + this.objectId);
|
|
158
|
+
this.implementation = impl;
|
|
159
|
+
impl.on('data', (bytes) => {
|
|
160
|
+
this.lastUsed = Date.now();
|
|
161
|
+
if (this.listenerCount('managedData') < 1) {
|
|
162
|
+
this.inputBuffer.push(bytes);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.emit('managedData', bytes, this.getPeerDescriptor());
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
impl.on('error', (name) => {
|
|
169
|
+
this.emit('error', name);
|
|
170
|
+
});
|
|
171
|
+
impl.on('connected', () => {
|
|
172
|
+
this.lastUsed = Date.now();
|
|
173
|
+
logger.trace('connected emitted');
|
|
174
|
+
this.emit('connected');
|
|
175
|
+
});
|
|
176
|
+
impl.off('disconnected', this.onDisconnected);
|
|
177
|
+
impl.on('disconnected', this.onDisconnected);
|
|
178
|
+
}
|
|
179
|
+
onDisconnected(disconnectionType, _code, _reason) {
|
|
180
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' onDisconnected() ' + disconnectionType);
|
|
181
|
+
if (this.bufferSentbyOtherConnection) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
this.emit('internal_disconnected');
|
|
185
|
+
this.doDisconnect(disconnectionType);
|
|
186
|
+
}
|
|
187
|
+
async send(data, doNotConnect = false) {
|
|
188
|
+
if (this.stopped) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (this.closing) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.lastUsed = Date.now();
|
|
195
|
+
if (doNotConnect && !this.implementation) {
|
|
196
|
+
throw new Err.ConnectionNotOpen('Connection not open when calling send() with doNotConnect flag');
|
|
197
|
+
}
|
|
198
|
+
else if (this.implementation) {
|
|
199
|
+
this.implementation.send(data);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
logger.trace('adding data to outputBuffer objectId: ' + this.objectId);
|
|
203
|
+
let result;
|
|
204
|
+
this.doNotEmitDisconnected = true;
|
|
205
|
+
try {
|
|
206
|
+
result = await (0, utils_1.runAndRaceEvents3)([() => { this.outputBuffer.push(data); }], this, ['handshakeCompleted', 'handshakeFailed',
|
|
207
|
+
'bufferSentByOtherConnection', 'closing', 'internal_disconnected'], 15000);
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
logger.debug(`Connection from ${this.ownPeerDescriptor.nodeName} to ${this.peerDescriptor?.nodeName} timed out`);
|
|
211
|
+
throw e;
|
|
212
|
+
}
|
|
213
|
+
if (result.winnerName === 'internal_disconnected') {
|
|
214
|
+
this.doNotEmitDisconnected = false;
|
|
215
|
+
this.doDisconnect('OTHER');
|
|
216
|
+
}
|
|
217
|
+
else if (result.winnerName === 'handshakeFailed') {
|
|
218
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' handshakeFailed received');
|
|
219
|
+
if (this.bufferSentbyOtherConnection) {
|
|
220
|
+
logger.trace('bufferSentByOtherConnection already true');
|
|
221
|
+
this.doNotEmitDisconnected = false;
|
|
222
|
+
this.doDisconnect('OTHER');
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
let result2;
|
|
226
|
+
try {
|
|
227
|
+
result2 = await (0, utils_1.raceEvents3)(this, ['bufferSentByOtherConnection', 'closing', 'disconnected'], 15000);
|
|
228
|
+
}
|
|
229
|
+
catch (ex) {
|
|
230
|
+
logger.debug(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName +
|
|
231
|
+
' Exception from raceEvents3 while waiting bufferSentByOtherConnection or closing ' + ex);
|
|
232
|
+
logger.trace(this.connectionId + ' Exception from raceEvents3 while waiting bufferSentByOtherConnection');
|
|
233
|
+
throw ex;
|
|
234
|
+
}
|
|
235
|
+
if (result2.winnerName === 'bufferSentByOtherConnection') {
|
|
236
|
+
logger.trace('bufferSentByOtherConnection received');
|
|
237
|
+
this.doNotEmitDisconnected = false;
|
|
238
|
+
this.doDisconnect('OTHER');
|
|
239
|
+
}
|
|
240
|
+
else if (result2.winnerName === 'closing') {
|
|
241
|
+
logger.trace('bufferSentByOtherConnection not received, instead received a closing event');
|
|
242
|
+
}
|
|
243
|
+
else if (result2.winnerName === 'disconnected') {
|
|
244
|
+
logger.trace('disconnected while in raceEvents3');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this.doNotEmitDisconnected = false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
sendNoWait(data) {
|
|
254
|
+
this.lastUsed = Date.now();
|
|
255
|
+
if (this.implementation) {
|
|
256
|
+
this.implementation.send(data);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
logger.trace('adding data to outputBuffer objectId: ' + this.objectId);
|
|
260
|
+
this.outputBuffer.push(data);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
reportBufferSentByOtherConnection() {
|
|
264
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' reportBufferSentByOtherConnection');
|
|
265
|
+
if (this.handshaker) {
|
|
266
|
+
this.handshaker.removeAllListeners();
|
|
267
|
+
}
|
|
268
|
+
logger.trace('bufferSentByOtherConnection reported');
|
|
269
|
+
this.bufferSentbyOtherConnection = true;
|
|
270
|
+
this.emit('bufferSentByOtherConnection');
|
|
271
|
+
}
|
|
272
|
+
reportBufferSendingByOtherConnectionFailed() {
|
|
273
|
+
logger.trace('reportBufferSendingByOtherConnectionFailed');
|
|
274
|
+
this.doDisconnect('OTHER');
|
|
275
|
+
}
|
|
276
|
+
acceptHandshake() {
|
|
277
|
+
// This happens when connectionRequest has been made and answered
|
|
278
|
+
if (this.implementation) {
|
|
279
|
+
if (!this.handshaker) {
|
|
280
|
+
this.handshaker = new Handshaker_1.Handshaker(this.ownPeerDescriptor, this.protocolVersion, this.implementation);
|
|
281
|
+
}
|
|
282
|
+
this.handshaker.sendHandshakeResponse();
|
|
283
|
+
}
|
|
284
|
+
else { // This happens to when there is a regular incoming connection
|
|
285
|
+
this.handshaker.sendHandshakeResponse();
|
|
286
|
+
this.attachImplementation(this.incomingConnection);
|
|
287
|
+
}
|
|
288
|
+
this.onHandshakeCompleted(this.peerDescriptor);
|
|
289
|
+
}
|
|
290
|
+
rejectHandshake(errorMessage) {
|
|
291
|
+
this.handshaker.sendHandshakeResponse(errorMessage);
|
|
292
|
+
}
|
|
293
|
+
doDisconnect(disconnectionType) {
|
|
294
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' doDisconnect() emitting');
|
|
295
|
+
if (!this.doNotEmitDisconnected) {
|
|
296
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName + ' emitting disconnected');
|
|
297
|
+
this.emit('disconnected', disconnectionType);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
logger.trace(' ' + this.ownPeerDescriptor.nodeName + ', ' + this.peerDescriptor?.nodeName +
|
|
301
|
+
' not emitting disconnected because doNotEmitDisconnected flag is set');
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
async close(disconnectionType) {
|
|
305
|
+
if (this.replacedByOtherConnection) {
|
|
306
|
+
logger.trace('close() called on replaced connection');
|
|
307
|
+
}
|
|
308
|
+
this.closing = true;
|
|
309
|
+
this.emit('closing');
|
|
310
|
+
this.doNotEmitDisconnected = false;
|
|
311
|
+
if (this.implementation) {
|
|
312
|
+
await this.implementation?.close(disconnectionType);
|
|
313
|
+
}
|
|
314
|
+
else if (this.outgoingConnection) {
|
|
315
|
+
await this.outgoingConnection?.close(disconnectionType);
|
|
316
|
+
}
|
|
317
|
+
else if (this.incomingConnection) {
|
|
318
|
+
await this.incomingConnection?.close(disconnectionType);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this.doDisconnect(disconnectionType);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
destroy() {
|
|
325
|
+
this.closing = true;
|
|
326
|
+
this.emit('closing');
|
|
327
|
+
if (!this.stopped) {
|
|
328
|
+
this.stopped = true;
|
|
329
|
+
this.removeAllListeners();
|
|
330
|
+
if (this.implementation) {
|
|
331
|
+
this.implementation?.destroy();
|
|
332
|
+
}
|
|
333
|
+
else if (this.outgoingConnection) {
|
|
334
|
+
this.outgoingConnection?.destroy();
|
|
335
|
+
}
|
|
336
|
+
else if (this.incomingConnection) {
|
|
337
|
+
this.incomingConnection?.destroy();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
isHandshakeCompleted() {
|
|
342
|
+
return this.handshakeCompleted;
|
|
343
|
+
}
|
|
344
|
+
stealOutputBuffer() {
|
|
345
|
+
const ret = this.outputBuffer;
|
|
346
|
+
this.outputBuffer = [];
|
|
347
|
+
return ret;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
exports.ManagedConnection = ManagedConnection;
|
|
351
|
+
ManagedConnection.objectCounter = 0;
|
|
352
|
+
//# sourceMappingURL=ManagedConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagedConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA2F;AAC3F,uDAAwC;AACxC,6CAAyC;AAEzC,0CAAmG;AACnG,kEAAwC;AAExC,kFAA2E;AAa3E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAGjC,MAAa,iBAAkB,SAAQ,uBAAoB;IA6BvD,YACI,iBAAiC,EACjC,eAAuB,EACvB,cAA8B,EAC9B,kBAAgC,EAChC,kBAAgC;QAEhC,KAAK,EAAE,CAAA;QAjCJ,aAAQ,GAAG,CAAC,CAAA;QAGX,iBAAY,GAAiB,EAAE,CAAA;QAC/B,gBAAW,GAAiB,EAAE,CAAA;QAO9B,uBAAkB,GAA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IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAA;aACjC;iBAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBAChC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAA;aACrC;iBAAM,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBAChC,IAAI,CAAC,kBAAkB,EAAE,OAAO,EAAE,CAAA;aACrC;SACJ;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;;AArXL,8CAsXC;AApXkB,+BAAa,GAAG,CAAC,AAAJ,CAAI"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { ManagedConnection } from './ManagedConnection';
|
|
3
|
+
import { NodeWebRtcConnection } from './WebRTC/NodeWebRtcConnection';
|
|
4
|
+
export declare class ManagedWebRtcConnection extends ManagedConnection {
|
|
5
|
+
constructor(ownPeerDescriptor: PeerDescriptor, protocolVersion: string, connectingConnection?: NodeWebRtcConnection, connectedConnection?: NodeWebRtcConnection);
|
|
6
|
+
getWebRtcConnection(): NodeWebRtcConnection;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ManagedWebRtcConnection = void 0;
|
|
4
|
+
const IConnection_1 = require("./IConnection");
|
|
5
|
+
const ManagedConnection_1 = require("./ManagedConnection");
|
|
6
|
+
class ManagedWebRtcConnection extends ManagedConnection_1.ManagedConnection {
|
|
7
|
+
constructor(ownPeerDescriptor, protocolVersion, connectingConnection, connectedConnection) {
|
|
8
|
+
super(ownPeerDescriptor, protocolVersion, IConnection_1.ConnectionType.WEBRTC, connectingConnection, connectedConnection);
|
|
9
|
+
}
|
|
10
|
+
getWebRtcConnection() {
|
|
11
|
+
if (this.outgoingConnection) {
|
|
12
|
+
return this.outgoingConnection;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return this.incomingConnection;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.ManagedWebRtcConnection = ManagedWebRtcConnection;
|
|
20
|
+
//# sourceMappingURL=ManagedWebRtcConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagedWebRtcConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedWebRtcConnection.ts"],"names":[],"mappings":";;;AACA,+CAA8C;AAC9C,2DAAuD;AAGvD,MAAa,uBAAwB,SAAQ,qCAAiB;IAE1D,YAAY,iBAAiC,EACzC,eAAuB,EACvB,oBAA2C,EAC3C,mBAA0C;QAC1C,KAAK,CACD,iBAAiB,EACjB,eAAe,EACf,4BAAc,CAAC,MAAM,EACrB,oBAAoB,EACpB,mBAAmB,CAAC,CAAA;IAC5B,CAAC;IAEM,mBAAmB;QACtB,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,OAAO,IAAI,CAAC,kBAAqD,CAAA;SACpE;aAAM;YACH,OAAO,IAAI,CAAC,kBAAqD,CAAA;SACpE;IACL,CAAC;CACJ;AArBD,0DAqBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
2
|
+
import { IConnectionLockerClient } from '../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
+
import { PeerDescriptor, DisconnectMode } from '../proto/packages/dht/protos/DhtRpc';
|
|
4
|
+
export declare class RemoteConnectionLocker {
|
|
5
|
+
private peerId;
|
|
6
|
+
private ownPeerDescriptor;
|
|
7
|
+
private targetPeerDescriptor;
|
|
8
|
+
private protocolVersion;
|
|
9
|
+
private client;
|
|
10
|
+
constructor(ownPeerDescriptor: PeerDescriptor, targetPeerDescriptor: PeerDescriptor, protocolVersion: string, client: ProtoRpcClient<IConnectionLockerClient>);
|
|
11
|
+
lockRequest(serviceId: string): Promise<boolean>;
|
|
12
|
+
unlockRequest(serviceId: string): void;
|
|
13
|
+
gracefulDisconnect(disconnecMode: DisconnectMode): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RemoteConnectionLocker = void 0;
|
|
27
|
+
const utils_1 = require("@streamr/utils");
|
|
28
|
+
const Err = __importStar(require("../helpers/errors"));
|
|
29
|
+
const peerIdFromPeerDescriptor_1 = require("../helpers/peerIdFromPeerDescriptor");
|
|
30
|
+
const logger = new utils_1.Logger(module);
|
|
31
|
+
class RemoteConnectionLocker {
|
|
32
|
+
constructor(ownPeerDescriptor, targetPeerDescriptor, protocolVersion, client) {
|
|
33
|
+
this.peerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
34
|
+
this.ownPeerDescriptor = ownPeerDescriptor;
|
|
35
|
+
this.targetPeerDescriptor = targetPeerDescriptor;
|
|
36
|
+
this.protocolVersion = protocolVersion;
|
|
37
|
+
this.client = client;
|
|
38
|
+
}
|
|
39
|
+
async lockRequest(serviceId) {
|
|
40
|
+
logger.trace(`Requesting locked connection to ${this.targetPeerDescriptor.kademliaId.toString()}`);
|
|
41
|
+
const request = {
|
|
42
|
+
peerDescriptor: this.ownPeerDescriptor,
|
|
43
|
+
protocolVersion: this.protocolVersion,
|
|
44
|
+
serviceId
|
|
45
|
+
};
|
|
46
|
+
const options = {
|
|
47
|
+
sourceDescriptor: this.ownPeerDescriptor,
|
|
48
|
+
targetDescriptor: this.targetPeerDescriptor
|
|
49
|
+
};
|
|
50
|
+
try {
|
|
51
|
+
const res = await this.client.lockRequest(request, options);
|
|
52
|
+
return res.accepted;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
logger.debug(new Err.ConnectionLocker('Connection lock rejected', err).stack);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
unlockRequest(serviceId) {
|
|
60
|
+
logger.trace(`Requesting connection to be unlocked from ${this.targetPeerDescriptor.kademliaId.toString()}`);
|
|
61
|
+
const request = {
|
|
62
|
+
peerDescriptor: this.ownPeerDescriptor,
|
|
63
|
+
protocolVersion: this.protocolVersion,
|
|
64
|
+
serviceId
|
|
65
|
+
};
|
|
66
|
+
const options = {
|
|
67
|
+
sourceDescriptor: this.ownPeerDescriptor,
|
|
68
|
+
targetDescriptor: this.targetPeerDescriptor,
|
|
69
|
+
notification: true
|
|
70
|
+
};
|
|
71
|
+
this.client.unlockRequest(request, options).catch((_e) => {
|
|
72
|
+
logger.trace('failed to send unlockRequest');
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async gracefulDisconnect(disconnecMode) {
|
|
76
|
+
logger.trace(`Notifying a graceful disconnect to ${this.targetPeerDescriptor.nodeName} from ${this.ownPeerDescriptor.nodeName}`);
|
|
77
|
+
const request = {
|
|
78
|
+
peerDescriptor: this.ownPeerDescriptor,
|
|
79
|
+
protocolVersion: this.protocolVersion,
|
|
80
|
+
disconnecMode: disconnecMode
|
|
81
|
+
};
|
|
82
|
+
const options = {
|
|
83
|
+
sourceDescriptor: this.ownPeerDescriptor,
|
|
84
|
+
targetDescriptor: this.targetPeerDescriptor,
|
|
85
|
+
doNotConnect: true,
|
|
86
|
+
doNotMindStopped: true,
|
|
87
|
+
timeout: 2000
|
|
88
|
+
};
|
|
89
|
+
await this.client.gracefulDisconnect(request, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.RemoteConnectionLocker = RemoteConnectionLocker;
|
|
93
|
+
//# sourceMappingURL=RemoteConnectionLocker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteConnectionLocker.js","sourceRoot":"","sources":["../../../src/connection/RemoteConnectionLocker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AAOvC,uDAAwC;AACxC,kFAA8E;AAE9E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,sBAAsB;IAO/B,YACI,iBAAiC,EACjC,oBAAoC,EACpC,eAAuB,EACvB,MAA+C;QAE/C,IAAI,CAAC,MAAM,GAAG,IAAA,mDAAwB,EAAC,oBAAoB,CAAC,CAAA;QAC5D,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;QAC1C,I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Y,EAAE,IAAI;SACrB,CAAA;QAED,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACrD,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;IAEN,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,aAA6B;QACzD,MAAM,CAAC,KAAK,CAAC,sCAAsC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,SAAS,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAA;QAChI,MAAM,OAAO,GAAqB;YAC9B,cAAc,EAAE,IAAI,CAAC,iBAAiB;YACtC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,aAAa,EAAE,aAAa;SAC/B,CAAA;QACD,MAAM,OAAO,GAAG;YACZ,gBAAgB,EAAE,IAAI,CAAC,iBAAiB;YACxC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB;YAC3C,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE,IAAI;YACtB,OAAO,EAAE,IAAI;SAChB,CAAA;QACD,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC1D,CAAC;CACJ;AA3ED,wDA2EC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
+
import { ConnectionSourceEvents } from '../IConnectionSource';
|
|
4
|
+
import { SimulatorConnector } from './SimulatorConnector';
|
|
5
|
+
import { SimulatorConnection } from './SimulatorConnection';
|
|
6
|
+
export declare enum LatencyType {
|
|
7
|
+
NONE = "NONE",
|
|
8
|
+
RANDOM = "RANDOM",
|
|
9
|
+
REAL = "REAL",
|
|
10
|
+
FIXED = "FIXED"
|
|
11
|
+
}
|
|
12
|
+
export declare class Simulator extends EventEmitter<ConnectionSourceEvents> {
|
|
13
|
+
private stopped;
|
|
14
|
+
private connectors;
|
|
15
|
+
private latencyTable?;
|
|
16
|
+
private associations;
|
|
17
|
+
private latencyType;
|
|
18
|
+
private fixedLatency?;
|
|
19
|
+
private loopCounter;
|
|
20
|
+
private operationCounter;
|
|
21
|
+
private MAX_LOOPS;
|
|
22
|
+
private operationQueue;
|
|
23
|
+
private simulatorTimeout?;
|
|
24
|
+
private static clock;
|
|
25
|
+
static useFakeTimers(on?: boolean): void;
|
|
26
|
+
constructor(latencyType?: LatencyType, fixedLatency?: number);
|
|
27
|
+
private generateExecutionTime;
|
|
28
|
+
private getLatency;
|
|
29
|
+
accept(sourceConnection: SimulatorConnection, targetConnection: SimulatorConnection): void;
|
|
30
|
+
addConnector(connector: SimulatorConnector): void;
|
|
31
|
+
private executeConnectOperation;
|
|
32
|
+
private executeCloseOperation;
|
|
33
|
+
private executeSendOperation;
|
|
34
|
+
private executeQueuedOperations;
|
|
35
|
+
getOperationCounter(): number;
|
|
36
|
+
private scheduleNextTimeout;
|
|
37
|
+
private scheduleOperation;
|
|
38
|
+
connect(sourceConnection: SimulatorConnection, targetDescriptor: PeerDescriptor, connectedCallback: (error?: string) => void): void;
|
|
39
|
+
close(sourceConnection: SimulatorConnection): void;
|
|
40
|
+
send(sourceConnection: SimulatorConnection, data: Uint8Array): void;
|
|
41
|
+
stop(): void;
|
|
42
|
+
}
|