@streamr/dht 100.0.0-pretestnet.6 → 100.0.0-rc.1
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/README.md +90 -8
- package/dist/package.json +70 -0
- package/dist/src/connection/Connection.d.ts +1 -0
- package/dist/src/connection/Connection.js +10 -3
- package/dist/src/connection/Connection.js.map +1 -1
- package/dist/src/connection/ConnectionLockHandler.d.ts +14 -14
- package/dist/src/connection/ConnectionLockHandler.js +22 -16
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +7 -6
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js +10 -37
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +19 -20
- package/dist/src/connection/ConnectionManager.js +132 -117
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +3 -2
- package/dist/src/connection/ConnectorFacade.js +10 -3
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +3 -1
- package/dist/src/connection/Handshaker.js +19 -10
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +2 -7
- package/dist/src/connection/IConnection.js +1 -8
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +5 -7
- package/dist/src/connection/ManagedConnection.js +42 -26
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -1
- package/dist/src/connection/connectivityChecker.d.ts +9 -0
- package/dist/src/connection/connectivityChecker.js +130 -0
- package/dist/src/connection/connectivityChecker.js.map +1 -0
- package/dist/src/connection/connectivityRequestHandler.d.ts +3 -0
- package/dist/src/connection/connectivityRequestHandler.js +101 -0
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -0
- package/dist/src/connection/simulator/Simulator.d.ts +0 -3
- package/dist/src/connection/simulator/Simulator.js +34 -69
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +27 -25
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.js +16 -12
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/simulator/pings.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +2 -3
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +40 -27
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +1 -2
- package/dist/src/connection/webrtc/WebrtcConnector.js +36 -32
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +4 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +28 -22
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.d.ts +3 -6
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js +2 -5
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js +1 -1
- package/dist/src/connection/webrtc/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +1 -2
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +6 -4
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/ClientWebsocket.d.ts +1 -0
- package/dist/src/connection/websocket/ClientWebsocket.js +14 -7
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +3 -9
- package/dist/src/connection/websocket/WebsocketConnector.js +142 -74
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +5 -3
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +9 -12
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +4 -7
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js +7 -44
- 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 +49 -40
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{ServerWebsocket.d.ts → WebsocketServerConnection.d.ts} +8 -4
- package/dist/src/connection/websocket/WebsocketServerConnection.js +97 -0
- package/dist/src/connection/websocket/WebsocketServerConnection.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +45 -49
- package/dist/src/dht/DhtNode.js +229 -317
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +10 -9
- package/dist/src/dht/DhtNodeRpcLocal.js +19 -11
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcRemote.d.ts +15 -10
- package/dist/src/dht/DhtNodeRpcRemote.js +38 -21
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +7 -6
- package/dist/src/dht/ExternalApiRpcLocal.js +9 -13
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +6 -5
- package/dist/src/dht/ExternalApiRpcRemote.js +10 -7
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +61 -0
- package/dist/src/dht/PeerManager.js +288 -0
- package/dist/src/dht/PeerManager.js.map +1 -0
- package/dist/src/dht/contact/Contact.d.ts +2 -2
- package/dist/src/dht/contact/Contact.js +4 -3
- package/dist/src/dht/contact/Contact.js.map +1 -1
- package/dist/src/dht/contact/ContactList.d.ts +8 -8
- package/dist/src/dht/contact/ContactList.js +12 -7
- 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 +13 -12
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/RingContactList.d.ts +31 -0
- package/dist/src/dht/contact/RingContactList.js +133 -0
- package/dist/src/dht/contact/RingContactList.js.map +1 -0
- package/dist/src/dht/contact/{Remote.d.ts → RpcRemote.d.ts} +8 -7
- package/dist/src/dht/contact/{Remote.js → RpcRemote.js} +16 -13
- package/dist/src/dht/contact/RpcRemote.js.map +1 -0
- package/dist/src/dht/contact/SortedContactList.d.ts +29 -15
- package/dist/src/dht/contact/SortedContactList.js +79 -42
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/contact/ringIdentifiers.d.ts +16 -0
- package/dist/src/dht/contact/ringIdentifiers.js +54 -0
- package/dist/src/dht/contact/ringIdentifiers.js.map +1 -0
- package/dist/src/dht/discovery/DiscoverySession.d.ts +8 -18
- package/dist/src/dht/discovery/DiscoverySession.js +32 -48
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +16 -12
- package/dist/src/dht/discovery/PeerDiscovery.js +82 -39
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +29 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js +123 -0
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +36 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +166 -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/recursive-operation/RecursiveOperationRpcLocal.js +26 -0
- 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/recursive-operation/RecursiveOperationRpcRemote.js +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcRemote.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +44 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +187 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +14 -0
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +20 -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/DuplicateDetector.d.ts +2 -4
- package/dist/src/dht/routing/DuplicateDetector.js +10 -15
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +11 -27
- package/dist/src/dht/routing/Router.js +92 -58
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -4
- package/dist/src/dht/routing/RouterRpcLocal.js +17 -16
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +3 -3
- package/dist/src/dht/routing/RouterRpcRemote.js +29 -20
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +29 -21
- package/dist/src/dht/routing/RoutingSession.js +93 -68
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/RoutingTablesCache.d.ts +24 -0
- package/dist/src/dht/routing/RoutingTablesCache.js +46 -0
- package/dist/src/dht/routing/RoutingTablesCache.js.map +1 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -1
- package/dist/src/dht/store/LocalDataStore.d.ts +9 -14
- package/dist/src/dht/store/LocalDataStore.js +46 -72
- 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 +182 -0
- package/dist/src/dht/store/StoreManager.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -41
- package/dist/src/dht/store/StoreRpcLocal.js +27 -234
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.d.ts +6 -7
- package/dist/src/dht/store/StoreRpcRemote.js +10 -20
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +5 -3
- package/dist/src/exports.js +10 -8
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/AddressTools.js +2 -0
- package/dist/src/helpers/AddressTools.js.map +1 -1
- package/dist/src/helpers/Connectivity.js.map +1 -1
- package/dist/src/helpers/MapWithTtl.d.ts +14 -0
- package/dist/src/helpers/MapWithTtl.js +60 -0
- package/dist/src/helpers/MapWithTtl.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptor.d.ts +3 -0
- package/dist/src/helpers/createPeerDescriptor.js +57 -0
- package/dist/src/helpers/createPeerDescriptor.js.map +1 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.d.ts +2 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js +30 -0
- package/dist/src/helpers/createPeerDescriptorSignaturePayload.js.map +1 -0
- package/dist/src/helpers/debugHelpers.js.map +1 -1
- package/dist/src/helpers/errors.js +2 -0
- package/dist/src/helpers/errors.js.map +1 -1
- package/dist/src/helpers/offering.d.ts +4 -0
- package/dist/src/helpers/offering.js +18 -0
- package/dist/src/helpers/offering.js.map +1 -0
- package/dist/src/helpers/protoClasses.js +2 -3
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/helpers/protoToString.js.map +1 -1
- package/dist/src/helpers/version.d.ts +6 -0
- package/dist/src/helpers/version.js +38 -0
- package/dist/src/helpers/version.js.map +1 -0
- package/dist/src/identifiers.d.ts +10 -0
- package/dist/src/identifiers.js +31 -0
- package/dist/src/identifiers.js.map +1 -0
- package/dist/src/proto/google/protobuf/any.js +8 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.js +2 -4
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.js +10 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +46 -49
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +63 -54
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +226 -232
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +146 -168
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -29
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +2 -2
- package/dist/src/rpc-protocol/DhtCallContext.js +8 -0
- 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 +10 -2
- package/dist/src/transport/ITransport.js +5 -0
- package/dist/src/transport/ITransport.js.map +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.js +3 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +4 -2
- package/dist/src/transport/RoutingRpcCommunicator.js +19 -12
- 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 +13 -9
- package/package.json +17 -14
- package/protos/DhtRpc.proto +76 -76
- package/src/connection/Connection.ts +6 -1
- package/src/connection/ConnectionLockHandler.ts +30 -22
- package/src/connection/ConnectionLockRpcLocal.ts +7 -12
- package/src/connection/ConnectionLockRpcRemote.ts +9 -19
- package/src/connection/ConnectionManager.ts +132 -138
- package/src/connection/ConnectorFacade.ts +10 -9
- package/src/connection/Handshaker.ts +24 -12
- package/src/connection/IConnection.ts +2 -8
- package/src/connection/ManagedConnection.ts +34 -35
- package/src/connection/connectivityChecker.ts +109 -0
- package/src/connection/connectivityRequestHandler.ts +103 -0
- package/src/connection/simulator/Simulator.ts +6 -37
- package/src/connection/simulator/SimulatorConnection.ts +23 -25
- package/src/connection/simulator/SimulatorConnector.ts +11 -11
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +17 -25
- package/src/connection/webrtc/NodeWebrtcConnection.ts +25 -27
- package/src/connection/webrtc/WebrtcConnector.ts +31 -36
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +31 -25
- package/src/connection/webrtc/WebrtcConnectorRpcRemote.ts +4 -14
- package/src/connection/webrtc/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +4 -6
- package/src/connection/websocket/ClientWebsocket.ts +10 -4
- package/src/connection/websocket/WebsocketConnector.ts +120 -97
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +13 -15
- package/src/connection/websocket/WebsocketConnectorRpcRemote.ts +7 -27
- package/src/connection/websocket/WebsocketServer.ts +50 -53
- package/src/connection/websocket/WebsocketServerConnection.ts +104 -0
- package/src/dht/DhtNode.ts +289 -410
- package/src/dht/DhtNodeRpcLocal.ts +25 -17
- package/src/dht/DhtNodeRpcRemote.ts +43 -27
- package/src/dht/ExternalApiRpcLocal.ts +30 -17
- package/src/dht/ExternalApiRpcRemote.ts +14 -11
- package/src/dht/PeerManager.ts +339 -0
- package/src/dht/contact/Contact.ts +4 -4
- package/src/dht/contact/ContactList.ts +11 -10
- package/src/dht/contact/RandomContactList.ts +15 -15
- package/src/dht/contact/RingContactList.ts +151 -0
- package/src/dht/contact/{Remote.ts → RpcRemote.ts} +16 -19
- package/src/dht/contact/SortedContactList.ts +120 -72
- package/src/dht/contact/ringIdentifiers.ts +62 -0
- package/src/dht/discovery/DiscoverySession.ts +36 -61
- package/src/dht/discovery/PeerDiscovery.ts +98 -43
- package/src/dht/discovery/RingDiscoverySession.ts +160 -0
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +246 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +34 -0
- package/src/dht/recursive-operation/RecursiveOperationRpcRemote.ts +43 -0
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +232 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +35 -0
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcRemote.ts +30 -0
- package/src/dht/routing/DuplicateDetector.ts +9 -21
- package/src/dht/routing/Router.ts +95 -92
- package/src/dht/routing/RouterRpcLocal.ts +16 -18
- package/src/dht/routing/RouterRpcRemote.ts +26 -24
- package/src/dht/routing/RoutingSession.ts +119 -98
- package/src/dht/routing/RoutingTablesCache.ts +58 -0
- package/src/dht/routing/getPreviousPeer.ts +1 -1
- package/src/dht/store/LocalDataStore.ts +47 -77
- package/src/dht/store/StoreManager.ts +209 -0
- package/src/dht/store/StoreRpcLocal.ts +39 -308
- package/src/dht/store/StoreRpcRemote.ts +13 -31
- package/src/exports.ts +13 -3
- package/src/helpers/AddressTools.ts +2 -0
- package/src/helpers/MapWithTtl.ts +71 -0
- package/src/helpers/createPeerDescriptor.ts +57 -0
- package/src/helpers/createPeerDescriptorSignaturePayload.ts +28 -0
- package/src/helpers/offering.ts +15 -0
- package/src/helpers/protoClasses.ts +4 -6
- package/src/helpers/version.ts +32 -0
- package/src/identifiers.ts +29 -0
- package/src/proto/google/protobuf/any.ts +4 -4
- package/src/proto/google/protobuf/empty.ts +2 -4
- package/src/proto/google/protobuf/timestamp.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +65 -68
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +27 -30
- package/src/proto/packages/dht/protos/DhtRpc.ts +297 -313
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/rpc-protocol/DhtCallContext.ts +2 -2
- package/src/rpc-protocol/DhtRpcOptions.ts +2 -1
- package/src/transport/ITransport.ts +11 -2
- package/src/transport/ListeningRpcCommunicator.ts +1 -1
- package/src/transport/RoutingRpcCommunicator.ts +21 -14
- package/test/RandomGraphSimulation.ts +3 -2
- package/test/benchmark/Find.test.ts +13 -28
- package/test/benchmark/KademliaCorrectness.test.ts +24 -28
- package/test/benchmark/RingCorrectness.test.ts +157 -0
- package/test/benchmark/SortedContactListBenchmark.test.ts +151 -0
- package/test/benchmark/WebsocketServerMemoryLeak.test.ts +41 -0
- package/test/benchmark/hybrid-network-simulation/RingContactList.test.ts +72 -0
- package/test/benchmark/kademlia-simulation/Contact.ts +9 -9
- package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +11 -11
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +29 -25
- package/test/data/generateGroundTruthData.ts +7 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +11 -15
- package/test/end-to-end/Layer0.test.ts +19 -22
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +19 -21
- package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +26 -28
- package/test/end-to-end/Layer0Webrtc.test.ts +19 -19
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +10 -18
- package/test/end-to-end/Layer1-Scale-Webrtc.test.ts +8 -15
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +2 -2
- package/test/end-to-end/WebsocketConnectionRequest.test.ts +8 -9
- package/test/end-to-end/memory-leak.test.ts +19 -24
- package/test/integration/ConnectionLocking.test.ts +66 -60
- package/test/integration/ConnectionManager.test.ts +43 -63
- package/test/integration/ConnectivityChecking.test.ts +52 -0
- package/test/integration/DhtJoinPeerDiscovery.test.ts +8 -12
- package/test/integration/DhtNodeExternalAPI.test.ts +17 -21
- package/test/integration/DhtNodeRpcRemote.test.ts +19 -26
- package/test/integration/DhtRpc.test.ts +20 -24
- package/test/integration/Find.test.ts +10 -12
- package/test/integration/Layer1-scale.test.ts +25 -37
- package/test/integration/Mock-Layer1-Layer0.test.ts +39 -59
- package/test/integration/MultipleEntryPointJoining.test.ts +14 -14
- package/test/integration/ReplicateData.test.ts +106 -0
- package/test/integration/RouteMessage.test.ts +42 -68
- package/test/integration/RouterRpcRemote.test.ts +19 -24
- package/test/integration/ScaleDownDht.test.ts +14 -12
- package/test/integration/SimultaneousConnections.test.ts +112 -111
- package/test/integration/Store.test.ts +43 -27
- package/test/integration/StoreAndDelete.test.ts +36 -48
- package/test/integration/StoreOnDhtWithThreeNodes.test.ts +59 -0
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +17 -37
- package/test/integration/StoreRpcRemote.test.ts +20 -32
- package/test/integration/WebrtcConnectionManagement.test.ts +39 -25
- package/test/integration/WebrtcConnectorRpc.test.ts +6 -11
- package/test/integration/WebsocketConnectionManagement.test.ts +87 -22
- package/test/integration/WebsocketConnectorRpc.test.ts +14 -24
- package/test/integration/{RpcErrors.test.ts → rpc-connections-over-webrpc.test.ts} +15 -26
- package/test/unit/AddressTools.test.ts +4 -0
- package/test/unit/ConnectivityHelpers.test.ts +9 -17
- package/test/unit/DuplicateDetector.test.ts +8 -5
- package/test/unit/LocalDataStore.test.ts +78 -75
- package/test/unit/PeerManager.test.ts +33 -0
- package/test/unit/RandomContactList.test.ts +12 -9
- package/test/unit/RecursiveOperationManager.test.ts +157 -0
- package/test/unit/RecursiveOperationSession.test.ts +68 -0
- package/test/unit/Router.test.ts +52 -35
- package/test/unit/RoutingSession.test.ts +79 -0
- package/test/unit/SortedContactList.test.ts +61 -30
- package/test/unit/StoreManager.test.ts +138 -0
- package/test/unit/WebsocketConnector.test.ts +27 -35
- package/test/unit/connectivityRequestHandler.test.ts +104 -0
- package/test/unit/createPeerDescriptor.test.ts +69 -0
- package/test/unit/customMatchers.test.ts +16 -0
- package/test/unit/version.test.ts +18 -0
- package/test/utils/FakeTransport.ts +47 -0
- package/test/utils/customMatchers.ts +71 -0
- package/test/utils/mock/MockRpcCommunicator.ts +7 -0
- package/test/utils/mock/Router.ts +13 -3
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/mock/mockDataEntry.ts +38 -0
- package/test/utils/utils.ts +104 -107
- package/tsconfig.browser.json +2 -1
- package/tsconfig.jest.json +4 -2
- package/tsconfig.node.json +4 -2
- package/dist/src/connection/ConnectivityChecker.d.ts +0 -17
- package/dist/src/connection/ConnectivityChecker.js +0 -208
- package/dist/src/connection/ConnectivityChecker.js.map +0 -1
- package/dist/src/connection/websocket/ServerWebsocket.js +0 -100
- package/dist/src/connection/websocket/ServerWebsocket.js.map +0 -1
- package/dist/src/dht/contact/Remote.js.map +0 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +0 -14
- package/dist/src/dht/find/FindRpcLocal.js +0 -25
- 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 -145
- 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 -184
- 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 +0 -41
- package/dist/src/dht/routing/FindRpcRemote.js.map +0 -1
- package/dist/src/helpers/PeerID.d.ts +0 -24
- package/dist/src/helpers/PeerID.js +0 -78
- package/dist/src/helpers/PeerID.js.map +0 -1
- package/dist/src/helpers/UUID.d.ts +0 -8
- package/dist/src/helpers/UUID.js +0 -36
- package/dist/src/helpers/UUID.js.map +0 -1
- package/dist/src/helpers/kademliaId.d.ts +0 -1
- package/dist/src/helpers/kademliaId.js +0 -14
- package/dist/src/helpers/kademliaId.js.map +0 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +0 -6
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +0 -23
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +0 -1
- package/src/connection/ConnectivityChecker.ts +0 -199
- package/src/connection/websocket/ServerWebsocket.ts +0 -114
- package/src/dht/find/FindRpcLocal.ts +0 -35
- package/src/dht/find/FindSession.ts +0 -178
- package/src/dht/find/FindSessionRpcLocal.ts +0 -25
- package/src/dht/find/FindSessionRpcRemote.ts +0 -30
- package/src/dht/find/Finder.ts +0 -275
- package/src/dht/routing/FindRpcRemote.ts +0 -40
- package/src/helpers/PeerID.ts +0 -88
- package/src/helpers/UUID.ts +0 -35
- package/src/helpers/kademliaId.ts +0 -8
- package/src/helpers/peerIdFromPeerDescriptor.ts +0 -20
- package/test/integration/MigrateData.test.ts +0 -204
- package/test/unit/Finder.test.ts +0 -110
- package/test/unit/PeerID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NodeWebrtcConnection extends EventEmitter<Events> implement
|
|
|
41
41
|
close(gracefulLeave: boolean, reason?: string): Promise<void>;
|
|
42
42
|
private doClose;
|
|
43
43
|
destroy(): void;
|
|
44
|
-
private onDataChannel;
|
|
45
44
|
private setupDataChannel;
|
|
46
|
-
private
|
|
45
|
+
private onDataChannelOpen;
|
|
47
46
|
private onStateChange;
|
|
48
47
|
isOpen(): boolean;
|
|
49
|
-
setConnectionId(
|
|
48
|
+
setConnectionId(connectionId: ConnectionID): void;
|
|
50
49
|
}
|
|
51
50
|
export {};
|
|
@@ -32,8 +32,9 @@ const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
|
32
32
|
const node_datachannel_1 = __importStar(require("node-datachannel"));
|
|
33
33
|
const utils_1 = require("@streamr/utils");
|
|
34
34
|
const errors_1 = require("../../helpers/errors");
|
|
35
|
-
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
36
35
|
const iceServerAsString_1 = require("./iceServerAsString");
|
|
36
|
+
const identifiers_1 = require("../../identifiers");
|
|
37
|
+
const Connection_1 = require("../Connection");
|
|
37
38
|
const logger = new utils_1.Logger(module);
|
|
38
39
|
exports.WEBRTC_CLEANUP = new class {
|
|
39
40
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -54,13 +55,24 @@ var RtcPeerConnectionStateEnum;
|
|
|
54
55
|
})(RtcPeerConnectionStateEnum || (RtcPeerConnectionStateEnum = {}));
|
|
55
56
|
node_datachannel_1.default.initLogger('Fatal');
|
|
56
57
|
class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
58
|
+
connectionId;
|
|
59
|
+
connection;
|
|
60
|
+
dataChannel;
|
|
61
|
+
lastState = 'connecting';
|
|
62
|
+
remoteDescriptionSet = false;
|
|
63
|
+
connectingTimeoutRef;
|
|
64
|
+
connectionType = IConnection_1.ConnectionType.WEBRTC;
|
|
65
|
+
iceServers;
|
|
66
|
+
_bufferThresholdHigh; // TODO: buffer handling must be implemented before production use (NET-938)
|
|
67
|
+
bufferThresholdLow;
|
|
68
|
+
connectingTimeout;
|
|
69
|
+
remotePeerDescriptor;
|
|
70
|
+
portRange;
|
|
71
|
+
maxMessageSize;
|
|
72
|
+
closed = false;
|
|
57
73
|
constructor(params) {
|
|
58
74
|
super();
|
|
59
|
-
this.
|
|
60
|
-
this.remoteDescriptionSet = false;
|
|
61
|
-
this.connectionType = IConnection_1.ConnectionType.WEBRTC;
|
|
62
|
-
this.closed = false;
|
|
63
|
-
this.connectionId = new IConnection_1.ConnectionID();
|
|
75
|
+
this.connectionId = (0, Connection_1.createRandomConnectionId)();
|
|
64
76
|
this.iceServers = params.iceServers ?? [];
|
|
65
77
|
// eslint-disable-next-line no-underscore-dangle
|
|
66
78
|
this._bufferThresholdHigh = params.bufferThresholdHigh ?? 2 ** 17;
|
|
@@ -71,9 +83,9 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
71
83
|
this.portRange = params.portRange;
|
|
72
84
|
}
|
|
73
85
|
start(isOffering) {
|
|
74
|
-
const
|
|
75
|
-
logger.trace(`Starting new connection for peer ${
|
|
76
|
-
this.connection = new node_datachannel_1.PeerConnection(
|
|
86
|
+
const nodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
87
|
+
logger.trace(`Starting new connection for peer ${nodeId}`, { isOffering });
|
|
88
|
+
this.connection = new node_datachannel_1.PeerConnection(nodeId, {
|
|
77
89
|
iceServers: this.iceServers.map(iceServerAsString_1.iceServerAsString),
|
|
78
90
|
maxMessageSize: this.maxMessageSize,
|
|
79
91
|
portRangeBegin: this.portRange?.min,
|
|
@@ -96,18 +108,19 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
96
108
|
this.setupDataChannel(dataChannel);
|
|
97
109
|
}
|
|
98
110
|
else {
|
|
99
|
-
this.connection.onDataChannel((dataChannel) => this.
|
|
111
|
+
this.connection.onDataChannel((dataChannel) => this.setupDataChannel(dataChannel));
|
|
100
112
|
}
|
|
101
113
|
}
|
|
102
114
|
async setRemoteDescription(description, type) {
|
|
103
115
|
if (this.connection) {
|
|
116
|
+
const remoteNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
104
117
|
try {
|
|
105
|
-
logger.trace(`Setting remote descriptor for peer: ${
|
|
118
|
+
logger.trace(`Setting remote descriptor for peer: ${remoteNodeId}`);
|
|
106
119
|
this.connection.setRemoteDescription(description, type);
|
|
107
120
|
this.remoteDescriptionSet = true;
|
|
108
121
|
}
|
|
109
122
|
catch (err) {
|
|
110
|
-
logger.debug(`Failed to set remote descriptor for peer ${
|
|
123
|
+
logger.debug(`Failed to set remote descriptor for peer ${remoteNodeId}`);
|
|
111
124
|
}
|
|
112
125
|
}
|
|
113
126
|
else {
|
|
@@ -117,12 +130,13 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
117
130
|
addRemoteCandidate(candidate, mid) {
|
|
118
131
|
if (this.connection) {
|
|
119
132
|
if (this.remoteDescriptionSet) {
|
|
133
|
+
const remoteNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
120
134
|
try {
|
|
121
|
-
logger.trace(`Setting remote candidate for peer: ${
|
|
135
|
+
logger.trace(`Setting remote candidate for peer: ${remoteNodeId}`);
|
|
122
136
|
this.connection.addRemoteCandidate(candidate, mid);
|
|
123
137
|
}
|
|
124
138
|
catch (err) {
|
|
125
|
-
logger.debug(`Failed to set remote candidate for peer ${
|
|
139
|
+
logger.debug(`Failed to set remote candidate for peer ${remoteNodeId}`);
|
|
126
140
|
}
|
|
127
141
|
}
|
|
128
142
|
else {
|
|
@@ -140,7 +154,8 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
140
154
|
this.dataChannel.sendMessageBinary(data);
|
|
141
155
|
}
|
|
142
156
|
catch (err) {
|
|
143
|
-
|
|
157
|
+
const remoteNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
158
|
+
logger.debug('Failed to send binary message to ' + remoteNodeId + err);
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
}
|
|
@@ -149,8 +164,8 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
149
164
|
}
|
|
150
165
|
doClose(gracefulLeave, reason) {
|
|
151
166
|
if (!this.closed) {
|
|
152
|
-
|
|
153
|
-
|
|
167
|
+
const remoteNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
168
|
+
logger.trace(`Closing Node WebRTC Connection to ${remoteNodeId}` + `${(reason !== undefined) ? `, reason: ${reason}` : ''}`);
|
|
154
169
|
this.closed = true;
|
|
155
170
|
this.emit('disconnected', gracefulLeave, undefined, reason);
|
|
156
171
|
this.removeAllListeners();
|
|
@@ -174,21 +189,20 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
174
189
|
logger.trace('conn.close() errored: %s', e);
|
|
175
190
|
}
|
|
176
191
|
}
|
|
192
|
+
this.connection = undefined;
|
|
193
|
+
this.dataChannel = undefined;
|
|
177
194
|
}
|
|
178
195
|
}
|
|
179
196
|
destroy() {
|
|
180
197
|
this.removeAllListeners();
|
|
181
198
|
this.doClose(false);
|
|
182
199
|
}
|
|
183
|
-
onDataChannel(dataChannel) {
|
|
184
|
-
this.openDataChannel(dataChannel);
|
|
185
|
-
this.setupDataChannel(dataChannel);
|
|
186
|
-
}
|
|
187
200
|
setupDataChannel(dataChannel) {
|
|
201
|
+
this.dataChannel = dataChannel;
|
|
188
202
|
dataChannel.setBufferedAmountLowThreshold(this.bufferThresholdLow);
|
|
189
203
|
dataChannel.onOpen(() => {
|
|
190
204
|
logger.trace(`dc.onOpened`);
|
|
191
|
-
this.
|
|
205
|
+
this.onDataChannelOpen();
|
|
192
206
|
});
|
|
193
207
|
dataChannel.onClosed(() => {
|
|
194
208
|
logger.trace(`dc.closed`);
|
|
@@ -203,12 +217,11 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
203
217
|
this.emit('data', msg);
|
|
204
218
|
});
|
|
205
219
|
}
|
|
206
|
-
|
|
220
|
+
onDataChannelOpen() {
|
|
207
221
|
if (this.connectingTimeoutRef) {
|
|
208
222
|
clearTimeout(this.connectingTimeoutRef);
|
|
209
223
|
}
|
|
210
|
-
|
|
211
|
-
logger.trace(`DataChannel opened for peer ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
224
|
+
logger.trace(`DataChannel opened for peer ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
212
225
|
this.emit('connected');
|
|
213
226
|
}
|
|
214
227
|
onStateChange(state) {
|
|
@@ -228,8 +241,8 @@ class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
|
228
241
|
isOpen() {
|
|
229
242
|
return !this.closed && this.lastState === 'connected' && !!this.dataChannel;
|
|
230
243
|
}
|
|
231
|
-
setConnectionId(
|
|
232
|
-
this.connectionId =
|
|
244
|
+
setConnectionId(connectionId) {
|
|
245
|
+
this.connectionId = connectionId;
|
|
233
246
|
}
|
|
234
247
|
}
|
|
235
248
|
exports.NodeWebrtcConnection = NodeWebrtcConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/NodeWebrtcConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA4F;AAE5F,kEAAwC;AACxC,qEAAgG;AAChG,0CAAuC;AACvC,iDAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"NodeWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/NodeWebrtcConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA4F;AAE5F,kEAAwC;AACxC,qEAAgG;AAChG,0CAAuC;AACvC,iDAAoE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3C,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,+BAA+B,IAAA,yCAA2B,EAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAA;QACrG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC1B,CAAC;IAEO,aAAa,CAAC,KAAa;QAC/B,MAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACpF,MAAM,IAAI,sCAA6B,CAAC,8CAA8C,GAAG,KAAK,CAAC,CAAA;QACnG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,SAAS,GAAG,KAA+B,CAAA;QACpD,CAAC;QAED,IAAI,KAAK,KAAK,0BAA0B,CAAC,MAAM;eACxC,KAAK,KAAK,0BAA0B,CAAC,YAAY;eACjD,KAAK,KAAK,0BAA0B,CAAC,MAAM,EAChD,CAAC;YACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC;IAEL,CAAC;IAED,MAAM;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IAC/E,CAAC;IAEM,eAAe,CAAC,YAA0B;QAC7C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IACpC,CAAC;CACJ;AAjND,oDAiNC"}
|
|
@@ -27,12 +27,11 @@ export declare class WebrtcConnector {
|
|
|
27
27
|
private readonly ongoingConnectAttempts;
|
|
28
28
|
private localPeerDescriptor?;
|
|
29
29
|
private stopped;
|
|
30
|
-
private iceServers;
|
|
31
30
|
private config;
|
|
32
31
|
constructor(config: WebrtcConnectorConfig, onNewConnection: (connection: ManagedConnection) => boolean);
|
|
33
32
|
private registerLocalRpcMethods;
|
|
34
33
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
34
|
+
private createConnection;
|
|
35
35
|
setLocalPeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
36
36
|
stop(): Promise<void>;
|
|
37
|
-
isOffering(targetPeerDescriptor: PeerDescriptor): boolean;
|
|
38
37
|
}
|
|
@@ -32,9 +32,9 @@ const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client")
|
|
|
32
32
|
const ManagedWebrtcConnection_1 = require("../ManagedWebrtcConnection");
|
|
33
33
|
const utils_1 = require("@streamr/utils");
|
|
34
34
|
const Err = __importStar(require("../../helpers/errors"));
|
|
35
|
-
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
36
|
-
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
37
35
|
const WebrtcConnectorRpcLocal_1 = require("./WebrtcConnectorRpcLocal");
|
|
36
|
+
const identifiers_1 = require("../../identifiers");
|
|
37
|
+
const offering_1 = require("../../helpers/offering");
|
|
38
38
|
const logger = new utils_1.Logger(module);
|
|
39
39
|
const replaceInternalIpWithExternalIp = (candidate, ip) => {
|
|
40
40
|
const parsed = candidate.split(' ');
|
|
@@ -46,18 +46,22 @@ const replaceInternalIpWithExternalIp = (candidate, ip) => {
|
|
|
46
46
|
};
|
|
47
47
|
exports.replaceInternalIpWithExternalIp = replaceInternalIpWithExternalIp;
|
|
48
48
|
class WebrtcConnector {
|
|
49
|
+
static WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector';
|
|
50
|
+
rpcCommunicator;
|
|
51
|
+
ongoingConnectAttempts = new Map();
|
|
52
|
+
localPeerDescriptor;
|
|
53
|
+
stopped = false;
|
|
54
|
+
config;
|
|
49
55
|
constructor(config, onNewConnection) {
|
|
50
|
-
this.ongoingConnectAttempts = new Map();
|
|
51
|
-
this.stopped = false;
|
|
52
56
|
this.config = config;
|
|
53
|
-
this.iceServers = config.iceServers ?? [];
|
|
54
57
|
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID, config.transport, {
|
|
55
|
-
rpcRequestTimeout: 15000
|
|
58
|
+
rpcRequestTimeout: 15000 // TODO use config option or named constant?
|
|
56
59
|
});
|
|
57
60
|
this.registerLocalRpcMethods(config, onNewConnection);
|
|
58
61
|
}
|
|
59
62
|
registerLocalRpcMethods(config, onNewConnection) {
|
|
60
63
|
const localRpc = new WebrtcConnectorRpcLocal_1.WebrtcConnectorRpcLocal({
|
|
64
|
+
createConnection: (targetPeerDescriptor) => this.createConnection(targetPeerDescriptor),
|
|
61
65
|
connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
62
66
|
onNewConnection,
|
|
63
67
|
ongoingConnectAttempts: this.ongoingConnectAttempts,
|
|
@@ -99,24 +103,19 @@ class WebrtcConnector {
|
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
105
|
connect(targetPeerDescriptor) {
|
|
102
|
-
if ((0,
|
|
106
|
+
if ((0, identifiers_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.localPeerDescriptor)) {
|
|
103
107
|
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self');
|
|
104
108
|
}
|
|
105
|
-
logger.trace(`Opening WebRTC connection to ${(0,
|
|
106
|
-
const
|
|
107
|
-
const existingConnection = this.ongoingConnectAttempts.get(
|
|
109
|
+
logger.trace(`Opening WebRTC connection to ${(0, identifiers_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor)}`);
|
|
110
|
+
const nodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
111
|
+
const existingConnection = this.ongoingConnectAttempts.get(nodeId);
|
|
108
112
|
if (existingConnection) {
|
|
109
113
|
return existingConnection;
|
|
110
114
|
}
|
|
111
|
-
const connection =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
116
|
-
connectingTimeout: this.config.connectionTimeout,
|
|
117
|
-
portRange: this.config.portRange
|
|
118
|
-
});
|
|
119
|
-
const offering = this.isOffering(targetPeerDescriptor);
|
|
115
|
+
const connection = this.createConnection(targetPeerDescriptor);
|
|
116
|
+
const localNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor);
|
|
117
|
+
const targetNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
118
|
+
const offering = ((0, offering_1.getOfferer)(localNodeId, targetNodeId) === 'local');
|
|
120
119
|
let managedConnection;
|
|
121
120
|
if (offering) {
|
|
122
121
|
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.localPeerDescriptor, connection);
|
|
@@ -125,30 +124,30 @@ class WebrtcConnector {
|
|
|
125
124
|
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.localPeerDescriptor, undefined, connection);
|
|
126
125
|
}
|
|
127
126
|
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
128
|
-
this.ongoingConnectAttempts.set(
|
|
127
|
+
this.ongoingConnectAttempts.set(targetNodeId, managedConnection);
|
|
129
128
|
const delFunc = () => {
|
|
130
|
-
this.ongoingConnectAttempts.delete(
|
|
129
|
+
this.ongoingConnectAttempts.delete(nodeId);
|
|
131
130
|
connection.off('disconnected', delFunc);
|
|
132
131
|
managedConnection.off('handshakeCompleted', delFunc);
|
|
133
132
|
};
|
|
134
133
|
connection.on('disconnected', delFunc);
|
|
135
134
|
managedConnection.on('handshakeCompleted', delFunc);
|
|
136
|
-
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.localPeerDescriptor, targetPeerDescriptor,
|
|
135
|
+
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.localPeerDescriptor, targetPeerDescriptor, this.rpcCommunicator, DhtRpc_client_1.WebrtcConnectorRpcClient);
|
|
137
136
|
connection.on('localCandidate', (candidate, mid) => {
|
|
138
|
-
if (this.config.externalIp) {
|
|
137
|
+
if (this.config.externalIp !== undefined) {
|
|
139
138
|
candidate = (0, exports.replaceInternalIpWithExternalIp)(candidate, this.config.externalIp);
|
|
140
139
|
logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`);
|
|
141
140
|
}
|
|
142
|
-
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId
|
|
141
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId);
|
|
143
142
|
});
|
|
144
143
|
if (offering) {
|
|
145
144
|
connection.once('localDescription', (description) => {
|
|
146
|
-
remoteConnector.sendRtcOffer(description, connection.connectionId
|
|
145
|
+
remoteConnector.sendRtcOffer(description, connection.connectionId);
|
|
147
146
|
});
|
|
148
147
|
}
|
|
149
148
|
else {
|
|
150
149
|
connection.once('localDescription', (description) => {
|
|
151
|
-
remoteConnector.sendRtcAnswer(description, connection.connectionId
|
|
150
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId);
|
|
152
151
|
});
|
|
153
152
|
}
|
|
154
153
|
connection.start(offering);
|
|
@@ -157,6 +156,17 @@ class WebrtcConnector {
|
|
|
157
156
|
}
|
|
158
157
|
return managedConnection;
|
|
159
158
|
}
|
|
159
|
+
createConnection(targetPeerDescriptor) {
|
|
160
|
+
return new NodeWebrtcConnection_1.NodeWebrtcConnection({
|
|
161
|
+
remotePeerDescriptor: targetPeerDescriptor,
|
|
162
|
+
iceServers: this.config.iceServers,
|
|
163
|
+
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
164
|
+
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
165
|
+
connectingTimeout: this.config.connectionTimeout,
|
|
166
|
+
portRange: this.config.portRange
|
|
167
|
+
// TODO should we pass maxMessageSize?
|
|
168
|
+
});
|
|
169
|
+
}
|
|
160
170
|
setLocalPeerDescriptor(peerDescriptor) {
|
|
161
171
|
this.localPeerDescriptor = peerDescriptor;
|
|
162
172
|
}
|
|
@@ -167,12 +177,6 @@ class WebrtcConnector {
|
|
|
167
177
|
await Promise.allSettled(attempts.map((conn) => conn.close(false)));
|
|
168
178
|
this.rpcCommunicator.destroy();
|
|
169
179
|
}
|
|
170
|
-
isOffering(targetPeerDescriptor) {
|
|
171
|
-
const myId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(this.localPeerDescriptor);
|
|
172
|
-
const theirId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
173
|
-
return myId.hasSmallerHashThan(theirId);
|
|
174
|
-
}
|
|
175
180
|
}
|
|
176
181
|
exports.WebrtcConnector = WebrtcConnector;
|
|
177
|
-
WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector';
|
|
178
182
|
//# sourceMappingURL=WebrtcConnector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnector.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAK+C;AAE/C,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,iFAAwF;
|
|
1
|
+
{"version":3,"file":"WebrtcConnector.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAK+C;AAE/C,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,iFAAwF;AACxF,wEAAoE;AACpE,0CAAuC;AACvC,0DAA2C;AAI3C,uEAAmE;AACnE,mDAAoG;AACpG,qDAAmD;AAEnD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,+BAA+B,GAAG,CAAC,SAAiB,EAAE,EAAU,EAA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CAAC,CAAC,CAAC,CAAA;QAEnE,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;;AAvKL,0CAwKC"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
2
|
-
import { PeerIDKey } from '../../helpers/PeerID';
|
|
3
2
|
import { Empty } from '../../proto/google/protobuf/empty';
|
|
4
3
|
import { IceCandidate, PeerDescriptor, RtcAnswer, RtcOffer } from '../../proto/packages/dht/protos/DhtRpc';
|
|
5
4
|
import { IWebrtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
6
5
|
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator';
|
|
7
6
|
import { ManagedConnection } from '../ManagedConnection';
|
|
8
7
|
import { ManagedWebrtcConnection } from '../ManagedWebrtcConnection';
|
|
8
|
+
import { NodeWebrtcConnection } from './NodeWebrtcConnection';
|
|
9
|
+
import { DhtAddress } from '../../identifiers';
|
|
9
10
|
interface WebrtcConnectorRpcLocalConfig {
|
|
11
|
+
createConnection: (targetPeerDescriptor: PeerDescriptor) => NodeWebrtcConnection;
|
|
10
12
|
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
11
13
|
onNewConnection: (connection: ManagedConnection) => boolean;
|
|
12
|
-
ongoingConnectAttempts: Map<
|
|
14
|
+
ongoingConnectAttempts: Map<DhtAddress, ManagedWebrtcConnection>;
|
|
13
15
|
rpcCommunicator: ListeningRpcCommunicator;
|
|
14
16
|
getLocalPeerDescriptor: () => PeerDescriptor;
|
|
15
17
|
allowPrivateAddresses: boolean;
|
|
@@ -1,22 +1,23 @@
|
|
|
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
|
-
const
|
|
6
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
8
7
|
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
9
8
|
const ManagedWebrtcConnection_1 = require("../ManagedWebrtcConnection");
|
|
10
|
-
const NodeWebrtcConnection_1 = require("./NodeWebrtcConnection");
|
|
11
9
|
const WebrtcConnectorRpcRemote_1 = require("./WebrtcConnectorRpcRemote");
|
|
10
|
+
const identifiers_1 = require("../../identifiers");
|
|
11
|
+
const version_1 = require("../../helpers/version");
|
|
12
12
|
const logger = new utils_1.Logger(module);
|
|
13
13
|
class WebrtcConnectorRpcLocal {
|
|
14
|
+
config;
|
|
14
15
|
constructor(config) {
|
|
15
16
|
this.config = config;
|
|
16
17
|
}
|
|
17
18
|
async requestConnection(context) {
|
|
18
19
|
const targetPeerDescriptor = context.incomingSourceDescriptor;
|
|
19
|
-
if (this.config.ongoingConnectAttempts.has((0,
|
|
20
|
+
if (this.config.ongoingConnectAttempts.has((0, identifiers_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor))) {
|
|
20
21
|
return {};
|
|
21
22
|
}
|
|
22
23
|
const managedConnection = this.config.connect(targetPeerDescriptor);
|
|
@@ -26,43 +27,48 @@ class WebrtcConnectorRpcLocal {
|
|
|
26
27
|
}
|
|
27
28
|
async rtcOffer(request, context) {
|
|
28
29
|
const remotePeer = context.incomingSourceDescriptor;
|
|
29
|
-
const
|
|
30
|
-
let managedConnection = this.config.ongoingConnectAttempts.get(
|
|
30
|
+
const nodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(remotePeer);
|
|
31
|
+
let managedConnection = this.config.ongoingConnectAttempts.get(nodeId);
|
|
31
32
|
let connection = managedConnection?.getWebrtcConnection();
|
|
32
33
|
if (!managedConnection) {
|
|
33
|
-
connection =
|
|
34
|
+
connection = this.config.createConnection(remotePeer);
|
|
34
35
|
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection);
|
|
35
36
|
managedConnection.setRemotePeerDescriptor(remotePeer);
|
|
36
|
-
this.config.ongoingConnectAttempts.set(
|
|
37
|
+
this.config.ongoingConnectAttempts.set(nodeId, managedConnection);
|
|
37
38
|
this.config.onNewConnection(managedConnection);
|
|
38
|
-
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.config.getLocalPeerDescriptor(), remotePeer,
|
|
39
|
+
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.config.getLocalPeerDescriptor(), remotePeer, this.config.rpcCommunicator, DhtRpc_client_1.WebrtcConnectorRpcClient);
|
|
39
40
|
connection.on('localCandidate', (candidate, mid) => {
|
|
40
|
-
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId
|
|
41
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId);
|
|
41
42
|
});
|
|
42
43
|
connection.once('localDescription', (description) => {
|
|
43
|
-
remoteConnector.sendRtcAnswer(description, connection.connectionId
|
|
44
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId);
|
|
44
45
|
});
|
|
45
46
|
connection.start(false);
|
|
46
47
|
}
|
|
47
48
|
// Always use offerers connectionId
|
|
48
49
|
connection.setConnectionId(request.connectionId);
|
|
49
50
|
connection.setRemoteDescription(request.description, 'offer');
|
|
50
|
-
managedConnection.on('handshakeRequest', () => {
|
|
51
|
-
if (this.config.ongoingConnectAttempts.has(
|
|
52
|
-
this.config.ongoingConnectAttempts.delete(
|
|
51
|
+
managedConnection.on('handshakeRequest', (_sourceDescriptor, remoteVersion) => {
|
|
52
|
+
if (this.config.ongoingConnectAttempts.has(nodeId)) {
|
|
53
|
+
this.config.ongoingConnectAttempts.delete(nodeId);
|
|
54
|
+
}
|
|
55
|
+
if (!(0, version_1.isMaybeSupportedVersion)(remoteVersion)) {
|
|
56
|
+
managedConnection.rejectHandshake(DhtRpc_1.HandshakeError.UNSUPPORTED_VERSION);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
managedConnection.acceptHandshake();
|
|
53
60
|
}
|
|
54
|
-
managedConnection.acceptHandshake();
|
|
55
61
|
});
|
|
56
62
|
return {};
|
|
57
63
|
}
|
|
58
64
|
async rtcAnswer(request, context) {
|
|
59
65
|
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
60
|
-
const
|
|
61
|
-
const connection = this.config.ongoingConnectAttempts.get(
|
|
66
|
+
const nodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(remotePeerDescriptor);
|
|
67
|
+
const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection();
|
|
62
68
|
if (!connection) {
|
|
63
69
|
return {};
|
|
64
70
|
}
|
|
65
|
-
else if (connection.connectionId
|
|
71
|
+
else if (connection.connectionId !== request.connectionId) {
|
|
66
72
|
logger.trace(`Ignoring RTC answer due to connectionId mismatch`);
|
|
67
73
|
return {};
|
|
68
74
|
}
|
|
@@ -71,12 +77,12 @@ class WebrtcConnectorRpcLocal {
|
|
|
71
77
|
}
|
|
72
78
|
async iceCandidate(request, context) {
|
|
73
79
|
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
74
|
-
const
|
|
75
|
-
const connection = this.config.ongoingConnectAttempts.get(
|
|
80
|
+
const nodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(remotePeerDescriptor);
|
|
81
|
+
const connection = this.config.ongoingConnectAttempts.get(nodeId)?.getWebrtcConnection();
|
|
76
82
|
if (!connection) {
|
|
77
83
|
return {};
|
|
78
84
|
}
|
|
79
|
-
else if (connection.connectionId
|
|
85
|
+
else if (connection.connectionId !== request.connectionId) {
|
|
80
86
|
logger.trace(`Ignoring remote candidate due to connectionId mismatch`);
|
|
81
87
|
return {};
|
|
82
88
|
}
|
|
@@ -88,7 +94,7 @@ class WebrtcConnectorRpcLocal {
|
|
|
88
94
|
isIceCandidateAllowed(candidate) {
|
|
89
95
|
if (!this.config.allowPrivateAddresses) {
|
|
90
96
|
const address = (0, AddressTools_1.getAddressFromIceCandidate)(candidate);
|
|
91
|
-
if (address && (0, AddressTools_1.isPrivateIPv4)(address)) {
|
|
97
|
+
if ((address !== undefined) && (0, AddressTools_1.isPrivateIPv4)(address)) {
|
|
92
98
|
return false;
|
|
93
99
|
}
|
|
94
100
|
}
|
|
@@ -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;AAEtF,mEAM+C;AAC/C,iFAAwF;AAKxF,wEAAoE;AAEpE,yEAAqE;AACrE,mDAA2E;AAC3E,mDAA+D;AAG/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAajC,MAAa,uBAAuB;IAEf,MAAM,CAA+B;IAEtD,YAAY,MAAqC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAA0B;QAC9C,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAA,yCAA2B,EAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC;YAC5F,OAAO,EAAE,CAAA;QACb,CAAC;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;QACnE,iBAAiB,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;QAC/D,IAAI,CAAC,MAAM,CAAC,eAAe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QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AArGD,0DAqGC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
5
|
-
export declare class WebrtcConnectorRpcRemote extends Remote<IWebrtcConnectorRpcClient> {
|
|
6
|
-
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebrtcConnectorRpcClient>);
|
|
1
|
+
import { RpcRemote } from '../../dht/contact/RpcRemote';
|
|
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 Remote_1 = require("../../dht/contact/Remote");
|
|
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
|
-
class WebrtcConnectorRpcRemote extends
|
|
8
|
-
constructor(localPeerDescriptor, remotePeerDescriptor, client) {
|
|
9
|
-
super(localPeerDescriptor, remotePeerDescriptor, 'DUMMY', client);
|
|
10
|
-
}
|
|
7
|
+
class WebrtcConnectorRpcRemote extends RpcRemote_1.RpcRemote {
|
|
11
8
|
requestConnection() {
|
|
12
9
|
const request = {};
|
|
13
10
|
const options = this.formDhtRpcOptions({
|