@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.4
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 +7 -8
- package/dist/src/connection/ConnectionLockHandler.js +16 -14
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js +9 -9
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +9 -16
- package/dist/src/connection/ConnectionManager.js +101 -132
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -10
- package/dist/src/connection/ConnectivityChecker.js +30 -32
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +19 -13
- package/dist/src/connection/ConnectorFacade.js +74 -29
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +8 -8
- package/dist/src/connection/Handshaker.js +30 -33
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +5 -6
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +9 -13
- package/dist/src/connection/ManagedConnection.js +63 -99
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
- package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +25 -24
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +3 -3
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +17 -18
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
- package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
- package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
- package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +41 -42
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
- package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
- package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +23 -16
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
- package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +25 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +53 -0
- package/dist/src/connection/websocket/WebsocketConnector.js +242 -0
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +6 -11
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
- package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +11 -19
- package/dist/src/dht/DhtNode.js +135 -163
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
- package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
- package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
- package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +20 -24
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
- package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/contact/Remote.d.ts +4 -1
- package/dist/src/dht/contact/Remote.js +28 -2
- package/dist/src/dht/contact/Remote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
- package/dist/src/dht/contact/SortedContactList.js +3 -3
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -9
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
- package/dist/src/dht/discovery/PeerDiscovery.js +6 -6
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
- package/dist/src/dht/find/FindRpcLocal.js +25 -0
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
- package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +17 -15
- package/dist/src/dht/find/FindSession.js.map +1 -0
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
- package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
- package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +50 -46
- package/dist/src/dht/find/Finder.js.map +1 -0
- package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
- package/dist/src/dht/routing/FindRpcRemote.js +41 -0
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +10 -17
- package/dist/src/dht/routing/Router.js +50 -93
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
- package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +17 -45
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
- package/dist/src/dht/routing/RoutingSession.js +124 -131
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
- package/dist/src/dht/routing/getPreviousPeer.js +9 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
- package/dist/src/dht/store/StoreRpcLocal.js +26 -25
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +6 -10
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +11 -5
- package/dist/src/exports.js +17 -4
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +4 -0
- package/dist/src/helpers/Connectivity.js +24 -0
- package/dist/src/helpers/Connectivity.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +3 -3
- package/dist/src/helpers/errors.js +7 -7
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +7 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +85 -96
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +82 -71
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/transport/ITransport.d.ts +5 -6
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -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 +0 -1
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/dist/src/types/ServiceID.d.ts +1 -0
- package/dist/src/types/ServiceID.js +3 -0
- package/dist/src/types/ServiceID.js.map +1 -0
- package/karma.config.js +4 -4
- package/package.json +10 -8
- package/protos/DhtRpc.proto +41 -40
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +11 -11
- package/src/connection/ConnectionManager.ts +88 -130
- package/src/connection/ConnectivityChecker.ts +36 -34
- package/src/connection/ConnectorFacade.ts +91 -40
- package/src/connection/Handshaker.ts +20 -23
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +76 -101
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +12 -10
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +27 -27
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +22 -23
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +13 -14
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +38 -40
- package/src/connection/webrtc/WebrtcConnector.ts +226 -0
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
- package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
- package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
- package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +22 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +23 -27
- package/src/connection/websocket/WebsocketConnector.ts +328 -0
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +8 -14
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +166 -193
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +17 -18
- package/src/dht/ExternalApiRpcLocal.ts +46 -0
- package/src/dht/ExternalApiRpcRemote.ts +4 -4
- package/src/dht/contact/Remote.ts +32 -4
- package/src/dht/contact/SortedContactList.ts +4 -4
- package/src/dht/discovery/DiscoverySession.ts +25 -22
- package/src/dht/discovery/PeerDiscovery.ts +16 -19
- package/src/dht/find/FindRpcLocal.ts +35 -0
- package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
- package/src/dht/find/FindSessionRpcLocal.ts +25 -0
- package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
- package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
- package/src/dht/routing/FindRpcRemote.ts +40 -0
- package/src/dht/routing/Router.ts +78 -109
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +18 -49
- package/src/dht/routing/RoutingSession.ts +58 -63
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +46 -39
- package/src/dht/store/StoreRpcRemote.ts +8 -12
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- package/src/helpers/peerIdFromPeerDescriptor.ts +6 -0
- package/src/helpers/protoClasses.ts +6 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
- package/src/proto/packages/dht/protos/DhtRpc.ts +112 -131
- package/src/rpc-protocol/DhtCallContext.ts +0 -1
- package/src/transport/ITransport.ts +5 -8
- package/src/transport/ListeningRpcCommunicator.ts +2 -1
- package/src/transport/RoutingRpcCommunicator.ts +3 -4
- package/src/types/ServiceID.ts +1 -0
- package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +7 -7
- package/test/benchmark/KademliaCorrectness.test.ts +3 -3
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
- package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
- package/test/end-to-end/Layer0.test.ts +35 -17
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +28 -9
- package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
- package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
- package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
- package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
- package/test/end-to-end/memory-leak.test.ts +85 -0
- package/test/integration/ConnectionLocking.test.ts +10 -7
- package/test/integration/ConnectionManager.test.ts +107 -30
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
- package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
- package/test/integration/DhtRpc.test.ts +5 -5
- package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +6 -9
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +8 -7
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +8 -8
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +6 -6
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +4 -7
- package/test/integration/StoreAndDelete.test.ts +4 -7
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +5 -5
- package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
- package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
- package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
- package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
- package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
- package/test/unit/ConnectivityHelpers.test.ts +69 -0
- package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
- package/test/unit/Router.test.ts +26 -26
- package/test/unit/UUID.test.ts +1 -1
- package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
- package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
- package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
- package/test/utils/FakeRpcCommunicator.ts +23 -0
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/utils.ts +22 -26
- package/tsconfig.browser.json +1 -1
- package/tsconfig.jest.json +3 -2
- package/tsconfig.node.json +3 -2
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
- package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
- package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.d.ts +0 -45
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js +0 -234
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
- package/dist/src/dht/RemoteDhtNode.js.map +0 -1
- package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
- package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
- package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
- package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
- package/src/connection/WebSocket/WebSocketConnectorRpcLocal.ts +0 -295
- package/src/dht/registerExternalApiRpcMethods.ts +0 -44
- package/test/utils/mock/RecursiveFinder.ts +0 -19
- /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
- /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
- /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PeerIDKey } from '../helpers/PeerID';
|
|
2
|
-
type
|
|
2
|
+
export type LockID = string;
|
|
3
3
|
export declare class ConnectionLockHandler {
|
|
4
4
|
private localLocks;
|
|
5
5
|
private remoteLocks;
|
|
@@ -7,17 +7,16 @@ export declare class ConnectionLockHandler {
|
|
|
7
7
|
getNumberOfLocalLockedConnections(): number;
|
|
8
8
|
getNumberOfRemoteLockedConnections(): number;
|
|
9
9
|
getNumberOfWeakLockedConnections(): number;
|
|
10
|
-
isLocalLocked(id: PeerIDKey,
|
|
11
|
-
isRemoteLocked(id: PeerIDKey,
|
|
10
|
+
isLocalLocked(id: PeerIDKey, lockId?: LockID): boolean;
|
|
11
|
+
isRemoteLocked(id: PeerIDKey, lockId?: LockID): boolean;
|
|
12
12
|
private isWeakLocked;
|
|
13
13
|
isLocked(id: PeerIDKey): boolean;
|
|
14
|
-
addLocalLocked(id: PeerIDKey,
|
|
15
|
-
addRemoteLocked(id: PeerIDKey,
|
|
14
|
+
addLocalLocked(id: PeerIDKey, lockId: LockID): void;
|
|
15
|
+
addRemoteLocked(id: PeerIDKey, lockId: LockID): void;
|
|
16
16
|
addWeakLocked(id: PeerIDKey): void;
|
|
17
|
-
removeLocalLocked(id: PeerIDKey,
|
|
18
|
-
removeRemoteLocked(id: PeerIDKey,
|
|
17
|
+
removeLocalLocked(id: PeerIDKey, lockId: LockID): void;
|
|
18
|
+
removeRemoteLocked(id: PeerIDKey, lockId: LockID): void;
|
|
19
19
|
removeWeakLocked(id: PeerIDKey): void;
|
|
20
20
|
clearAllLocks(id: PeerIDKey): void;
|
|
21
21
|
clear(): void;
|
|
22
22
|
}
|
|
23
|
-
export {};
|
|
@@ -7,6 +7,8 @@ class ConnectionLockHandler {
|
|
|
7
7
|
constructor() {
|
|
8
8
|
this.localLocks = new Map();
|
|
9
9
|
this.remoteLocks = new Map();
|
|
10
|
+
// TODO: remove weakLocks use localLocks instead. When opening weakLocks from the ConnectioManager,
|
|
11
|
+
// simply do not send lock requests.
|
|
10
12
|
this.weakLocks = new Set();
|
|
11
13
|
}
|
|
12
14
|
getNumberOfLocalLockedConnections() {
|
|
@@ -18,20 +20,20 @@ class ConnectionLockHandler {
|
|
|
18
20
|
getNumberOfWeakLockedConnections() {
|
|
19
21
|
return this.weakLocks.size;
|
|
20
22
|
}
|
|
21
|
-
isLocalLocked(id,
|
|
22
|
-
if (!
|
|
23
|
+
isLocalLocked(id, lockId) {
|
|
24
|
+
if (!lockId) {
|
|
23
25
|
return this.localLocks.has(id);
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
|
-
return this.localLocks.has(id) && this.localLocks.get(id).has(
|
|
28
|
+
return this.localLocks.has(id) && this.localLocks.get(id).has(lockId);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
isRemoteLocked(id,
|
|
30
|
-
if (!
|
|
31
|
+
isRemoteLocked(id, lockId) {
|
|
32
|
+
if (!lockId) {
|
|
31
33
|
return this.remoteLocks.has(id);
|
|
32
34
|
}
|
|
33
35
|
else {
|
|
34
|
-
if (this.remoteLocks.has(id) && this.remoteLocks.get(id).has(
|
|
36
|
+
if (this.remoteLocks.has(id) && this.remoteLocks.get(id).has(lockId)) {
|
|
35
37
|
return true;
|
|
36
38
|
}
|
|
37
39
|
else {
|
|
@@ -45,32 +47,32 @@ class ConnectionLockHandler {
|
|
|
45
47
|
isLocked(id) {
|
|
46
48
|
return (this.isLocalLocked(id) || this.isRemoteLocked(id) || this.isWeakLocked(id));
|
|
47
49
|
}
|
|
48
|
-
addLocalLocked(id,
|
|
50
|
+
addLocalLocked(id, lockId) {
|
|
49
51
|
if (!this.localLocks.has(id)) {
|
|
50
52
|
this.localLocks.set(id, new Set());
|
|
51
53
|
}
|
|
52
|
-
this.localLocks.get(id).add(
|
|
54
|
+
this.localLocks.get(id).add(lockId);
|
|
53
55
|
}
|
|
54
|
-
addRemoteLocked(id,
|
|
56
|
+
addRemoteLocked(id, lockId) {
|
|
55
57
|
if (!this.remoteLocks.has(id)) {
|
|
56
58
|
this.remoteLocks.set(id, new Set());
|
|
57
59
|
}
|
|
58
|
-
this.remoteLocks.get(id).add(
|
|
60
|
+
this.remoteLocks.get(id).add(lockId);
|
|
59
61
|
}
|
|
60
62
|
addWeakLocked(id) {
|
|
61
63
|
this.weakLocks.add(id);
|
|
62
64
|
}
|
|
63
|
-
removeLocalLocked(id,
|
|
65
|
+
removeLocalLocked(id, lockId) {
|
|
64
66
|
if (this.localLocks.has(id)) {
|
|
65
|
-
this.localLocks.get(id)?.delete(
|
|
67
|
+
this.localLocks.get(id)?.delete(lockId);
|
|
66
68
|
if (this.localLocks.get(id)?.size === 0) {
|
|
67
69
|
this.localLocks.delete(id);
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
|
-
removeRemoteLocked(id,
|
|
73
|
+
removeRemoteLocked(id, lockId) {
|
|
72
74
|
if (this.remoteLocks.has(id)) {
|
|
73
|
-
this.remoteLocks.get(id)?.delete(
|
|
75
|
+
this.remoteLocks.get(id)?.delete(lockId);
|
|
74
76
|
if (this.remoteLocks.get(id)?.size === 0) {
|
|
75
77
|
this.remoteLocks.delete(id);
|
|
76
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionLockHandler.js","sourceRoot":"","sources":["../../../src/connection/ConnectionLockHandler.ts"],"names":[],"mappings":";AAAA,mEAAmE;AACnE,mCAAmC;;;AAMnC,MAAa,qBAAqB;IAAlC;QAEY,eAAU,
|
|
1
|
+
{"version":3,"file":"ConnectionLockHandler.js","sourceRoot":"","sources":["../../../src/connection/ConnectionLockHandler.ts"],"names":[],"mappings":";AAAA,mEAAmE;AACnE,mCAAmC;;;AAMnC,MAAa,qBAAqB;IAAlC;QAEY,eAAU,GAAgC,IAAI,GAAG,EAAE,CAAA;QACnD,gBAAW,GAAgC,IAAI,GAAG,EAAE,CAAA;QAC5D,mGAAmG;QACnG,oCAAoC;QAC5B,cAAS,GAAmB,IAAI,GAAG,EAAE,CAAA;IA6FjD,CAAC;IA3FU,iCAAiC;QACpC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,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AAE,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE;gBACtC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;aAC9B;SACJ;IACL,CAAC;IAEM,gBAAgB,CAAC,EAAa;QACjC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC7B,CAAC;IAEM,aAAa,CAAC,EAAa;QAC9B,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC7B,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;QACvB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;QACxB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC;CACJ;AAnGD,sDAmGC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
2
|
+
import { Empty } from '../proto/google/protobuf/empty';
|
|
3
|
+
import { DisconnectNotice, LockRequest, LockResponse, PeerDescriptor, UnlockRequest } from '../proto/packages/dht/protos/DhtRpc';
|
|
4
|
+
import { IConnectionLockRpc } from '../proto/packages/dht/protos/DhtRpc.server';
|
|
5
|
+
import { PeerIDKey } from '../helpers/PeerID';
|
|
6
|
+
import { LockID } from './ConnectionLockHandler';
|
|
7
|
+
interface ConnectionLockRpcLocalConfig {
|
|
8
|
+
addRemoteLocked: (id: PeerIDKey, lockId: LockID) => void;
|
|
9
|
+
removeRemoteLocked: (id: PeerIDKey, lockId: LockID) => void;
|
|
10
|
+
closeConnection: (peerDescriptor: PeerDescriptor, gracefulLeave: boolean, reason?: string) => void;
|
|
11
|
+
getLocalPeerDescriptor: () => PeerDescriptor;
|
|
12
|
+
}
|
|
13
|
+
export declare class ConnectionLockRpcLocal implements IConnectionLockRpc {
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(config: ConnectionLockRpcLocalConfig);
|
|
16
|
+
lockRequest(lockRequest: LockRequest, context: ServerCallContext): Promise<LockResponse>;
|
|
17
|
+
unlockRequest(unlockRequest: UnlockRequest, context: ServerCallContext): Promise<Empty>;
|
|
18
|
+
gracefulDisconnect(disconnectNotice: DisconnectNotice, context: ServerCallContext): Promise<Empty>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionLockRpcLocal = void 0;
|
|
4
|
+
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const peerIdFromPeerDescriptor_1 = require("../helpers/peerIdFromPeerDescriptor");
|
|
6
|
+
const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
|
|
7
|
+
const ConnectionManager_1 = require("./ConnectionManager");
|
|
8
|
+
const logger = new utils_1.Logger(module);
|
|
9
|
+
class ConnectionLockRpcLocal {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
async lockRequest(lockRequest, context) {
|
|
14
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
15
|
+
const remotePeerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(senderPeerDescriptor);
|
|
16
|
+
if ((0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(senderPeerDescriptor, this.config.getLocalPeerDescriptor())) {
|
|
17
|
+
const response = {
|
|
18
|
+
accepted: false
|
|
19
|
+
};
|
|
20
|
+
return response;
|
|
21
|
+
}
|
|
22
|
+
this.config.addRemoteLocked(remotePeerId.toKey(), lockRequest.lockId);
|
|
23
|
+
const response = {
|
|
24
|
+
accepted: true
|
|
25
|
+
};
|
|
26
|
+
return response;
|
|
27
|
+
}
|
|
28
|
+
async unlockRequest(unlockRequest, context) {
|
|
29
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
30
|
+
const peerIdKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(senderPeerDescriptor);
|
|
31
|
+
this.config.removeRemoteLocked(peerIdKey, unlockRequest.lockId);
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
async gracefulDisconnect(disconnectNotice, context) {
|
|
35
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
36
|
+
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(senderPeerDescriptor) + ' received gracefulDisconnect notice');
|
|
37
|
+
if (disconnectNotice.disconnectMode === DhtRpc_1.DisconnectMode.LEAVING) {
|
|
38
|
+
this.config.closeConnection(senderPeerDescriptor, true, 'graceful leave notified');
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
this.config.closeConnection(senderPeerDescriptor, false, 'graceful disconnect notified');
|
|
42
|
+
}
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.ConnectionLockRpcLocal = ConnectionLockRpcLocal;
|
|
47
|
+
//# sourceMappingURL=ConnectionLockRpcLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionLockRpcLocal.js","sourceRoot":"","sources":["../../../src/connection/ConnectionLockRpcLocal.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,kFAI4C;AAE5C,gEAO4C;AAI5C,2DAA0E;AAU1E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,sBAAsB;IAI/B,YAAY,MAAoC;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,WAAwB,EAAE,OAA0B;QAClE,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBA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AO,EAAE,CAAA;IACb,CAAC;CACJ;AA1CD,wDA0CC"}
|
|
@@ -2,9 +2,10 @@ import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
|
2
2
|
import { IConnectionLockRpcClient } from '../proto/packages/dht/protos/DhtRpc.client';
|
|
3
3
|
import { PeerDescriptor, DisconnectMode } from '../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import { Remote } from '../dht/contact/Remote';
|
|
5
|
+
import { LockID } from './ConnectionLockHandler';
|
|
5
6
|
export declare class ConnectionLockRpcRemote extends Remote<IConnectionLockRpcClient> {
|
|
6
|
-
constructor(
|
|
7
|
-
lockRequest(
|
|
8
|
-
unlockRequest(
|
|
7
|
+
constructor(localPeerDescriptor: PeerDescriptor, targetPeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IConnectionLockRpcClient>);
|
|
8
|
+
lockRequest(lockId: LockID): Promise<boolean>;
|
|
9
|
+
unlockRequest(lockId: LockID): void;
|
|
9
10
|
gracefulDisconnect(disconnectMode: DisconnectMode): Promise<void>;
|
|
10
11
|
}
|
|
@@ -30,13 +30,13 @@ const peerIdFromPeerDescriptor_1 = require("../helpers/peerIdFromPeerDescriptor"
|
|
|
30
30
|
const Remote_1 = require("../dht/contact/Remote");
|
|
31
31
|
const logger = new utils_1.Logger(module);
|
|
32
32
|
class ConnectionLockRpcRemote extends Remote_1.Remote {
|
|
33
|
-
constructor(
|
|
34
|
-
super(
|
|
33
|
+
constructor(localPeerDescriptor, targetPeerDescriptor, client) {
|
|
34
|
+
super(localPeerDescriptor, targetPeerDescriptor, 'DUMMY', client);
|
|
35
35
|
}
|
|
36
|
-
async lockRequest(
|
|
37
|
-
logger.trace(`Requesting locked connection to ${(0, peerIdFromPeerDescriptor_1.
|
|
36
|
+
async lockRequest(lockId) {
|
|
37
|
+
logger.trace(`Requesting locked connection to ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor())}`);
|
|
38
38
|
const request = {
|
|
39
|
-
|
|
39
|
+
lockId
|
|
40
40
|
};
|
|
41
41
|
const options = this.formDhtRpcOptions();
|
|
42
42
|
try {
|
|
@@ -48,10 +48,10 @@ class ConnectionLockRpcRemote extends Remote_1.Remote {
|
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
unlockRequest(
|
|
52
|
-
logger.trace(`Requesting connection to be unlocked from ${(0, peerIdFromPeerDescriptor_1.
|
|
51
|
+
unlockRequest(lockId) {
|
|
52
|
+
logger.trace(`Requesting connection to be unlocked from ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor())}`);
|
|
53
53
|
const request = {
|
|
54
|
-
|
|
54
|
+
lockId
|
|
55
55
|
};
|
|
56
56
|
const options = this.formDhtRpcOptions({
|
|
57
57
|
notification: true
|
|
@@ -61,7 +61,7 @@ class ConnectionLockRpcRemote extends Remote_1.Remote {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
async gracefulDisconnect(disconnectMode) {
|
|
64
|
-
logger.trace(`Notifying a graceful disconnect to ${(0, peerIdFromPeerDescriptor_1.
|
|
64
|
+
logger.trace(`Notifying a graceful disconnect to ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.getPeerDescriptor())}`);
|
|
65
65
|
const request = {
|
|
66
66
|
disconnectMode
|
|
67
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionLockRpcRemote.js","sourceRoot":"","sources":["../../../src/connection/ConnectionLockRpcRemote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;
|
|
1
|
+
{"version":3,"file":"ConnectionLockRpcRemote.js","sourceRoot":"","sources":["../../../src/connection/ConnectionLockRpcRemote.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAuC;AAIvC,uDAAwC;AACxC,kFAAiF;AACjF,kDAA8C;AAG9C,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BAA8B,CAAC,CAAA;QAChD,CAAC,CAAC,CAAA;IACN,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,cAA8B;QAC1D,MAAM,CAAC,KAAK,CAAC,sCAAsC,IAAA,sDAA2B,EAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAA;QAC3G,MAAM,OAAO,GAAqB;YAC9B,cAAc;SACjB,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACnC,YAAY,EAAE,IAAI;YAClB,gBAAgB,EAAE,IAAI;YACtB,OAAO,EAAE,IAAI;SAChB,CAAC,CAAA;QACF,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;CACJ;AAlDD,0DAkDC"}
|
|
@@ -2,6 +2,7 @@ import { MetricsContext } from '@streamr/utils';
|
|
|
2
2
|
import { EventEmitter } from 'eventemitter3';
|
|
3
3
|
import { Message, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import { ITransport, TransportEvents } from '../transport/ITransport';
|
|
5
|
+
import { LockID } from './ConnectionLockHandler';
|
|
5
6
|
import { ConnectorFacade } from './ConnectorFacade';
|
|
6
7
|
import { ManagedConnection } from './ManagedConnection';
|
|
7
8
|
export interface ConnectionManagerConfig {
|
|
@@ -14,9 +15,6 @@ export declare enum NatType {
|
|
|
14
15
|
UNKNOWN = "unknown"
|
|
15
16
|
}
|
|
16
17
|
type ServiceId = string;
|
|
17
|
-
interface ConnectionManagerEvents {
|
|
18
|
-
newConnection: (connection: ManagedConnection) => void;
|
|
19
|
-
}
|
|
20
18
|
export interface ConnectionLocker {
|
|
21
19
|
lockConnection(targetDescriptor: PeerDescriptor, serviceId: ServiceId): void;
|
|
22
20
|
unlockConnection(targetDescriptor: PeerDescriptor, serviceId: ServiceId): void;
|
|
@@ -31,9 +29,8 @@ export interface TlsCertificate {
|
|
|
31
29
|
privateKeyFileName: string;
|
|
32
30
|
certFileName: string;
|
|
33
31
|
}
|
|
34
|
-
export
|
|
35
|
-
export declare
|
|
36
|
-
export declare class ConnectionManager extends EventEmitter<Events> implements ITransport, ConnectionLocker {
|
|
32
|
+
export declare const getNodeIdOrUnknownFromPeerDescriptor: (peerDescriptor: PeerDescriptor | undefined) => string;
|
|
33
|
+
export declare class ConnectionManager extends EventEmitter<TransportEvents> implements ITransport, ConnectionLocker {
|
|
37
34
|
private config;
|
|
38
35
|
private readonly metricsContext;
|
|
39
36
|
private readonly duplicateMessageDetector;
|
|
@@ -53,10 +50,9 @@ export declare class ConnectionManager extends EventEmitter<Events> implements I
|
|
|
53
50
|
getNumberOfWeakLockedConnections(): number;
|
|
54
51
|
send(message: Message, doNotConnect?: boolean, doNotMindStopped?: boolean): Promise<void>;
|
|
55
52
|
private isConnectionToSelf;
|
|
56
|
-
private
|
|
53
|
+
private isOwnWebsocketServer;
|
|
57
54
|
getConnection(peerDescriptor: PeerDescriptor): ManagedConnection | undefined;
|
|
58
|
-
|
|
59
|
-
private getOwnPeerDescriptor;
|
|
55
|
+
getLocalPeerDescriptor(): PeerDescriptor;
|
|
60
56
|
hasConnection(peerDescriptor: PeerDescriptor): boolean;
|
|
61
57
|
hasLocalLockedConnection(peerDescriptor: PeerDescriptor): boolean;
|
|
62
58
|
hasRemoteLockedConnection(peerDescriptor: PeerDescriptor): boolean;
|
|
@@ -65,19 +61,16 @@ export declare class ConnectionManager extends EventEmitter<Events> implements I
|
|
|
65
61
|
private onData;
|
|
66
62
|
private onConnected;
|
|
67
63
|
private onDisconnected;
|
|
68
|
-
private
|
|
69
|
-
private
|
|
64
|
+
private onNewConnection;
|
|
65
|
+
private acceptNewConnection;
|
|
70
66
|
private closeConnection;
|
|
71
|
-
lockConnection(targetDescriptor: PeerDescriptor,
|
|
72
|
-
unlockConnection(targetDescriptor: PeerDescriptor,
|
|
67
|
+
lockConnection(targetDescriptor: PeerDescriptor, lockId: LockID): void;
|
|
68
|
+
unlockConnection(targetDescriptor: PeerDescriptor, lockId: LockID): void;
|
|
73
69
|
weakLockConnection(targetDescriptor: PeerDescriptor): void;
|
|
74
70
|
weakUnlockConnection(targetDescriptor: PeerDescriptor): void;
|
|
75
71
|
private gracefullyDisconnectAsync;
|
|
76
72
|
private doGracefullyDisconnectAsync;
|
|
77
73
|
getAllConnectionPeerDescriptors(): PeerDescriptor[];
|
|
78
|
-
private lockRequest;
|
|
79
|
-
private unlockRequest;
|
|
80
|
-
private gracefulDisconnect;
|
|
81
74
|
private onConnectionCountChange;
|
|
82
75
|
}
|
|
83
76
|
export {};
|