@streamr/dht 101.1.1 → 102.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.
- package/.eslintignore +1 -1
- package/dist/{src/proto → generated}/google/protobuf/any.d.ts +11 -4
- package/dist/generated/google/protobuf/any.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/empty.d.ts +0 -1
- package/dist/generated/google/protobuf/empty.js.map +1 -0
- package/dist/{src/proto → generated}/google/protobuf/timestamp.d.ts +9 -3
- package/dist/generated/google/protobuf/timestamp.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.d.ts +9 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.client.js +7 -0
- package/dist/generated/packages/dht/protos/DhtRpc.client.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.d.ts +16 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.js +16 -2
- package/dist/generated/packages/dht/protos/DhtRpc.js.map +1 -0
- package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.d.ts +5 -0
- package/dist/generated/packages/dht/protos/DhtRpc.server.js.map +1 -0
- package/dist/generated/packages/proto-rpc/protos/ProtoRpc.js.map +1 -0
- package/dist/package.json +11 -11
- package/dist/src/connection/Connection.d.ts +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +5 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +9 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -2
- package/dist/src/connection/ConnectionLockRpcRemote.js +14 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionLockStates.d.ts +5 -0
- package/dist/src/connection/ConnectionLockStates.js +14 -0
- package/dist/src/connection/ConnectionLockStates.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +8 -1
- package/dist/src/connection/ConnectionManager.js +78 -24
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectionsView.d.ts +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +1 -1
- package/dist/src/connection/Handshaker.d.ts +1 -1
- package/dist/src/connection/Handshaker.js +2 -2
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +7 -1
- package/dist/src/connection/ManagedConnection.js +24 -1
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/PendingConnection.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +1 -1
- package/dist/src/connection/connectivityChecker.js +2 -1
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +1 -1
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -1
- package/dist/src/connection/simulator/Simulator.js +2 -2
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +9 -9
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +4 -4
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/simulator/SimulatorTransport.js +2 -1
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +13 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +2 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +9 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +4 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.d.ts +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.js +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +3 -3
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.d.ts +1 -1
- package/dist/src/connection/websocket/WebsocketServerConnector.js +7 -7
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +4 -2
- package/dist/src/dht/DhtNode.js +17 -6
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +2 -2
- package/dist/src/dht/DhtNodeRpcRemote.js +3 -3
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +1 -1
- package/dist/src/dht/PeerManager.js +10 -10
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +1 -1
- package/dist/src/dht/contact/Contact.js +1 -1
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +1 -1
- package/dist/src/dht/contact/RingContactList.js +1 -1
- package/dist/src/dht/contact/RingContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +1 -1
- package/dist/src/dht/contact/SortedContactList.js +1 -1
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +1 -1
- package/dist/src/dht/discovery/DiscoverySession.js +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.js +7 -7
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +2 -2
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/Router.d.ts +4 -1
- package/dist/src/dht/routing/Router.js +17 -9
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcLocal.js +5 -5
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +2 -2
- package/dist/src/dht/routing/RouterRpcRemote.js +7 -7
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +1 -1
- package/dist/src/dht/routing/RoutingSession.js +5 -6
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +1 -1
- package/dist/src/dht/store/LocalDataStore.js +2 -2
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +2 -2
- package/dist/src/dht/store/StoreManager.js +8 -8
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +4 -4
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcRemote.js +7 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -2
- package/dist/src/exports.js +6 -6
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +1 -1
- package/dist/src/helpers/Connectivity.js +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptor.js +2 -2
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +1 -1
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +1 -1
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/identifiers.d.ts +5 -5
- package/dist/src/identifiers.js +11 -11
- package/dist/src/identifiers.js.map +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +1 -1
- package/dist/src/transport/ITransport.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +13 -4
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +1 -1
- package/{src/proto → generated}/google/protobuf/any.ts +11 -4
- package/{src/proto → generated}/google/protobuf/empty.ts +0 -1
- package/{src/proto → generated}/google/protobuf/timestamp.ts +9 -3
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.client.ts +12 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.server.ts +5 -0
- package/{src/proto → generated}/packages/dht/protos/DhtRpc.ts +23 -1
- package/package.json +11 -11
- package/proto.sh +2 -3
- package/protos/DhtRpc.proto +5 -0
- package/src/connection/Connection.ts +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +16 -7
- package/src/connection/ConnectionLockRpcRemote.ts +18 -6
- package/src/connection/ConnectionLockStates.ts +18 -0
- package/src/connection/ConnectionManager.ts +92 -26
- package/src/connection/ConnectionsView.ts +1 -1
- package/src/connection/ConnectorFacade.ts +1 -1
- package/src/connection/Handshaker.ts +3 -3
- package/src/connection/ManagedConnection.ts +28 -3
- package/src/connection/PendingConnection.ts +1 -1
- package/src/connection/connectivityChecker.ts +2 -1
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +4 -4
- package/src/connection/simulator/SimulatorConnection.ts +10 -10
- package/src/connection/simulator/SimulatorConnector.ts +5 -5
- package/src/connection/simulator/SimulatorTransport.ts +3 -2
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +10 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +15 -9
- package/src/connection/webrtc/WebrtcConnector.ts +10 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +8 -8
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +2 -2
- package/src/connection/websocket/WebsocketClientConnector.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +5 -5
- package/src/connection/websocket/WebsocketClientConnectorRpcRemote.ts +4 -4
- package/src/connection/websocket/WebsocketServerConnector.ts +8 -8
- package/src/dht/DhtNode.ts +21 -8
- package/src/dht/DhtNodeRpcLocal.ts +7 -7
- package/src/dht/DhtNodeRpcRemote.ts +5 -5
- package/src/dht/ExternalApiRpcLocal.ts +8 -8
- package/src/dht/ExternalApiRpcRemote.ts +6 -6
- package/src/dht/PeerManager.ts +12 -12
- package/src/dht/contact/Contact.ts +3 -3
- package/src/dht/contact/RingContactList.ts +3 -3
- package/src/dht/contact/RpcRemote.ts +1 -1
- package/src/dht/contact/SortedContactList.ts +2 -2
- package/src/dht/contact/ringIdentifiers.ts +1 -1
- package/src/dht/discovery/DiscoverySession.ts +5 -5
- package/src/dht/discovery/PeerDiscovery.ts +12 -12
- package/src/dht/discovery/RingDiscoverySession.ts +3 -3
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +4 -4
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +6 -6
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +8 -8
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +5 -5
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +2 -2
- package/src/dht/routing/Router.ts +19 -10
- package/src/dht/routing/RouterRpcLocal.ts +7 -7
- package/src/dht/routing/RouterRpcRemote.ts +9 -9
- package/src/dht/routing/RoutingSession.ts +7 -8
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +4 -4
- package/src/dht/store/StoreManager.ts +12 -12
- package/src/dht/store/StoreRpcLocal.ts +8 -8
- package/src/dht/store/StoreRpcRemote.ts +10 -7
- package/src/exports.ts +5 -5
- package/src/helpers/Connectivity.ts +1 -1
- package/src/helpers/createPeerDescriptor.ts +3 -3
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +1 -1
- package/src/helpers/protoClasses.ts +1 -1
- package/src/identifiers.ts +7 -7
- package/src/rpc-protocol/DhtCallContext.ts +1 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +1 -1
- package/src/transport/ITransport.ts +2 -1
- package/src/transport/ListeningRpcCommunicator.ts +14 -6
- package/src/transport/RoutingRpcCommunicator.ts +2 -2
- package/test/benchmark/Find.test.ts +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +5 -5
- package/test/benchmark/RingCorrectness.test.ts +5 -5
- package/test/benchmark/SortedContactListBenchmark.test.ts +10 -10
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +1 -1
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +6 -6
- package/test/end-to-end/Layer0Webrtc.test.ts +6 -6
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +1 -1
- package/test/end-to-end/memory-leak.test.ts +4 -4
- package/test/integration/ConnectionLocking.test.ts +16 -15
- package/test/integration/ConnectionManager.test.ts +62 -6
- package/test/integration/ConnectivityChecking.test.ts +2 -1
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNode.test.ts +4 -4
- package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
- package/test/integration/DhtNodeRpcRemote.test.ts +9 -9
- package/test/integration/DhtRpc.test.ts +12 -13
- package/test/integration/Find.test.ts +5 -5
- package/test/integration/GeoIpConnectivityChecking.test.ts +2 -1
- package/test/integration/Layer1-scale.test.ts +2 -2
- package/test/integration/Mock-Layer1-Layer0.test.ts +6 -6
- package/test/integration/MultipleEntryPointJoining.test.ts +1 -1
- package/test/integration/ReplicateData.test.ts +10 -11
- package/test/integration/RouteMessage.test.ts +9 -9
- package/test/integration/RouterRpcRemote.test.ts +7 -7
- package/test/integration/SimultaneousConnections.test.ts +13 -12
- package/test/integration/Store.test.ts +9 -9
- package/test/integration/StoreAndDelete.test.ts +10 -10
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +9 -9
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/StoreRpcRemote.test.ts +10 -10
- package/test/integration/WebrtcConnectionManagement.test.ts +4 -3
- package/test/integration/WebrtcConnectorRpc.test.ts +9 -9
- package/test/integration/Websocket.test.ts +0 -2
- package/test/integration/WebsocketClientConnectorRpc.test.ts +8 -8
- package/test/integration/WebsocketConnectionManagement.test.ts +8 -9
- package/test/integration/{rpc-connections-over-webrpc.test.ts → rpc-connections-over-webrtc.test.ts} +4 -3
- package/test/unit/ConnectionManager.test.ts +4 -3
- package/test/unit/ConnectivityHelpers.test.ts +1 -1
- package/test/unit/DiscoverySession.test.ts +6 -6
- package/test/unit/Handshaker.test.ts +1 -1
- package/test/unit/ListeningRpcCommunicator.test.ts +52 -0
- package/test/unit/LocalDataStore.test.ts +21 -21
- package/test/unit/PeerManager.test.ts +13 -13
- package/test/unit/PendingConnection.test.ts +1 -1
- package/test/unit/ProtobufMessage.test.ts +1 -1
- package/test/unit/RandomContactList.test.ts +2 -2
- package/test/unit/RecursiveOperationManager.test.ts +3 -3
- package/test/unit/RecursiveOperationSession.test.ts +4 -4
- package/test/unit/Router.test.ts +6 -6
- package/test/unit/RoutingSession.test.ts +6 -6
- package/test/unit/SortedContactList.test.ts +5 -5
- package/test/unit/StoreManager.test.ts +10 -10
- package/test/unit/StoreRpcLocal.test.ts +9 -9
- package/test/unit/WebrtcConnection.test.ts +29 -0
- package/test/unit/WebsocketClientConnector.test.ts +1 -1
- package/test/unit/WebsocketServerConnector.test.ts +1 -1
- package/test/unit/connectivityRequestHandler.test.ts +1 -1
- package/test/unit/createPeerDescriptor.test.ts +4 -4
- package/test/unit/getClosestNodes.test.ts +5 -5
- package/test/utils/FakeConnectorFacade.ts +1 -1
- package/test/utils/FakeTransport.ts +12 -9
- package/test/utils/customMatchers.ts +3 -3
- package/test/utils/mock/MockConnectionsView.ts +1 -1
- package/test/utils/mock/MockRouter.ts +5 -1
- package/test/utils/mock/MockTransport.ts +6 -1
- package/test/utils/mock/mockDataEntry.ts +6 -6
- package/test/utils/topology.ts +3 -3
- package/test/utils/utils.ts +9 -9
- package/tsconfig.jest.json +2 -1
- package/tsconfig.node.json +1 -0
- package/dist/src/proto/google/protobuf/any.js.map +0 -1
- package/dist/src/proto/google/protobuf/empty.js.map +0 -1
- package/dist/src/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +0 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.js.map +0 -1
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js.map +0 -1
- package/dist/src/proto/tests.d.ts +0 -39
- package/dist/src/proto/tests.js +0 -34
- package/dist/src/proto/tests.js.map +0 -1
- package/src/proto/tests.ts +0 -52
- package/test/benchmark/any.test.ts +0 -28
- /package/dist/{src/proto → generated}/google/protobuf/any.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/empty.js +0 -0
- /package/dist/{src/proto → generated}/google/protobuf/timestamp.js +0 -0
- /package/dist/{src/proto → generated}/packages/dht/protos/DhtRpc.server.js +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.d.ts +0 -0
- /package/dist/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.js +0 -0
- /package/{src/proto → generated}/packages/proto-rpc/protos/ProtoRpc.ts +0 -0
- /package/{src/types/glogal.d.ts → test/types/global.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DhtAddress } from '../identifiers'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
|
|
4
4
|
export interface ConnectionsView {
|
|
5
5
|
getConnections: () => PeerDescriptor[]
|
|
@@ -2,7 +2,7 @@ import { Logger } from '@streamr/utils'
|
|
|
2
2
|
import {
|
|
3
3
|
ConnectivityResponse,
|
|
4
4
|
PeerDescriptor
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
6
6
|
import { ITransport } from '../transport/ITransport'
|
|
7
7
|
import { PortRange, TlsCertificate } from './ConnectionManager'
|
|
8
8
|
import { Simulator } from './simulator/Simulator'
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Logger } from '@streamr/utils'
|
|
2
2
|
import { EventEmitter } from 'eventemitter3'
|
|
3
3
|
import { v4 } from 'uuid'
|
|
4
|
-
import { Message, HandshakeRequest, HandshakeResponse, PeerDescriptor, HandshakeError } from '
|
|
4
|
+
import { Message, HandshakeRequest, HandshakeResponse, PeerDescriptor, HandshakeError } from '../../generated/packages/dht/protos/DhtRpc'
|
|
5
5
|
import { IConnection } from './IConnection'
|
|
6
6
|
import { LOCAL_PROTOCOL_VERSION, isMaybeSupportedVersion } from '../helpers/version'
|
|
7
|
-
import {
|
|
7
|
+
import { toNodeId } from '../identifiers'
|
|
8
8
|
import { PendingConnection } from './PendingConnection'
|
|
9
9
|
|
|
10
10
|
const logger = new Logger(module)
|
|
@@ -43,7 +43,7 @@ export const createOutgoingHandshaker = (
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
const handshakeCompletedListener = (peerDescriptor: PeerDescriptor) => {
|
|
46
|
-
logger.trace('handshake completed for outgoing connection, ' +
|
|
46
|
+
logger.trace('handshake completed for outgoing connection, ' + toNodeId(peerDescriptor))
|
|
47
47
|
pendingConnection.onHandshakeCompleted(connection)
|
|
48
48
|
stopHandshaker()
|
|
49
49
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConnectionID, IConnection } from './IConnection'
|
|
2
2
|
import * as Err from '../helpers/errors'
|
|
3
|
-
import { PeerDescriptor } from '
|
|
3
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { Logger } from '@streamr/utils'
|
|
5
5
|
import EventEmitter from 'eventemitter3'
|
|
6
6
|
import { getNodeIdOrUnknownFromPeerDescriptor } from './ConnectionManager'
|
|
7
|
-
import { DhtAddress,
|
|
7
|
+
import { DhtAddress, toNodeId } from '../identifiers'
|
|
8
8
|
import { createRandomConnectionId } from './Connection'
|
|
9
9
|
|
|
10
10
|
export interface ManagedConnectionEvents {
|
|
@@ -26,6 +26,11 @@ export class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
|
26
26
|
private lastUsedTimestamp: number = Date.now()
|
|
27
27
|
private replacedAsDuplicate = false
|
|
28
28
|
private stopped = false
|
|
29
|
+
private openedAt = Date.now()
|
|
30
|
+
private bytesSent = 0
|
|
31
|
+
private bytesReceived = 0
|
|
32
|
+
private messagesSent = 0
|
|
33
|
+
private messagesReceived = 0
|
|
29
34
|
|
|
30
35
|
constructor(peerDescriptor: PeerDescriptor, connection: IConnection) {
|
|
31
36
|
super()
|
|
@@ -34,6 +39,8 @@ export class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
|
34
39
|
|
|
35
40
|
connection.on('data', (bytes: Uint8Array) => {
|
|
36
41
|
this.lastUsedTimestamp = Date.now()
|
|
42
|
+
this.messagesReceived += 1
|
|
43
|
+
this.bytesReceived += bytes.length
|
|
37
44
|
this.emit('managedData', bytes, this.getPeerDescriptor()!)
|
|
38
45
|
})
|
|
39
46
|
connection.on('disconnected', (gracefulLeave) => this.onDisconnected(gracefulLeave))
|
|
@@ -62,6 +69,8 @@ export class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
|
62
69
|
throw new Err.SendFailed('ManagedConnection is stopped')
|
|
63
70
|
}
|
|
64
71
|
this.lastUsedTimestamp = Date.now()
|
|
72
|
+
this.messagesSent += 1
|
|
73
|
+
this.bytesSent += data.length
|
|
65
74
|
this.connection.send(data)
|
|
66
75
|
}
|
|
67
76
|
|
|
@@ -74,7 +83,7 @@ export class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
getNodeId(): DhtAddress {
|
|
77
|
-
return
|
|
86
|
+
return toNodeId(this.remotePeerDescriptor)
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
getLastUsedTimestamp(): number {
|
|
@@ -85,4 +94,20 @@ export class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
|
85
94
|
return this.remotePeerDescriptor
|
|
86
95
|
}
|
|
87
96
|
|
|
97
|
+
getDiagnosticInfo(): Record<string, unknown> {
|
|
98
|
+
return {
|
|
99
|
+
remotePeerDescriptor: this.remotePeerDescriptor,
|
|
100
|
+
lastUsedTimestamp: this.lastUsedTimestamp,
|
|
101
|
+
replacedAsDuplicate: this.replacedAsDuplicate,
|
|
102
|
+
stopped: this.stopped,
|
|
103
|
+
openedAt: this.openedAt,
|
|
104
|
+
bytesSent: this.bytesSent,
|
|
105
|
+
bytesReceived: this.bytesReceived,
|
|
106
|
+
messagesSent: this.messagesSent,
|
|
107
|
+
messagesReceived: this.messagesReceived
|
|
108
|
+
// Add connection type?
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
}
|
|
112
|
+
|
|
88
113
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EventEmitter from 'eventemitter3'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { Logger, setAbortableTimeout } from '@streamr/utils'
|
|
4
4
|
import { getNodeIdOrUnknownFromPeerDescriptor } from './ConnectionManager'
|
|
5
5
|
import { IConnection } from './IConnection'
|
|
@@ -4,7 +4,7 @@ import * as Err from '../helpers/errors'
|
|
|
4
4
|
import {
|
|
5
5
|
ConnectivityRequest, ConnectivityResponse,
|
|
6
6
|
Message, PeerDescriptor
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { ConnectionEvents, IConnection } from './IConnection'
|
|
9
9
|
import { WebsocketClientConnection } from './websocket/NodeWebsocketClientConnection'
|
|
10
10
|
import { connectivityMethodToWebsocketUrl } from './websocket/WebsocketClientConnector'
|
|
@@ -85,6 +85,7 @@ export const sendConnectivityRequest = async (
|
|
|
85
85
|
if (isMaybeSupportedVersion(remoteVersion)) {
|
|
86
86
|
resolve(connectivityResponseMessage)
|
|
87
87
|
} else {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
88
89
|
reject(`Unsupported version: ${remoteVersion}`)
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ConnectivityRequest,
|
|
5
5
|
ConnectivityResponse,
|
|
6
6
|
Message
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { NatType } from './ConnectionManager'
|
|
9
9
|
import { CONNECTIVITY_CHECKER_SERVICE_ID, connectAsync } from './connectivityChecker'
|
|
10
10
|
import { IConnection } from './IConnection'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { SimulatorConnector } from './SimulatorConnector'
|
|
4
4
|
import { SimulatorConnection } from './SimulatorConnection'
|
|
5
5
|
import { ConnectionID } from '../IConnection'
|
|
@@ -7,7 +7,7 @@ import { Logger } from '@streamr/utils'
|
|
|
7
7
|
import { getRegionDelayMatrix } from './pings'
|
|
8
8
|
import Heap from 'heap'
|
|
9
9
|
import { debugVars } from '../../helpers/debugHelpers'
|
|
10
|
-
import { DhtAddress,
|
|
10
|
+
import { DhtAddress, toNodeId } from '../../identifiers'
|
|
11
11
|
|
|
12
12
|
const logger = new Logger(module)
|
|
13
13
|
|
|
@@ -183,11 +183,11 @@ export class Simulator {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
public addConnector(connector: SimulatorConnector): void {
|
|
186
|
-
this.connectors.set(
|
|
186
|
+
this.connectors.set(toNodeId(connector.getPeerDescriptor()), connector)
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
private executeConnectOperation(operation: ConnectOperation): void {
|
|
190
|
-
const target = this.connectors.get(
|
|
190
|
+
const target = this.connectors.get(toNodeId(operation.targetDescriptor))
|
|
191
191
|
|
|
192
192
|
if (!target) {
|
|
193
193
|
logger.error('Target connector not found when executing connect operation')
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ConnectionType, IConnection } from '../IConnection'
|
|
2
2
|
import { Simulator } from './Simulator'
|
|
3
|
-
import { Message, PeerDescriptor } from '
|
|
3
|
+
import { Message, PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import { Connection } from '../Connection'
|
|
5
5
|
import { Logger } from '@streamr/utils'
|
|
6
6
|
import { protoToString } from '../../helpers/protoToString'
|
|
7
|
-
import {
|
|
7
|
+
import { toNodeId } from '../../identifiers'
|
|
8
8
|
|
|
9
9
|
const logger = new Logger(module)
|
|
10
10
|
|
|
@@ -45,15 +45,15 @@ export class SimulatorConnection extends Connection implements IConnection {
|
|
|
45
45
|
this.simulator.send(this, data)
|
|
46
46
|
|
|
47
47
|
} else {
|
|
48
|
-
const localNodeId =
|
|
49
|
-
const targetNodeId =
|
|
48
|
+
const localNodeId = toNodeId(this.localPeerDescriptor)
|
|
49
|
+
const targetNodeId = toNodeId(this.targetPeerDescriptor)
|
|
50
50
|
logger.error(localNodeId + ', ' + targetNodeId + 'tried to send() on a stopped connection')
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
public async close(gracefulLeave: boolean): Promise<void> {
|
|
55
|
-
const localNodeId =
|
|
56
|
-
const targetNodeId =
|
|
55
|
+
const localNodeId = toNodeId(this.localPeerDescriptor)
|
|
56
|
+
const targetNodeId = toNodeId(this.targetPeerDescriptor)
|
|
57
57
|
|
|
58
58
|
logger.trace(localNodeId + ', ' + targetNodeId + ' close()')
|
|
59
59
|
if (!this.stopped) {
|
|
@@ -104,7 +104,7 @@ export class SimulatorConnection extends Connection implements IConnection {
|
|
|
104
104
|
|
|
105
105
|
public handleIncomingDisconnection(): void {
|
|
106
106
|
if (!this.stopped) {
|
|
107
|
-
const localNodeId =
|
|
107
|
+
const localNodeId = toNodeId(this.localPeerDescriptor)
|
|
108
108
|
logger.trace(localNodeId + ' handleIncomingDisconnection()')
|
|
109
109
|
this.stopped = true
|
|
110
110
|
this.doDisconnect(false)
|
|
@@ -114,7 +114,7 @@ export class SimulatorConnection extends Connection implements IConnection {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
public destroy(): void {
|
|
117
|
-
const localNodeId =
|
|
117
|
+
const localNodeId = toNodeId(this.localPeerDescriptor)
|
|
118
118
|
if (!this.stopped) {
|
|
119
119
|
logger.trace(localNodeId + ' destroy()')
|
|
120
120
|
this.removeAllListeners()
|
|
@@ -125,8 +125,8 @@ export class SimulatorConnection extends Connection implements IConnection {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
private doDisconnect(gracefulLeave: boolean) {
|
|
128
|
-
const localNodeId =
|
|
129
|
-
const targetNodeId =
|
|
128
|
+
const localNodeId = toNodeId(this.localPeerDescriptor)
|
|
129
|
+
const targetNodeId = toNodeId(this.targetPeerDescriptor)
|
|
130
130
|
logger.trace(localNodeId + ' doDisconnect()')
|
|
131
131
|
this.stopped = true
|
|
132
132
|
|
|
@@ -3,11 +3,11 @@ import { ConnectionType } from '../IConnection'
|
|
|
3
3
|
import {
|
|
4
4
|
HandshakeError,
|
|
5
5
|
PeerDescriptor,
|
|
6
|
-
} from '
|
|
6
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
7
7
|
import { Logger } from '@streamr/utils'
|
|
8
8
|
import { Simulator } from './Simulator'
|
|
9
9
|
import { SimulatorConnection } from './SimulatorConnection'
|
|
10
|
-
import { DhtAddress,
|
|
10
|
+
import { DhtAddress, toNodeId } from '../../identifiers'
|
|
11
11
|
import { acceptHandshake, createIncomingHandshaker, createOutgoingHandshaker, rejectHandshake } from '../Handshaker'
|
|
12
12
|
import { PendingConnection } from '../PendingConnection'
|
|
13
13
|
|
|
@@ -32,8 +32,8 @@ export class SimulatorConnector {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
public connect(targetPeerDescriptor: PeerDescriptor): PendingConnection {
|
|
35
|
-
logger.trace('connect() ' +
|
|
36
|
-
const nodeId =
|
|
35
|
+
logger.trace('connect() ' + toNodeId(targetPeerDescriptor))
|
|
36
|
+
const nodeId = toNodeId(targetPeerDescriptor)
|
|
37
37
|
const existingConnection = this.connectingConnections.get(nodeId)
|
|
38
38
|
if (existingConnection) {
|
|
39
39
|
return existingConnection
|
|
@@ -65,7 +65,7 @@ export class SimulatorConnector {
|
|
|
65
65
|
public handleIncomingConnection(sourceConnection: SimulatorConnection): void {
|
|
66
66
|
// connection is incoming, so remotePeerDescriptor is localPeerDescriptor
|
|
67
67
|
const remotePeerDescriptor = sourceConnection.localPeerDescriptor
|
|
68
|
-
const remoteNodeId =
|
|
68
|
+
const remoteNodeId = toNodeId(sourceConnection.localPeerDescriptor)
|
|
69
69
|
logger.trace(remoteNodeId + ' incoming connection, stopped: ' + this.stopped)
|
|
70
70
|
if (this.stopped) {
|
|
71
71
|
return
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MetricsContext } from '@streamr/utils'
|
|
2
|
-
import { PeerDescriptor } from '
|
|
2
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
3
3
|
import { ConnectionManager } from '../ConnectionManager'
|
|
4
4
|
import { Simulator } from './Simulator'
|
|
5
5
|
import { SimulatorConnectorFacade } from '../ConnectorFacade'
|
|
@@ -8,7 +8,8 @@ export class SimulatorTransport extends ConnectionManager {
|
|
|
8
8
|
constructor(localPeerDescriptor: PeerDescriptor, simulator: Simulator) {
|
|
9
9
|
super({
|
|
10
10
|
createConnectorFacade: () => new SimulatorConnectorFacade(localPeerDescriptor, simulator),
|
|
11
|
-
metricsContext: new MetricsContext()
|
|
11
|
+
metricsContext: new MetricsContext(),
|
|
12
|
+
allowIncomingPrivateConnections: false
|
|
12
13
|
})
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -2,7 +2,7 @@ import EventEmitter from 'eventemitter3'
|
|
|
2
2
|
import { WebrtcConnectionEvents, IWebrtcConnection, RtcDescription } from './IWebrtcConnection'
|
|
3
3
|
import { IConnection, ConnectionID, ConnectionEvents, ConnectionType } from '../IConnection'
|
|
4
4
|
import { Logger } from '@streamr/utils'
|
|
5
|
-
import { IceServer } from './WebrtcConnector'
|
|
5
|
+
import { EARLY_TIMEOUT, IceServer } from './WebrtcConnector'
|
|
6
6
|
import { createRandomConnectionId } from '../Connection'
|
|
7
7
|
|
|
8
8
|
enum DisconnectedRtcPeerConnectionStateEnum {
|
|
@@ -32,11 +32,15 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IWebrt
|
|
|
32
32
|
private makingOffer = false
|
|
33
33
|
private isOffering = false
|
|
34
34
|
private closed = false
|
|
35
|
+
private earlyTimeout: NodeJS.Timeout
|
|
35
36
|
|
|
36
37
|
constructor(params: Params) {
|
|
37
38
|
super()
|
|
38
39
|
this.connectionId = createRandomConnectionId()
|
|
39
40
|
this.iceServers = params.iceServers ?? []
|
|
41
|
+
this.earlyTimeout = setTimeout(() => {
|
|
42
|
+
this.doClose(false, 'timed out due to remote descriptor not being set')
|
|
43
|
+
}, EARLY_TIMEOUT)
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
public start(isOffering: boolean): void {
|
|
@@ -55,6 +59,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IWebrt
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
this.peerConnection.onicegatheringstatechange = () => {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
58
63
|
logger.trace(`conn.onGatheringStateChange: ${this.peerConnection?.iceGatheringState}`)
|
|
59
64
|
}
|
|
60
65
|
|
|
@@ -95,6 +100,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IWebrt
|
|
|
95
100
|
}
|
|
96
101
|
try {
|
|
97
102
|
await this.peerConnection?.setRemoteDescription({ sdp: description, type: type.toLowerCase() as RTCSdpType })
|
|
103
|
+
clearTimeout(this.earlyTimeout)
|
|
98
104
|
} catch (err) {
|
|
99
105
|
logger.warn('Failed to set remote description', { err })
|
|
100
106
|
}
|
|
@@ -132,6 +138,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IWebrt
|
|
|
132
138
|
if (!this.closed) {
|
|
133
139
|
this.closed = true
|
|
134
140
|
this.lastState = 'closed'
|
|
141
|
+
clearTimeout(this.earlyTimeout)
|
|
135
142
|
|
|
136
143
|
this.stopListening()
|
|
137
144
|
this.emit('disconnected', gracefulLeave, undefined, reason)
|
|
@@ -175,6 +182,8 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IWebrt
|
|
|
175
182
|
|
|
176
183
|
private setupDataChannel(dataChannel: RTCDataChannel): void {
|
|
177
184
|
this.dataChannel = dataChannel
|
|
185
|
+
this.dataChannel.binaryType = 'arraybuffer'
|
|
186
|
+
|
|
178
187
|
dataChannel.onopen = () => {
|
|
179
188
|
logger.trace('dc.onOpen')
|
|
180
189
|
this.onDataChannelOpen()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IWebrtcConnection, WebrtcConnectionEvents } from './IWebrtcConnection'
|
|
2
2
|
import { ConnectionType, IConnection, ConnectionID, ConnectionEvents } from '../IConnection'
|
|
3
|
-
import { PeerDescriptor } from '
|
|
3
|
+
import { PeerDescriptor } from '../../../generated/packages/dht/protos/DhtRpc'
|
|
4
4
|
import EventEmitter from 'eventemitter3'
|
|
5
5
|
// TODO: why does eslint import rule plugin not work?
|
|
6
6
|
// eslint-disable-next-line import/no-unresolved
|
|
@@ -8,9 +8,9 @@ import { DataChannel, DescriptionType, PeerConnection, initLogger } from 'node-d
|
|
|
8
8
|
import { Logger } from '@streamr/utils'
|
|
9
9
|
import { IllegalRtcPeerConnectionState } from '../../helpers/errors'
|
|
10
10
|
import { iceServerAsString } from './iceServerAsString'
|
|
11
|
-
import { IceServer } from './WebrtcConnector'
|
|
11
|
+
import { IceServer, EARLY_TIMEOUT } from './WebrtcConnector'
|
|
12
12
|
import { PortRange } from '../ConnectionManager'
|
|
13
|
-
import {
|
|
13
|
+
import { toNodeId } from '../../identifiers'
|
|
14
14
|
import { createRandomConnectionId } from '../Connection'
|
|
15
15
|
|
|
16
16
|
const logger = new Logger(module)
|
|
@@ -58,6 +58,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
58
58
|
private readonly maxMessageSize?: number
|
|
59
59
|
private closed = false
|
|
60
60
|
private offering?: boolean
|
|
61
|
+
private readonly earlyTimeout: NodeJS.Timeout
|
|
61
62
|
|
|
62
63
|
constructor(params: Params) {
|
|
63
64
|
super()
|
|
@@ -69,10 +70,13 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
69
70
|
this.remotePeerDescriptor = params.remotePeerDescriptor
|
|
70
71
|
this.maxMessageSize = params.maxMessageSize ?? 1048576
|
|
71
72
|
this.portRange = params.portRange
|
|
73
|
+
this.earlyTimeout = setTimeout(() => {
|
|
74
|
+
this.doClose(false, 'timed out due to remote descriptor not being set')
|
|
75
|
+
}, EARLY_TIMEOUT)
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
public start(isOffering: boolean): void {
|
|
75
|
-
const nodeId =
|
|
79
|
+
const nodeId = toNodeId(this.remotePeerDescriptor)
|
|
76
80
|
this.offering = isOffering
|
|
77
81
|
logger.trace(`Starting new connection for peer ${nodeId}`, { isOffering })
|
|
78
82
|
this.connection = new PeerConnection(nodeId, {
|
|
@@ -101,7 +105,8 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
101
105
|
|
|
102
106
|
public async setRemoteDescription(description: string, type: string): Promise<void> {
|
|
103
107
|
if (this.connection) {
|
|
104
|
-
|
|
108
|
+
clearTimeout(this.earlyTimeout)
|
|
109
|
+
const remoteNodeId = toNodeId(this.remotePeerDescriptor)
|
|
105
110
|
try {
|
|
106
111
|
logger.trace(`Setting remote descriptor for peer: ${remoteNodeId}`)
|
|
107
112
|
this.connection.setRemoteDescription(description, type as DescriptionType)
|
|
@@ -117,7 +122,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
117
122
|
public addRemoteCandidate(candidate: string, mid: string): void {
|
|
118
123
|
if (this.connection) {
|
|
119
124
|
if (this.remoteDescriptionSet) {
|
|
120
|
-
const remoteNodeId =
|
|
125
|
+
const remoteNodeId = toNodeId(this.remotePeerDescriptor)
|
|
121
126
|
try {
|
|
122
127
|
logger.trace(`Setting remote candidate for peer: ${remoteNodeId}`)
|
|
123
128
|
this.connection.addRemoteCandidate(candidate, mid)
|
|
@@ -138,7 +143,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
138
143
|
try {
|
|
139
144
|
this.dataChannel!.sendMessageBinary(data as Buffer)
|
|
140
145
|
} catch (err) {
|
|
141
|
-
const remoteNodeId =
|
|
146
|
+
const remoteNodeId = toNodeId(this.remotePeerDescriptor)
|
|
142
147
|
logger.debug('Failed to send binary message to ' + remoteNodeId + err)
|
|
143
148
|
}
|
|
144
149
|
}
|
|
@@ -150,7 +155,8 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
150
155
|
|
|
151
156
|
private doClose(gracefulLeave: boolean, reason?: string): void {
|
|
152
157
|
if (!this.closed) {
|
|
153
|
-
|
|
158
|
+
clearTimeout(this.earlyTimeout)
|
|
159
|
+
const remoteNodeId = toNodeId(this.remotePeerDescriptor)
|
|
154
160
|
logger.trace(`Closing Node WebRTC Connection to ${remoteNodeId}` + `${(reason !== undefined) ? `, reason: ${reason}` : ''}`)
|
|
155
161
|
|
|
156
162
|
this.closed = true
|
|
@@ -210,7 +216,7 @@ export class NodeWebrtcConnection extends EventEmitter<Events> implements IConne
|
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
private onDataChannelOpen(): void {
|
|
213
|
-
logger.trace(`DataChannel opened for peer ${
|
|
219
|
+
logger.trace(`DataChannel opened for peer ${toNodeId(this.remotePeerDescriptor)}`)
|
|
214
220
|
this.emit('connected')
|
|
215
221
|
}
|
|
216
222
|
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
PeerDescriptor,
|
|
5
5
|
RtcAnswer,
|
|
6
6
|
RtcOffer, WebrtcConnectionRequest
|
|
7
|
-
} from '
|
|
7
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
8
8
|
import { ITransport } from '../../transport/ITransport'
|
|
9
9
|
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator'
|
|
10
10
|
import { NodeWebrtcConnection } from './NodeWebrtcConnection'
|
|
11
11
|
import { WebrtcConnectorRpcRemote } from './WebrtcConnectorRpcRemote'
|
|
12
|
-
import { WebrtcConnectorRpcClient } from '
|
|
12
|
+
import { WebrtcConnectorRpcClient } from '../../../generated/packages/dht/protos/DhtRpc.client'
|
|
13
13
|
import { Logger } from '@streamr/utils'
|
|
14
14
|
import * as Err from '../../helpers/errors'
|
|
15
15
|
import { PortRange } from '../ConnectionManager'
|
|
16
16
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
17
17
|
import { WebrtcConnectorRpcLocal } from './WebrtcConnectorRpcLocal'
|
|
18
|
-
import { DhtAddress, areEqualPeerDescriptors,
|
|
18
|
+
import { DhtAddress, areEqualPeerDescriptors, toNodeId } from '../../identifiers'
|
|
19
19
|
import { getOfferer } from '../../helpers/offering'
|
|
20
20
|
import { acceptHandshake, createIncomingHandshaker, createOutgoingHandshaker, rejectHandshake } from '../Handshaker'
|
|
21
21
|
import { isMaybeSupportedVersion } from '../../helpers/version'
|
|
@@ -32,6 +32,8 @@ export const replaceInternalIpWithExternalIp = (candidate: string, ip: string):
|
|
|
32
32
|
return parsed.join(' ')
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export const EARLY_TIMEOUT = 5000
|
|
36
|
+
|
|
35
37
|
export interface WebrtcConnectorOptions {
|
|
36
38
|
onNewConnection: (connection: PendingConnection) => boolean
|
|
37
39
|
transport: ITransport
|
|
@@ -127,9 +129,9 @@ export class WebrtcConnector {
|
|
|
127
129
|
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self')
|
|
128
130
|
}
|
|
129
131
|
|
|
130
|
-
logger.trace(`Opening WebRTC connection to ${
|
|
132
|
+
logger.trace(`Opening WebRTC connection to ${toNodeId(targetPeerDescriptor)}`)
|
|
131
133
|
|
|
132
|
-
const nodeId =
|
|
134
|
+
const nodeId = toNodeId(targetPeerDescriptor)
|
|
133
135
|
const existingConnection = this.ongoingConnectAttempts.get(nodeId)
|
|
134
136
|
if (existingConnection) {
|
|
135
137
|
return existingConnection.managedConnection
|
|
@@ -137,8 +139,8 @@ export class WebrtcConnector {
|
|
|
137
139
|
|
|
138
140
|
const connection = this.createConnection(targetPeerDescriptor)
|
|
139
141
|
|
|
140
|
-
const localNodeId =
|
|
141
|
-
const targetNodeId =
|
|
142
|
+
const localNodeId = toNodeId(this.localPeerDescriptor!)
|
|
143
|
+
const targetNodeId = toNodeId(targetPeerDescriptor)
|
|
142
144
|
const offering = (getOfferer(localNodeId, targetNodeId) === 'local')
|
|
143
145
|
let pendingConnection: PendingConnection
|
|
144
146
|
const remoteConnector = new WebrtcConnectorRpcRemote(
|
|
@@ -224,7 +226,7 @@ export class WebrtcConnector {
|
|
|
224
226
|
const attempts = Array.from(this.ongoingConnectAttempts.values())
|
|
225
227
|
await Promise.allSettled(attempts.map(async (conn) => {
|
|
226
228
|
conn.connection.destroy()
|
|
227
|
-
|
|
229
|
+
conn.managedConnection.close(false)
|
|
228
230
|
}))
|
|
229
231
|
|
|
230
232
|
this.rpcCommunicator.destroy()
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
2
|
import { Logger } from '@streamr/utils'
|
|
3
3
|
import { getAddressFromIceCandidate, isPrivateIPv4 } from '../../helpers/AddressTools'
|
|
4
|
-
import { Empty } from '
|
|
4
|
+
import { Empty } from '../../../generated/google/protobuf/empty'
|
|
5
5
|
import {
|
|
6
6
|
IceCandidate,
|
|
7
7
|
PeerDescriptor,
|
|
8
8
|
RtcAnswer,
|
|
9
9
|
RtcOffer
|
|
10
|
-
} from '
|
|
11
|
-
import { IWebrtcConnectorRpc } from '
|
|
10
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
11
|
+
import { IWebrtcConnectorRpc } from '../../../generated/packages/dht/protos/DhtRpc.server'
|
|
12
12
|
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
13
13
|
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator'
|
|
14
14
|
import { NodeWebrtcConnection } from './NodeWebrtcConnection'
|
|
15
|
-
import { DhtAddress,
|
|
15
|
+
import { DhtAddress, toNodeId } from '../../identifiers'
|
|
16
16
|
import { ConnectionID } from '../IConnection'
|
|
17
17
|
import { ConnectingConnection } from './WebrtcConnector'
|
|
18
18
|
import { PendingConnection } from '../PendingConnection'
|
|
@@ -39,7 +39,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
|
39
39
|
|
|
40
40
|
async requestConnection(context: ServerCallContext): Promise<Empty> {
|
|
41
41
|
const targetPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
42
|
-
if (this.options.ongoingConnectAttempts.has(
|
|
42
|
+
if (this.options.ongoingConnectAttempts.has(toNodeId(targetPeerDescriptor))) {
|
|
43
43
|
return {}
|
|
44
44
|
}
|
|
45
45
|
const pendingConnection = this.options.connect(targetPeerDescriptor, false)
|
|
@@ -49,7 +49,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
|
49
49
|
|
|
50
50
|
async rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty> {
|
|
51
51
|
const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
52
|
-
const nodeId =
|
|
52
|
+
const nodeId = toNodeId(remotePeerDescriptor)
|
|
53
53
|
let connection: NodeWebrtcConnection
|
|
54
54
|
let pendingConnection: PendingConnection
|
|
55
55
|
|
|
@@ -69,7 +69,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
|
69
69
|
|
|
70
70
|
async rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty> {
|
|
71
71
|
const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
72
|
-
const nodeId =
|
|
72
|
+
const nodeId = toNodeId(remotePeerDescriptor)
|
|
73
73
|
const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection
|
|
74
74
|
if (!connection) {
|
|
75
75
|
return {}
|
|
@@ -83,7 +83,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
|
83
83
|
|
|
84
84
|
async iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty> {
|
|
85
85
|
const remotePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
86
|
-
const nodeId =
|
|
86
|
+
const nodeId = toNodeId(remotePeerDescriptor)
|
|
87
87
|
const connection = this.options.ongoingConnectAttempts.get(nodeId)?.connection
|
|
88
88
|
if (!connection) {
|
|
89
89
|
return {}
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
RtcAnswer,
|
|
6
6
|
RtcOffer,
|
|
7
7
|
WebrtcConnectionRequest
|
|
8
|
-
} from '
|
|
9
|
-
import { WebrtcConnectorRpcClient } from '
|
|
8
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
9
|
+
import { WebrtcConnectorRpcClient } from '../../../generated/packages/dht/protos/DhtRpc.client'
|
|
10
10
|
|
|
11
11
|
const logger = new Logger(module)
|
|
12
12
|
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
ConnectivityMethod,
|
|
7
7
|
PeerDescriptor,
|
|
8
8
|
WebsocketConnectionRequest
|
|
9
|
-
} from '
|
|
9
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
10
10
|
import { WebsocketServer } from './WebsocketServer'
|
|
11
11
|
import { createOutgoingHandshaker } from '../Handshaker'
|
|
12
12
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
13
13
|
import { expectedConnectionType } from '../../helpers/Connectivity'
|
|
14
|
-
import { Empty } from '
|
|
15
|
-
import { DhtAddress,
|
|
14
|
+
import { Empty } from '../../../generated/google/protobuf/empty'
|
|
15
|
+
import { DhtAddress, toNodeId } from '../../identifiers'
|
|
16
16
|
import { GeoIpLocator } from '@streamr/geoip-location'
|
|
17
17
|
import { PendingConnection } from '../PendingConnection'
|
|
18
18
|
|
|
@@ -73,7 +73,7 @@ export class WebsocketClientConnector {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
public connect(targetPeerDescriptor: PeerDescriptor): PendingConnection {
|
|
76
|
-
const nodeId =
|
|
76
|
+
const nodeId = toNodeId(targetPeerDescriptor)
|
|
77
77
|
const existingConnection = this.connectingConnections.get(nodeId)
|
|
78
78
|
if (existingConnection) {
|
|
79
79
|
return existingConnection
|
|
@@ -114,6 +114,6 @@ export class WebsocketClientConnector {
|
|
|
114
114
|
await Promise.allSettled(requests.map((conn) => conn.close(true)))
|
|
115
115
|
|
|
116
116
|
await this.websocketServer?.stop()
|
|
117
|
-
|
|
117
|
+
this.geoIpLocator?.stop()
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -2,11 +2,11 @@ import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
|
2
2
|
import {
|
|
3
3
|
PeerDescriptor,
|
|
4
4
|
WebsocketConnectionRequest
|
|
5
|
-
} from '
|
|
6
|
-
import { IWebsocketClientConnectorRpc } from '
|
|
5
|
+
} from '../../../generated/packages/dht/protos/DhtRpc'
|
|
6
|
+
import { IWebsocketClientConnectorRpc } from '../../../generated/packages/dht/protos/DhtRpc.server'
|
|
7
7
|
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
8
|
-
import { Empty } from '
|
|
9
|
-
import {
|
|
8
|
+
import { Empty } from '../../../generated/google/protobuf/empty'
|
|
9
|
+
import { toNodeId, DhtAddress } from '../../identifiers'
|
|
10
10
|
import { PendingConnection } from '../PendingConnection'
|
|
11
11
|
|
|
12
12
|
interface WebsocketClientConnectorRpcLocalOptions {
|
|
@@ -29,7 +29,7 @@ export class WebsocketClientConnectorRpcLocal implements IWebsocketClientConnect
|
|
|
29
29
|
return {}
|
|
30
30
|
}
|
|
31
31
|
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
32
|
-
if (!this.options.hasConnection(
|
|
32
|
+
if (!this.options.hasConnection(toNodeId(senderPeerDescriptor))) {
|
|
33
33
|
const connection = this.options.connect(senderPeerDescriptor)
|
|
34
34
|
this.options.onNewConnection(connection)
|
|
35
35
|
}
|