@streamr/dht 100.0.0-testnet-one.4 → 100.0.0-testnet-two.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/dist/src/connection/ConnectionLockHandler.d.ts +11 -11
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +4 -4
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +3 -5
- package/dist/src/connection/ConnectionLockRpcRemote.js +4 -7
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +4 -6
- package/dist/src/connection/ConnectionManager.js +48 -46
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +2 -2
- package/dist/src/connection/ConnectorFacade.js +2 -1
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +3 -6
- package/dist/src/connection/ManagedConnection.js +6 -10
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.js +1 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +0 -3
- package/dist/src/connection/simulator/Simulator.js +3 -51
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +5 -5
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +2 -2
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +0 -1
- package/dist/src/connection/webrtc/WebrtcConnector.js +7 -9
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +11 -12
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +2 -5
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +1 -4
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +3 -4
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +2 -7
- package/dist/src/connection/websocket/WebsocketConnector.js +32 -38
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +3 -2
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +8 -10
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +3 -6
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +0 -3
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketServer.d.ts +1 -4
- package/dist/src/connection/websocket/WebsocketServer.js +11 -12
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +10 -13
- package/dist/src/dht/DhtNode.js +39 -52
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +0 -1
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +7 -7
- package/dist/src/dht/DhtNodeRpcRemote.js +8 -7
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +5 -4
- package/dist/src/dht/ExternalApiRpcLocal.js +3 -2
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -0
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +13 -14
- package/dist/src/dht/PeerManager.js +45 -60
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/Contact.d.ts +2 -2
- package/dist/src/dht/contact/Contact.js +2 -2
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +7 -7
- package/dist/src/dht/contact/ContactList.js +3 -3
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +4 -4
- package/dist/src/dht/contact/RandomContactList.js +12 -11
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RpcRemote.d.ts +7 -4
- package/dist/src/dht/contact/RpcRemote.js +5 -2
- package/dist/src/dht/contact/RpcRemote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +13 -13
- package/dist/src/dht/contact/SortedContactList.js +33 -29
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +2 -4
- package/dist/src/dht/discovery/DiscoverySession.js +19 -20
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +2 -5
- package/dist/src/dht/discovery/PeerDiscovery.js +12 -20
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +165 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +14 -0
- package/dist/src/dht/{find/FindRpcLocal.js → recursive-operation/RecursiveOperationRpcLocal.js} +7 -7
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.d.ts +6 -0
- package/dist/src/dht/{routing/FindRpcRemote.js → recursive-operation/RecursiveOperationRpcRemote.js} +11 -11
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +42 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +182 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +17 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.d.ts +6 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js +21 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +4 -19
- package/dist/src/dht/routing/Router.js +41 -33
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.js +6 -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 +20 -16
- package/dist/src/dht/routing/RoutingSession.js +37 -45
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +11 -13
- package/dist/src/dht/store/LocalDataStore.js +36 -56
- package/dist/src/dht/store/LocalDataStore.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +33 -0
- package/dist/src/dht/store/StoreManager.js +186 -0
- package/dist/src/dht/store/StoreManager.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +8 -40
- package/dist/src/dht/store/StoreRpcLocal.js +13 -229
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +5 -5
- package/dist/src/dht/store/StoreRpcRemote.js +4 -5
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +2 -0
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.d.ts +14 -0
- package/dist/src/helpers/MapWithTtl.js +59 -0
- package/dist/src/helpers/MapWithTtl.js.map +1 -0
- package/dist/src/helpers/PeerID.d.ts +2 -0
- package/dist/src/helpers/PeerID.js +4 -0
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/nodeId.d.ts +5 -0
- package/dist/src/helpers/nodeId.js +18 -1
- package/dist/src/helpers/nodeId.js.map +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +2 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +2 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +2 -3
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +21 -22
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +18 -18
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +36 -60
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +34 -53
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +11 -12
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -1
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/rpc-protocol/DhtRpcOptions.d.ts +2 -1
- package/dist/src/transport/ITransport.d.ts +9 -1
- package/dist/src/transport/ITransport.js +5 -0
- package/dist/src/transport/ITransport.js.map +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +16 -11
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/jest.config.js +4 -1
- package/karma-setup.js +2 -0
- package/karma.config.js +11 -7
- package/package.json +6 -7
- package/protos/DhtRpc.proto +17 -23
- package/src/connection/ConnectionLockHandler.ts +15 -15
- package/src/connection/ConnectionLockRpcLocal.ts +8 -9
- package/src/connection/ConnectionLockRpcRemote.ts +7 -16
- package/src/connection/ConnectionManager.ts +58 -55
- package/src/connection/ConnectorFacade.ts +3 -0
- package/src/connection/ManagedConnection.ts +12 -30
- package/src/connection/connectivityChecker.ts +1 -0
- package/src/connection/simulator/Simulator.ts +5 -36
- package/src/connection/simulator/SimulatorConnector.ts +8 -8
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -3
- package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -4
- package/src/connection/webrtc/WebrtcConnector.ts +11 -13
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +16 -16
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +3 -13
- package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
- package/src/connection/websocket/ClientWebsocket.ts +1 -0
- package/src/connection/websocket/WebsocketConnector.ts +43 -56
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +11 -13
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +4 -15
- package/src/connection/websocket/WebsocketServer.ts +14 -17
- package/src/dht/DhtNode.ts +67 -69
- package/src/dht/DhtNodeRpcLocal.ts +0 -1
- package/src/dht/DhtNodeRpcRemote.ts +13 -13
- package/src/dht/ExternalApiRpcLocal.ts +16 -6
- package/src/dht/ExternalApiRpcRemote.ts +5 -3
- package/src/dht/PeerManager.ts +73 -90
- package/src/dht/contact/Contact.ts +5 -4
- package/src/dht/contact/ContactList.ts +9 -9
- package/src/dht/contact/RandomContactList.ts +14 -14
- package/src/dht/contact/RpcRemote.ts +10 -7
- package/src/dht/contact/SortedContactList.ts +48 -45
- package/src/dht/discovery/DiscoverySession.ts +25 -25
- package/src/dht/discovery/PeerDiscovery.ts +16 -37
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +240 -0
- package/src/dht/{find/FindRpcLocal.ts → recursive-operation/RecursiveOperationRpcLocal.ts} +9 -9
- package/src/dht/{routing/FindRpcRemote.ts → recursive-operation/RecursiveOperationRpcRemote.ts} +10 -10
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +224 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +25 -0
- package/src/dht/{find/FindSessionRpcRemote.ts → recursive-operation/RecursiveOperationSessionRpcRemote.ts} +8 -8
- package/src/dht/routing/Router.ts +45 -64
- package/src/dht/routing/RouterRpcLocal.ts +7 -6
- package/src/dht/routing/RouterRpcRemote.ts +9 -10
- package/src/dht/routing/RoutingSession.ts +59 -68
- package/src/dht/store/LocalDataStore.ts +47 -66
- package/src/dht/store/StoreManager.ts +217 -0
- package/src/dht/store/StoreRpcLocal.ts +26 -302
- package/src/dht/store/StoreRpcRemote.ts +9 -11
- package/src/exports.ts +2 -0
- package/src/helpers/MapWithTtl.ts +71 -0
- package/src/helpers/PeerID.ts +5 -0
- package/src/helpers/nodeId.ts +20 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +5 -3
- package/src/helpers/protoClasses.ts +4 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +31 -32
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +11 -12
- package/src/proto/packages/dht/protos/DhtRpc.ts +49 -80
- package/src/rpc-protocol/DhtCallContext.ts +2 -1
- package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
- package/src/transport/ITransport.ts +10 -1
- package/src/transport/ListeningRpcCommunicator.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +18 -12
- package/test/benchmark/Find.test.ts +8 -21
- package/test/benchmark/KademliaCorrectness.test.ts +11 -20
- package/test/benchmark/SortedContactListBenchmark.test.ts +9 -9
- package/test/benchmark/kademlia-simulation/Contact.ts +9 -8
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +2 -2
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +17 -17
- package/test/end-to-end/Layer0-Layer1.test.ts +10 -14
- package/test/end-to-end/Layer0.test.ts +15 -18
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +7 -9
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +4 -10
- package/test/end-to-end/Layer0Webrtc.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -16
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +6 -13
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +5 -6
- package/test/end-to-end/memory-leak.test.ts +6 -8
- package/test/integration/ConnectionLocking.test.ts +6 -13
- package/test/integration/ConnectionManager.test.ts +26 -43
- package/test/integration/DhtJoinPeerDiscovery.test.ts +5 -10
- package/test/integration/DhtNodeExternalAPI.test.ts +16 -22
- package/test/integration/DhtNodeRpcRemote.test.ts +13 -22
- package/test/integration/DhtRpc.test.ts +13 -18
- package/test/integration/Find.test.ts +10 -10
- package/test/integration/Layer1-scale.test.ts +17 -28
- package/test/integration/Mock-Layer1-Layer0.test.ts +25 -43
- package/test/integration/MultipleEntryPointJoining.test.ts +7 -7
- package/test/integration/ReplicateData.test.ts +28 -30
- package/test/integration/RouteMessage.test.ts +30 -27
- package/test/integration/RouterRpcRemote.test.ts +12 -18
- package/test/integration/RpcErrors.test.ts +8 -21
- package/test/integration/ScaleDownDht.test.ts +11 -10
- package/test/integration/SimultaneousConnections.test.ts +43 -67
- package/test/integration/Store.test.ts +23 -36
- package/test/integration/StoreAndDelete.test.ts +30 -50
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +16 -37
- package/test/integration/StoreRpcRemote.test.ts +20 -30
- package/test/integration/WebrtcConnectionManagement.test.ts +3 -13
- package/test/integration/WebrtcConnectorRpc.test.ts +3 -9
- package/test/integration/WebsocketConnectionManagement.test.ts +7 -10
- package/test/integration/WebsocketConnectorRpc.test.ts +8 -17
- package/test/unit/ConnectivityHelpers.test.ts +9 -17
- package/test/unit/DuplicateDetector.test.ts +7 -4
- package/test/unit/LocalDataStore.test.ts +66 -77
- package/test/unit/PeerManager.test.ts +31 -0
- package/test/unit/RandomContactList.test.ts +13 -8
- package/test/unit/{Finder.test.ts → RecursiveOperationManager.test.ts} +38 -43
- package/test/unit/RecursiveOperationSession.test.ts +68 -0
- package/test/unit/Router.test.ts +15 -22
- package/test/unit/RoutingSession.test.ts +23 -25
- package/test/unit/SortedContactList.test.ts +41 -26
- package/test/unit/StoreManager.test.ts +132 -0
- package/test/unit/WebsocketConnector.test.ts +27 -35
- package/test/unit/customMatchers.test.ts +16 -0
- package/test/utils/FakeTransport.ts +44 -0
- package/test/utils/customMatchers.ts +70 -0
- package/test/utils/mock/MockRpcCommunicator.ts +7 -0
- package/test/utils/mock/Router.ts +3 -2
- package/test/utils/mock/mockDataEntry.ts +36 -0
- package/test/utils/utils.ts +49 -87
- package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
- package/dist/src/dht/find/FindRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSession.d.ts +0 -44
- package/dist/src/dht/find/FindSession.js +0 -150
- package/dist/src/dht/find/FindSession.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +0 -12
- package/dist/src/dht/find/FindSessionRpcLocal.js +0 -17
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +0 -1
- package/dist/src/dht/find/FindSessionRpcRemote.d.ts +0 -6
- package/dist/src/dht/find/FindSessionRpcRemote.js +0 -21
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +0 -1
- package/dist/src/dht/find/Finder.d.ts +0 -49
- package/dist/src/dht/find/Finder.js +0 -197
- package/dist/src/dht/find/Finder.js.map +0 -1
- package/dist/src/dht/routing/FindRpcRemote.d.ts +0 -6
- package/dist/src/dht/routing/FindRpcRemote.js.map +0 -1
- package/src/dht/find/FindSession.ts +0 -183
- package/src/dht/find/FindSessionRpcLocal.ts +0 -25
- package/src/dht/find/Finder.ts +0 -295
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebrtcConnectorRpcLocal = void 0;
|
|
4
|
-
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
5
4
|
const utils_1 = require("@streamr/utils");
|
|
6
5
|
const AddressTools_1 = require("../../helpers/AddressTools");
|
|
7
6
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
@@ -16,7 +15,7 @@ class WebrtcConnectorRpcLocal {
|
|
|
16
15
|
}
|
|
17
16
|
async requestConnection(context) {
|
|
18
17
|
const targetPeerDescriptor = context.incomingSourceDescriptor;
|
|
19
|
-
if (this.config.ongoingConnectAttempts.has((0, peerIdFromPeerDescriptor_1.
|
|
18
|
+
if (this.config.ongoingConnectAttempts.has((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor))) {
|
|
20
19
|
return {};
|
|
21
20
|
}
|
|
22
21
|
const managedConnection = this.config.connect(targetPeerDescriptor);
|
|
@@ -26,16 +25,16 @@ class WebrtcConnectorRpcLocal {
|
|
|
26
25
|
}
|
|
27
26
|
async rtcOffer(request, context) {
|
|
28
27
|
const remotePeer = context.incomingSourceDescriptor;
|
|
29
|
-
const
|
|
30
|
-
let managedConnection = this.config.ongoingConnectAttempts.get(
|
|
28
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(remotePeer);
|
|
29
|
+
let managedConnection = this.config.ongoingConnectAttempts.get(nodeId);
|
|
31
30
|
let connection = managedConnection?.getWebrtcConnection();
|
|
32
31
|
if (!managedConnection) {
|
|
33
32
|
connection = new NodeWebrtcConnection_1.NodeWebrtcConnection({ remotePeerDescriptor: remotePeer });
|
|
34
33
|
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection);
|
|
35
34
|
managedConnection.setRemotePeerDescriptor(remotePeer);
|
|
36
|
-
this.config.ongoingConnectAttempts.set(
|
|
35
|
+
this.config.ongoingConnectAttempts.set(nodeId, managedConnection);
|
|
37
36
|
this.config.onNewConnection(managedConnection);
|
|
38
|
-
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.config.getLocalPeerDescriptor(), remotePeer,
|
|
37
|
+
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.config.getLocalPeerDescriptor(), remotePeer, 'DUMMY', this.config.rpcCommunicator, DhtRpc_client_1.WebrtcConnectorRpcClient);
|
|
39
38
|
connection.on('localCandidate', (candidate, mid) => {
|
|
40
39
|
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString());
|
|
41
40
|
});
|
|
@@ -48,8 +47,8 @@ class WebrtcConnectorRpcLocal {
|
|
|
48
47
|
connection.setConnectionId(request.connectionId);
|
|
49
48
|
connection.setRemoteDescription(request.description, 'offer');
|
|
50
49
|
managedConnection.on('handshakeRequest', () => {
|
|
51
|
-
if (this.config.ongoingConnectAttempts.has(
|
|
52
|
-
this.config.ongoingConnectAttempts.delete(
|
|
50
|
+
if (this.config.ongoingConnectAttempts.has(nodeId)) {
|
|
51
|
+
this.config.ongoingConnectAttempts.delete(nodeId);
|
|
53
52
|
}
|
|
54
53
|
managedConnection.acceptHandshake();
|
|
55
54
|
});
|
|
@@ -57,8 +56,8 @@ class WebrtcConnectorRpcLocal {
|
|
|
57
56
|
}
|
|
58
57
|
async rtcAnswer(request, context) {
|
|
59
58
|
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
60
|
-
const
|
|
61
|
-
const connection = this.config.ongoingConnectAttempts.get(
|
|
59
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(remotePeerDescriptor);
|
|
60
|
+
const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection();
|
|
62
61
|
if (!connection) {
|
|
63
62
|
return {};
|
|
64
63
|
}
|
|
@@ -71,8 +70,8 @@ class WebrtcConnectorRpcLocal {
|
|
|
71
70
|
}
|
|
72
71
|
async iceCandidate(request, context) {
|
|
73
72
|
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
74
|
-
const
|
|
75
|
-
const connection = this.config.ongoingConnectAttempts.get(
|
|
73
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(remotePeerDescriptor);
|
|
74
|
+
const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection();
|
|
76
75
|
if (!connection) {
|
|
77
76
|
return {};
|
|
78
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,6DAAsF;AACtF,qFAAoF;AAQpF,iFAAwF;AAKxF,wEAAoE;AACpE,iEAA6D;AAC7D,yEAAqE;AAGrE,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;A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AAO,EAAE,CAAA;IACb,CAAC;IAEO,qBAAqB,CAAC,SAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACpC,MAAM,OAAO,GAAG,IAAA,yCAA0B,EAAC,SAAS,CAAC,CAAA;YACrD,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,IAAI,IAAA,4BAAa,EAAC,OAAO,CAAC,EAAE;gBACnD,OAAO,KAAK,CAAA;aACf;SACJ;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAlGD,0DAkGC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { RpcRemote } from '../../dht/contact/RpcRemote';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
5
|
-
export declare class WebrtcConnectorRpcRemote extends RpcRemote<IWebrtcConnectorRpcClient> {
|
|
6
|
-
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebrtcConnectorRpcClient>);
|
|
2
|
+
import { WebrtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
+
export declare class WebrtcConnectorRpcRemote extends RpcRemote<WebrtcConnectorRpcClient> {
|
|
7
4
|
requestConnection(): void;
|
|
8
5
|
sendRtcOffer(description: string, connectionId: string): void;
|
|
9
6
|
sendRtcAnswer(description: string, connectionId: string): void;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebrtcConnectorRpcRemote = void 0;
|
|
4
|
-
const RpcRemote_1 = require("../../dht/contact/RpcRemote");
|
|
5
4
|
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const RpcRemote_1 = require("../../dht/contact/RpcRemote");
|
|
6
6
|
const logger = new utils_1.Logger(module);
|
|
7
7
|
class WebrtcConnectorRpcRemote extends RpcRemote_1.RpcRemote {
|
|
8
|
-
constructor(localPeerDescriptor, remotePeerDescriptor, client) {
|
|
9
|
-
super(localPeerDescriptor, remotePeerDescriptor, 'DUMMY', client);
|
|
10
|
-
}
|
|
11
8
|
requestConnection() {
|
|
12
9
|
const request = {};
|
|
13
10
|
const options = this.formDhtRpcOptions({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"WebrtcConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAAA,0CAAuC;AACvC,2DAAuD;AASvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,wBAAyB,SAAQ,qBAAmC;IAE7E,iBAAiB;QACb,MAAM,OAAO,GAA4B,EACxC,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnC,YAAY,EAAE,IAAI;SACrB,CAAC,CAAA;QACF,IAAI,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YAC9D,MAAM,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;IACN,CAAC;IAED,YAAY,CAAC,WAAmB,EAAE,YAAoB;QAClD,MAAM,OAAO,GAAa;YACtB,YAAY;YACZ,WAAW;SACd,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACrD,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACN,CAAC;IAED,aAAa,CAAC,WAAmB,EAAE,YAAoB;QACnD,MAAM,OAAO,GAAc;YACvB,YAAY;YACZ,WAAW;SACd,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACtD,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACN,CAAC;IAED,gBAAgB,CAAC,SAAiB,EAAE,GAAW,EAAE,YAAoB;QACjE,MAAM,OAAO,GAAiB;YAC1B,YAAY;YACZ,GAAG;YACH,SAAS;SACZ,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACzD,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AA9CD,4DA8CC"}
|
|
@@ -17,8 +17,7 @@ interface AutoCertifierClientFacadeConfig {
|
|
|
17
17
|
export declare class AutoCertifierClientFacade {
|
|
18
18
|
private autoCertifierClient;
|
|
19
19
|
private readonly rpcCommunicator;
|
|
20
|
-
private readonly
|
|
21
|
-
private readonly updateCertificate;
|
|
20
|
+
private readonly config;
|
|
22
21
|
constructor(config: AutoCertifierClientFacadeConfig);
|
|
23
22
|
start(): Promise<void>;
|
|
24
23
|
stop(): void;
|
|
@@ -11,16 +11,15 @@ const defaultAutoCertifierClientFactory = (configFile, autoCertifierUrl, autoCer
|
|
|
11
11
|
const logger = new utils_1.Logger(module);
|
|
12
12
|
class AutoCertifierClientFacade {
|
|
13
13
|
constructor(config) {
|
|
14
|
-
this.
|
|
15
|
-
this.updateCertificate = config.updateCertificate;
|
|
14
|
+
this.config = config;
|
|
16
15
|
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(autocertifier_client_1.SERVICE_ID, config.transport);
|
|
17
16
|
this.autoCertifierClient = config.createClientFactory ? config.createClientFactory()
|
|
18
17
|
: defaultAutoCertifierClientFactory(config.configFile, config.url, this.rpcCommunicator, config.wsServerPort);
|
|
19
18
|
}
|
|
20
19
|
async start() {
|
|
21
20
|
this.autoCertifierClient.on('updatedCertificate', (subdomain) => {
|
|
22
|
-
this.setHost(subdomain.fqdn);
|
|
23
|
-
this.updateCertificate(subdomain.certificate, subdomain.privateKey);
|
|
21
|
+
this.config.setHost(subdomain.fqdn);
|
|
22
|
+
this.config.updateCertificate(subdomain.certificate, subdomain.privateKey);
|
|
24
23
|
logger.trace(`Updated certificate`);
|
|
25
24
|
});
|
|
26
25
|
await Promise.all([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCertifierClientFacade.js","sourceRoot":"","sources":["../../../../src/connection/websocket/AutoCertifierClientFacade.ts"],"names":[],"mappings":";;;AAAA,wEAOsC;AACtC,uFAAmF;AACnF,0CAAsD;AAGtD,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAA;AAE/B,MAAM,iCAAiC,GAAG,CACtC,UAAkB,EAClB,gBAAwB,EACxB,4BAAsD,EACtD,YAAoB,EACtB,EAAE,CAAC,IAAI,0CAAmB,CACxB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,CAAC,UAAkB,EAAE,aAAqB,EAAE,MAAkB,EAAE,EAAE;IAC9D,4BAA4B,CAAC,iBAAiB,CAC1C,wCAAiB,EACjB,yCAAkB,EAClB,aAAa,EACb,MAAM,CACT,CAAA;AACL,CAAC,CACJ,CAAA;AAoBD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,yBAAyB;
|
|
1
|
+
{"version":3,"file":"AutoCertifierClientFacade.js","sourceRoot":"","sources":["../../../../src/connection/websocket/AutoCertifierClientFacade.ts"],"names":[],"mappings":";;;AAAA,wEAOsC;AACtC,uFAAmF;AACnF,0CAAsD;AAGtD,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAA;AAE/B,MAAM,iCAAiC,GAAG,CACtC,UAAkB,EAClB,gBAAwB,EACxB,4BAAsD,EACtD,YAAoB,EACtB,EAAE,CAAC,IAAI,0CAAmB,CACxB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,CAAC,UAAkB,EAAE,aAAqB,EAAE,MAAkB,EAAE,EAAE;IAC9D,4BAA4B,CAAC,iBAAiB,CAC1C,wCAAiB,EACjB,yCAAkB,EAClB,aAAa,EACb,MAAM,CACT,CAAA;AACL,CAAC,CACJ,CAAA;AAoBD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,yBAAyB;IAMlC,YAAY,MAAuC;QAC/C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,eAAe,GAAG,IAAI,mDAAwB,CAAC,iCAAyB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;QAChG,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE;YAChF,CAAC,CAAC,iCAAiC,CAC/B,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,GAAG,EACV,IAAI,CAAC,eAAe,EACpB,MAAM,CAAC,YAAY,CACtB,CAAA;IACT,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,SAA6B,EAAE,EAAE;YAChF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YACnC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;YAC1E,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,GAAG,CAAC;YACd,IAAA,qBAAa,EAAC,IAAI,CAAC,mBAA0B,EAAE,oBAAoB,EAAE,aAAa,CAAC;YACnF,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE;SACnC,CAAC,CAAA;IACN,CAAC;IAED,IAAI;QACA,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;CAEJ;AAnCD,8DAmCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ClientWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AACvC,kEAAwC;AACxC,yCAAiF;AACjF,gDAA4F;AAE5F,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,mGAAmG;AACnG,sDAAsD;AACzC,QAAA,UAAU,GAAG,IAAI,CAAA;AAC9B,+FAA+F;AAC/F,+BAA+B;AAClB,QAAA,iBAAiB,GAAG,IAAI,CAAA;AAErC,MAAM,WAAW,GAAG,aAAa,CAAA;AAEjC,MAAa,eAAgB,SAAQ,uBAA8B;
|
|
1
|
+
{"version":3,"file":"ClientWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ClientWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AACvC,kEAAwC;AACxC,yCAAiF;AACjF,gDAA4F;AAE5F,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,mGAAmG;AACnG,sDAAsD;AACzC,QAAA,UAAU,GAAG,IAAI,CAAA;A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CAAC,wBAAwB,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACzB,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,IAAI,CAAC,aAAa,EAAE,CAAA;gBACpB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;gBACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;aAC1B;YACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;SACxB;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC1D;IACL,CAAC;CACJ;AA/GD,0CA+GC"}
|
|
@@ -7,6 +7,7 @@ export declare const connectivityMethodToWebsocketUrl: (ws: ConnectivityMethod,
|
|
|
7
7
|
export interface WebsocketConnectorConfig {
|
|
8
8
|
transport: ITransport;
|
|
9
9
|
onNewConnection: (connection: ManagedConnection) => boolean;
|
|
10
|
+
hasConnection: (peerDescriptor: PeerDescriptor) => boolean;
|
|
10
11
|
portRange?: PortRange;
|
|
11
12
|
maxMessageSize?: number;
|
|
12
13
|
host?: string;
|
|
@@ -22,19 +23,13 @@ export declare class WebsocketConnector {
|
|
|
22
23
|
private readonly rpcCommunicator;
|
|
23
24
|
private readonly websocketServer?;
|
|
24
25
|
private readonly ongoingConnectRequests;
|
|
25
|
-
private onNewConnection;
|
|
26
26
|
private host?;
|
|
27
|
-
private readonly entrypoints?;
|
|
28
|
-
private readonly tlsCertificate?;
|
|
29
|
-
private readonly autoCertifierTransport;
|
|
30
|
-
private readonly autoCertifierUrl;
|
|
31
|
-
private readonly autoCertifierConfigFile;
|
|
32
|
-
private readonly serverEnableTls;
|
|
33
27
|
private autoCertifierClient?;
|
|
34
28
|
private selectedPort?;
|
|
35
29
|
private localPeerDescriptor?;
|
|
36
30
|
private connectingConnections;
|
|
37
31
|
private abortController;
|
|
32
|
+
private readonly config;
|
|
38
33
|
constructor(config: WebsocketConnectorConfig);
|
|
39
34
|
private registerLocalRpcMethods;
|
|
40
35
|
private attachHandshaker;
|
|
@@ -36,7 +36,6 @@ const ManagedConnection_1 = require("../ManagedConnection");
|
|
|
36
36
|
const WebsocketServer_1 = require("./WebsocketServer");
|
|
37
37
|
const connectivityChecker_1 = require("../connectivityChecker");
|
|
38
38
|
const ConnectionManager_1 = require("../ConnectionManager");
|
|
39
|
-
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
40
39
|
const Handshaker_1 = require("../Handshaker");
|
|
41
40
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
42
41
|
const lodash_1 = require("lodash");
|
|
@@ -56,22 +55,16 @@ class WebsocketConnector {
|
|
|
56
55
|
this.ongoingConnectRequests = new Map();
|
|
57
56
|
this.connectingConnections = new Map();
|
|
58
57
|
this.abortController = new AbortController();
|
|
58
|
+
this.config = config;
|
|
59
59
|
this.websocketServer = config.portRange ? new WebsocketServer_1.WebsocketServer({
|
|
60
60
|
portRange: config.portRange,
|
|
61
61
|
tlsCertificate: config.tlsCertificate,
|
|
62
62
|
maxMessageSize: config.maxMessageSize,
|
|
63
63
|
enableTls: config.serverEnableTls
|
|
64
64
|
}) : undefined;
|
|
65
|
-
this.onNewConnection = config.onNewConnection;
|
|
66
65
|
this.host = config.host;
|
|
67
|
-
this.entrypoints = config.entrypoints;
|
|
68
|
-
this.tlsCertificate = config.tlsCertificate;
|
|
69
|
-
this.autoCertifierTransport = config.autoCertifierTransport;
|
|
70
|
-
this.autoCertifierUrl = config.autoCertifierUrl;
|
|
71
|
-
this.autoCertifierConfigFile = config.autoCertifierConfigFile;
|
|
72
|
-
this.serverEnableTls = config.serverEnableTls;
|
|
73
66
|
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebsocketConnector.WEBSOCKET_CONNECTOR_SERVICE_ID, config.transport, {
|
|
74
|
-
rpcRequestTimeout: 15000
|
|
67
|
+
rpcRequestTimeout: 15000 // TODO use config option or named constant?
|
|
75
68
|
});
|
|
76
69
|
this.registerLocalRpcMethods(config);
|
|
77
70
|
}
|
|
@@ -79,10 +72,11 @@ class WebsocketConnector {
|
|
|
79
72
|
const rpcLocal = new WebsocketConnectorRpcLocal_1.WebsocketConnectorRpcLocal({
|
|
80
73
|
connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
81
74
|
hasConnection: (targetPeerDescriptor) => {
|
|
82
|
-
const
|
|
83
|
-
if (this.connectingConnections.has(
|
|
84
|
-
|| this.connectingConnections.has(
|
|
85
|
-
|| this.ongoingConnectRequests.has(
|
|
75
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
76
|
+
if (this.connectingConnections.has(nodeId)
|
|
77
|
+
|| this.connectingConnections.has(nodeId)
|
|
78
|
+
|| this.ongoingConnectRequests.has(nodeId)
|
|
79
|
+
|| config.hasConnection(targetPeerDescriptor)) {
|
|
86
80
|
return true;
|
|
87
81
|
}
|
|
88
82
|
else {
|
|
@@ -92,12 +86,12 @@ class WebsocketConnector {
|
|
|
92
86
|
onNewConnection: (connection) => config.onNewConnection(connection),
|
|
93
87
|
abortSignal: this.abortController.signal
|
|
94
88
|
});
|
|
95
|
-
this.rpcCommunicator.
|
|
89
|
+
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.WebsocketConnectionRequest, 'requestConnection', async (req, context) => {
|
|
96
90
|
if (!this.abortController.signal.aborted) {
|
|
97
91
|
return rpcLocal.requestConnection(req, context);
|
|
98
92
|
}
|
|
99
93
|
else {
|
|
100
|
-
return {
|
|
94
|
+
return {};
|
|
101
95
|
}
|
|
102
96
|
});
|
|
103
97
|
}
|
|
@@ -109,9 +103,9 @@ class WebsocketConnector {
|
|
|
109
103
|
}
|
|
110
104
|
async autoCertify() {
|
|
111
105
|
this.autoCertifierClient = new AutoCertifierClientFacade_1.AutoCertifierClientFacade({
|
|
112
|
-
configFile: this.autoCertifierConfigFile,
|
|
113
|
-
transport: this.autoCertifierTransport,
|
|
114
|
-
url: this.autoCertifierUrl,
|
|
106
|
+
configFile: this.config.autoCertifierConfigFile,
|
|
107
|
+
transport: this.config.autoCertifierTransport,
|
|
108
|
+
url: this.config.autoCertifierUrl,
|
|
115
109
|
wsServerPort: this.selectedPort,
|
|
116
110
|
setHost: (hostName) => this.setHost(hostName),
|
|
117
111
|
updateCertificate: (certificate, privateKey) => this.websocketServer.updateCertificate(certificate, privateKey)
|
|
@@ -154,18 +148,18 @@ class WebsocketConnector {
|
|
|
154
148
|
return noServerConnectivityResponse;
|
|
155
149
|
}
|
|
156
150
|
for (const reattempt of (0, lodash_1.range)(ENTRY_POINT_CONNECTION_ATTEMPTS)) {
|
|
157
|
-
const entryPoint = (0, lodash_1.sample)(this.entrypoints);
|
|
151
|
+
const entryPoint = (0, lodash_1.sample)(this.config.entrypoints);
|
|
158
152
|
try {
|
|
159
153
|
if (!this.websocketServer) {
|
|
160
154
|
return noServerConnectivityResponse;
|
|
161
155
|
}
|
|
162
156
|
else {
|
|
163
|
-
if (!this.entrypoints || this.entrypoints.length === 0) {
|
|
157
|
+
if (!this.config.entrypoints || this.config.entrypoints.length === 0) {
|
|
164
158
|
// return connectivity info given in config
|
|
165
159
|
const preconfiguredConnectivityResponse = {
|
|
166
160
|
host: this.host,
|
|
167
161
|
natType: ConnectionManager_1.NatType.OPEN_INTERNET,
|
|
168
|
-
websocket: { host: this.host, port: this.selectedPort, tls: this.tlsCertificate !== undefined }
|
|
162
|
+
websocket: { host: this.host, port: this.selectedPort, tls: this.config.tlsCertificate !== undefined }
|
|
169
163
|
};
|
|
170
164
|
return preconfiguredConnectivityResponse;
|
|
171
165
|
}
|
|
@@ -174,7 +168,7 @@ class WebsocketConnector {
|
|
|
174
168
|
const connectivityRequest = {
|
|
175
169
|
port: this.selectedPort,
|
|
176
170
|
host: this.host,
|
|
177
|
-
tls: this.serverEnableTls,
|
|
171
|
+
tls: this.config.serverEnableTls,
|
|
178
172
|
selfSigned
|
|
179
173
|
};
|
|
180
174
|
if (!this.abortController.signal.aborted) {
|
|
@@ -202,8 +196,8 @@ class WebsocketConnector {
|
|
|
202
196
|
return (connectionType === IConnection_1.ConnectionType.WEBSOCKET_CLIENT || connectionType === IConnection_1.ConnectionType.WEBSOCKET_SERVER);
|
|
203
197
|
}
|
|
204
198
|
connect(targetPeerDescriptor) {
|
|
205
|
-
const
|
|
206
|
-
const existingConnection = this.connectingConnections.get(
|
|
199
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
200
|
+
const existingConnection = this.connectingConnections.get(nodeId);
|
|
207
201
|
if (existingConnection) {
|
|
208
202
|
return existingConnection;
|
|
209
203
|
}
|
|
@@ -215,10 +209,10 @@ class WebsocketConnector {
|
|
|
215
209
|
const url = (0, exports.connectivityMethodToWebsocketUrl)(targetPeerDescriptor.websocket);
|
|
216
210
|
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_CLIENT, socket, undefined, targetPeerDescriptor);
|
|
217
211
|
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
218
|
-
this.connectingConnections.set((0, peerIdFromPeerDescriptor_1.
|
|
212
|
+
this.connectingConnections.set((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
219
213
|
const delFunc = () => {
|
|
220
|
-
if (this.connectingConnections.has(
|
|
221
|
-
this.connectingConnections.delete(
|
|
214
|
+
if (this.connectingConnections.has(nodeId)) {
|
|
215
|
+
this.connectingConnections.delete(nodeId);
|
|
222
216
|
}
|
|
223
217
|
socket.off('disconnected', delFunc);
|
|
224
218
|
managedConnection.off('handshakeCompleted', delFunc);
|
|
@@ -231,29 +225,29 @@ class WebsocketConnector {
|
|
|
231
225
|
}
|
|
232
226
|
requestConnectionFromPeer(localPeerDescriptor, targetPeerDescriptor) {
|
|
233
227
|
setImmediate(() => {
|
|
234
|
-
const remoteConnector = new WebsocketConnectorRpcRemote_1.WebsocketConnectorRpcRemote(localPeerDescriptor, targetPeerDescriptor,
|
|
235
|
-
remoteConnector.requestConnection().then((
|
|
236
|
-
logger.trace('Sent WebsocketConnectionRequest
|
|
228
|
+
const remoteConnector = new WebsocketConnectorRpcRemote_1.WebsocketConnectorRpcRemote(localPeerDescriptor, targetPeerDescriptor, 'DUMMY', this.rpcCommunicator, DhtRpc_client_1.WebsocketConnectorRpcClient);
|
|
229
|
+
remoteConnector.requestConnection().then(() => {
|
|
230
|
+
logger.trace('Sent WebsocketConnectionRequest notification to peer', { targetPeerDescriptor });
|
|
237
231
|
return;
|
|
238
232
|
}, (err) => {
|
|
239
|
-
logger.debug('Failed to send WebsocketConnectionRequest
|
|
233
|
+
logger.debug('Failed to send WebsocketConnectionRequest notification to peer ', {
|
|
240
234
|
error: err, targetPeerDescriptor
|
|
241
235
|
});
|
|
242
236
|
});
|
|
243
237
|
});
|
|
244
238
|
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, undefined, targetPeerDescriptor);
|
|
245
|
-
managedConnection.on('disconnected', () => this.ongoingConnectRequests.delete((0, peerIdFromPeerDescriptor_1.
|
|
239
|
+
managedConnection.on('disconnected', () => this.ongoingConnectRequests.delete((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor)));
|
|
246
240
|
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
247
|
-
this.ongoingConnectRequests.set((0, peerIdFromPeerDescriptor_1.
|
|
241
|
+
this.ongoingConnectRequests.set((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
248
242
|
return managedConnection;
|
|
249
243
|
}
|
|
250
244
|
onServerSocketHandshakeRequest(sourcePeerDescriptor, serverWebsocket, targetPeerDescriptor) {
|
|
251
|
-
const
|
|
252
|
-
if (this.ongoingConnectRequests.has(
|
|
253
|
-
const ongoingConnectRequest = this.ongoingConnectRequests.get(
|
|
245
|
+
const nodeId = (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(sourcePeerDescriptor);
|
|
246
|
+
if (this.ongoingConnectRequests.has(nodeId)) {
|
|
247
|
+
const ongoingConnectRequest = this.ongoingConnectRequests.get(nodeId);
|
|
254
248
|
ongoingConnectRequest.attachImplementation(serverWebsocket);
|
|
255
249
|
ongoingConnectRequest.acceptHandshake();
|
|
256
|
-
this.ongoingConnectRequests.delete(
|
|
250
|
+
this.ongoingConnectRequests.delete(nodeId);
|
|
257
251
|
}
|
|
258
252
|
else {
|
|
259
253
|
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, serverWebsocket, targetPeerDescriptor);
|
|
@@ -261,7 +255,7 @@ class WebsocketConnector {
|
|
|
261
255
|
if (targetPeerDescriptor && !(0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(this.localPeerDescriptor, targetPeerDescriptor)) {
|
|
262
256
|
managedConnection.rejectHandshake(DhtRpc_1.HandshakeError.INVALID_TARGET_PEER_DESCRIPTOR);
|
|
263
257
|
}
|
|
264
|
-
else if (this.onNewConnection(managedConnection)) {
|
|
258
|
+
else if (this.config.onNewConnection(managedConnection)) {
|
|
265
259
|
managedConnection.acceptHandshake();
|
|
266
260
|
}
|
|
267
261
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnector.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAmD;AACnD,gDAA4D;AAE5D,uFAAmF;AACnF,6EAAyE;AACzE,+EAA2E;AAC3E,
|
|
1
|
+
{"version":3,"file":"WebsocketConnector.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketCon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{ PeerDescriptor, WebsocketConnectionRequest
|
|
3
|
+
import { PeerDescriptor, WebsocketConnectionRequest } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import { IWebsocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
5
5
|
import { ManagedConnection } from '../ManagedConnection';
|
|
6
|
+
import { Empty } from '../../proto/google/protobuf/empty';
|
|
6
7
|
interface WebsocketConnectorRpcLocalConfig {
|
|
7
8
|
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
8
9
|
hasConnection: (targetPeerDescriptor: PeerDescriptor) => boolean;
|
|
@@ -12,6 +13,6 @@ interface WebsocketConnectorRpcLocalConfig {
|
|
|
12
13
|
export declare class WebsocketConnectorRpcLocal implements IWebsocketConnectorRpc {
|
|
13
14
|
private readonly config;
|
|
14
15
|
constructor(config: WebsocketConnectorRpcLocalConfig);
|
|
15
|
-
requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<
|
|
16
|
+
requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<Empty>;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
|
@@ -6,17 +6,15 @@ class WebsocketConnectorRpcLocal {
|
|
|
6
6
|
this.config = config;
|
|
7
7
|
}
|
|
8
8
|
async requestConnection(_request, context) {
|
|
9
|
+
if (this.config.abortSignal.aborted) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
9
12
|
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const connection = this.config.connect(senderPeerDescriptor);
|
|
16
|
-
this.config.onNewConnection(connection);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return { accepted: true };
|
|
13
|
+
if (!this.config.hasConnection(senderPeerDescriptor)) {
|
|
14
|
+
const connection = this.config.connect(senderPeerDescriptor);
|
|
15
|
+
this.config.onNewConnection(connection);
|
|
16
|
+
}
|
|
17
|
+
return {};
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
20
|
exports.WebsocketConnectorRpcLocal = WebsocketConnectorRpcLocal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcLocal.ts"],"names":[],"mappings":";;;AAiBA,MAAa,0BAA0B;IAInC,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAoC,EAAE,OAA0B;QAC3F,
|
|
1
|
+
{"version":3,"file":"WebsocketConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcLocal.ts"],"names":[],"mappings":";;;AAiBA,MAAa,0BAA0B;IAInC,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAoC,EAAE,OAA0B;QAC3F,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;YACjC,OAAO,EAAE,CAAA;SACZ;QACD,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE;YAClD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;YAC5D,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;SAC1C;QACD,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AAnBD,gEAmBC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { PeerDescriptor, WebsocketConnectionResponse } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
-
import { IWebsocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
-
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
4
1
|
import { RpcRemote } from '../../dht/contact/RpcRemote';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
requestConnection(): Promise<
|
|
2
|
+
import { WebsocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
+
export declare class WebsocketConnectorRpcRemote extends RpcRemote<WebsocketConnectorRpcClient> {
|
|
4
|
+
requestConnection(): Promise<void>;
|
|
8
5
|
}
|
|
@@ -6,9 +6,6 @@ const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescript
|
|
|
6
6
|
const RpcRemote_1 = require("../../dht/contact/RpcRemote");
|
|
7
7
|
const logger = new utils_1.Logger(module);
|
|
8
8
|
class WebsocketConnectorRpcRemote extends RpcRemote_1.RpcRemote {
|
|
9
|
-
constructor(localPeerDescriptor, remotePeerDescriptor, client) {
|
|
10
|
-
super(localPeerDescriptor, remotePeerDescriptor, 'DUMMY', client);
|
|
11
|
-
}
|
|
12
9
|
async requestConnection() {
|
|
13
10
|
logger.trace(`Requesting WebSocket connection from ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.getLocalPeerDescriptor())}`);
|
|
14
11
|
const request = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcRemote.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"WebsocketConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAGA,0CAAuC;AACvC,qFAAoF;AACpF,2DAAuD;AAGvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,2BAA4B,SAAQ,qBAAsC;IAEnF,KAAK,CAAC,iBAAiB;QACnB,MAAM,CAAC,KAAK,CAAC,wCAAwC,IAAA,sDAA2B,EAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,EAAE,CAAC,CAAA;QAClH,MAAM,OAAO,GAA+B,EAAE,CAAA;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;CACJ;AARD,kEAQC"}
|
|
@@ -11,10 +11,7 @@ export declare class WebsocketServer extends EventEmitter<ConnectionSourceEvents
|
|
|
11
11
|
private httpServer?;
|
|
12
12
|
private wsServer?;
|
|
13
13
|
private readonly abortController;
|
|
14
|
-
private readonly
|
|
15
|
-
private readonly tlsCertificate?;
|
|
16
|
-
private readonly enableTls;
|
|
17
|
-
private readonly maxMessageSize;
|
|
14
|
+
private readonly config;
|
|
18
15
|
constructor(config: WebsocketServerConfig);
|
|
19
16
|
start(): Promise<number>;
|
|
20
17
|
private startServer;
|