@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.3
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 +6 -6
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +5 -8
- package/dist/src/connection/ConnectionManager.js +77 -107
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -6
- package/dist/src/connection/ConnectivityChecker.js +23 -20
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +15 -12
- package/dist/src/connection/ConnectorFacade.js +61 -26
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +2 -2
- package/dist/src/connection/Handshaker.js +28 -28
- 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 +3 -4
- package/dist/src/connection/ManagedConnection.js +30 -30
- 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 +22 -22
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +2 -2
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +11 -11
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js.map +1 -1
- 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} +36 -36
- 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} +20 -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} +23 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.d.ts → websocket/WebsocketConnector.d.ts} +23 -15
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcLocal.js → websocket/WebsocketConnector.js} +107 -101
- 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} +5 -10
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js.map → websocket/WebsocketConnectorRpcRemote.js.map} +1 -1
- 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 +119 -150
- 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} +17 -21
- 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 +8 -8
- 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 +5 -5
- 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 +47 -90
- 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 +15 -43
- 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 +25 -24
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +3 -7
- 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/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 +64 -84
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +64 -66
- 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 +32 -35
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +7 -6
- package/src/connection/ConnectionManager.ts +59 -95
- package/src/connection/ConnectivityChecker.ts +30 -26
- package/src/connection/ConnectorFacade.ts +74 -34
- package/src/connection/Handshaker.ts +9 -9
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +21 -22
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +9 -9
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +23 -24
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +13 -13
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +12 -13
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +32 -33
- package/src/connection/webrtc/WebrtcConnector.ts +225 -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} +19 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +21 -27
- package/src/connection/{WebSocket/WebSocketConnectorRpcLocal.ts → websocket/WebsocketConnector.ts} +109 -100
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +6 -12
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +144 -179
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +12 -13
- 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 +23 -20
- package/src/dht/discovery/PeerDiscovery.ts +14 -17
- 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 +69 -105
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +15 -45
- package/src/dht/routing/RoutingSession.ts +56 -61
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +44 -37
- package/src/dht/store/StoreRpcRemote.ts +4 -8
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- 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 +87 -114
- 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} +6 -6
- package/test/benchmark/KademliaCorrectness.test.ts +2 -2
- 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 +24 -6
- 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 +4 -4
- package/test/integration/ConnectionManager.test.ts +37 -28
- 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} +3 -3
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +6 -5
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +6 -6
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +3 -3
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +1 -1
- package/test/integration/StoreAndDelete.test.ts +1 -1
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +4 -4
- 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 +14 -24
- 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/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.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/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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ManagedWebrtcConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedWebrtcConnection.ts"],"names":[],"mappings":";;;AACA,+CAA8C;AAC9C,2DAAuD;AAGvD,MAAa,uBAAwB,SAAQ,qCAAiB;IAE1D,YAAY,mBAAmC,EAC3C,oBAA2C,EAC3C,mBAA0C;QAC1C,KAAK,CACD,mBAAmB,EACnB,4BAAc,CAAC,MAAM,EACrB,oBAAoB,EACpB,mBAAmB,CAAC,CAAA;IAC5B,CAAC;IAEM,mBAAmB;QACtB,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,OAAO,IAAI,CAAC,kBAAqD,CAAA;SACpE;aAAM;YACH,OAAO,IAAI,CAAC,kBAAqD,CAAA;SACpE;IACL,CAAC;CACJ;AAnBD,0DAmBC"}
|
|
@@ -279,7 +279,7 @@ class Simulator extends eventemitter3_1.default {
|
|
|
279
279
|
debugHelpers_1.debugVars['simulatorHeapSize'] = this.operationQueue.size();
|
|
280
280
|
const association = new Association(sourceConnection, undefined, connectedCallback);
|
|
281
281
|
this.associations.set(sourceConnection.connectionId, association);
|
|
282
|
-
const executionTime = this.generateExecutionTime(association, sourceConnection.
|
|
282
|
+
const executionTime = this.generateExecutionTime(association, sourceConnection.localPeerDescriptor.region, targetDescriptor.region);
|
|
283
283
|
association.setLastOperationAt(executionTime);
|
|
284
284
|
const operation = new ConnectOperation(executionTime, association, sourceConnection, targetDescriptor);
|
|
285
285
|
this.scheduleOperation(operation);
|
|
@@ -293,7 +293,7 @@ class Simulator extends eventemitter3_1.default {
|
|
|
293
293
|
return;
|
|
294
294
|
}
|
|
295
295
|
association.setClosing();
|
|
296
|
-
const executionTime = this.generateExecutionTime(association, sourceConnection.
|
|
296
|
+
const executionTime = this.generateExecutionTime(association, sourceConnection.localPeerDescriptor.region, sourceConnection.getPeerDescriptor()?.region);
|
|
297
297
|
association.setLastOperationAt(executionTime);
|
|
298
298
|
const operation = new CloseOperation(executionTime, association);
|
|
299
299
|
this.scheduleOperation(operation);
|
|
@@ -310,7 +310,7 @@ class Simulator extends eventemitter3_1.default {
|
|
|
310
310
|
logger.trace('Tried to call send() on a closing association');
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
|
-
const executionTime = this.generateExecutionTime(association, sourceConnection.
|
|
313
|
+
const executionTime = this.generateExecutionTime(association, sourceConnection.localPeerDescriptor.region, association.destinationConnection.localPeerDescriptor.region);
|
|
314
314
|
association.setLastOperationAt(executionTime);
|
|
315
315
|
const operation = new SendOperation(executionTime, association, data);
|
|
316
316
|
this.scheduleOperation(operation);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Simulator.js","sourceRoot":"","sources":["../../../../src/connection/
|
|
1
|
+
{"version":3,"file":"Simulator.js","sourceRoot":"","sources":["../../../../src/connection/simulator/Simulator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,kEAAwC;AAOxC,0CAAuC;AACvC,mCAA8C;AAC9C,qFAA8E;AAC9E,gDAAuB;AACvB,6DAAsD;AACtD,6CAA8B;AAM9B,SAAgB,mBAAmB;IAC/B,gDAAgD;IAChD,OAAO,OAAO,sBAAsB,KAAK,WAAW,CAAA;AACxD,CAAC;AAHD,kDAGC;AAED,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,IAAY,WAAgF;AAA5F,WAAY,WAAW;IAAG,4BAAa,CAAA;IAAE,gCAAiB,CAAA;IAAE,4BAAa,CAAA;IAAE,8BAAe,CAAA;AAAC,CAAC,EAAhF,WAAW,2BAAX,WAAW,QAAqE;AAE5F,6BAA6B;AAE7B,MAAM,WAAW;IAMb,YAAY,gBAAqC,EAC7C,qBAA2C,EACpC,iBAA4C;QAA5C,sBAAiB,GAAjB,iBAAiB,CAA2B;QAL/C,oBAAe,GAAW,CAAC,CAAA;QAC3B,YAAO,GAAG,KAAK,CAAA;QAMnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAA;IACtD,CAAC;IAEM,wBAAwB,CAAC,UAA+B;QAC3D,IAAI,CAAC,qBAAqB,GAAG,UAAU,CAAA;IAC3C,CAAC;IAEM,kBAAkB;QACrB,OAAO,IAAI,CAAC,eAAe,CAAA;IAC/B,CAAC;IAEM,kBAAkB,CAAC,aAAqB;QAC3C,IAAI,CAAC,eAAe,GAAG,aAAa,CAAA;IACxC,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,OA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,WAAW,EACxD,gBAAgB,CAAC,mBAAmB,CAAC,MAAM,EAC3C,WAAW,CAAC,qBAAsB,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;QAElE,WAAW,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;QAE7C,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;QAErE,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,GAAG,0CAA0C,CAAC,CAAA;QAEhF,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;SACtC;IACL,CAAC;CACJ;AA5SD,8BA4SC"}
|
|
@@ -2,15 +2,14 @@ import { ConnectionType, IConnection } from '../IConnection';
|
|
|
2
2
|
import { Simulator } from './Simulator';
|
|
3
3
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import { Connection } from '../Connection';
|
|
5
|
-
import { DisconnectionType } from '../../transport/ITransport';
|
|
6
5
|
export declare class SimulatorConnection extends Connection implements IConnection {
|
|
7
6
|
private stopped;
|
|
8
|
-
|
|
7
|
+
localPeerDescriptor: PeerDescriptor;
|
|
9
8
|
private targetPeerDescriptor;
|
|
10
9
|
private simulator;
|
|
11
|
-
constructor(
|
|
10
|
+
constructor(localPeerDescriptor: PeerDescriptor, targetPeerDescriptor: PeerDescriptor, connectionType: ConnectionType, simulator: Simulator);
|
|
12
11
|
send(data: Uint8Array): void;
|
|
13
|
-
close(
|
|
12
|
+
close(gracefulLeave: boolean): Promise<void>;
|
|
14
13
|
connect(): void;
|
|
15
14
|
handleIncomingData(data: Uint8Array): void;
|
|
16
15
|
handleIncomingDisconnection(): void;
|
|
@@ -8,10 +8,10 @@ const protoToString_1 = require("../../helpers/protoToString");
|
|
|
8
8
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
9
9
|
const logger = new utils_1.Logger(module);
|
|
10
10
|
class SimulatorConnection extends Connection_1.Connection {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(localPeerDescriptor, targetPeerDescriptor, connectionType, simulator) {
|
|
12
12
|
super(connectionType);
|
|
13
13
|
this.stopped = false;
|
|
14
|
-
this.
|
|
14
|
+
this.localPeerDescriptor = localPeerDescriptor;
|
|
15
15
|
this.setPeerDescriptor(targetPeerDescriptor);
|
|
16
16
|
this.targetPeerDescriptor = targetPeerDescriptor;
|
|
17
17
|
this.connectionType = connectionType;
|
|
@@ -30,35 +30,35 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
30
30
|
this.simulator.send(this, data);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
logger.error((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
33
|
+
logger.error((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
34
34
|
'tried to send() on a stopped connection');
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
async close(
|
|
38
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
37
|
+
async close(gracefulLeave) {
|
|
38
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) + ' close()');
|
|
39
39
|
if (!this.stopped) {
|
|
40
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
40
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', '
|
|
41
41
|
+ (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) + ' close() not stopped');
|
|
42
42
|
this.stopped = true;
|
|
43
43
|
try {
|
|
44
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
44
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
45
45
|
' close() calling simulator.disconnect()');
|
|
46
46
|
this.simulator.close(this);
|
|
47
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
47
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
48
48
|
' close() simulator.disconnect returned');
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
51
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
51
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
52
52
|
'close aborted' + e);
|
|
53
53
|
}
|
|
54
54
|
finally {
|
|
55
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
55
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
56
56
|
' calling this.doDisconnect');
|
|
57
|
-
this.doDisconnect(
|
|
57
|
+
this.doDisconnect(gracefulLeave);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
61
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
62
62
|
' close() tried to close a stopped connection');
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -68,7 +68,7 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
68
68
|
this.simulator.connect(this, this.targetPeerDescriptor, (error) => {
|
|
69
69
|
if (error) {
|
|
70
70
|
logger.trace(error);
|
|
71
|
-
this.doDisconnect(
|
|
71
|
+
this.doDisconnect(false);
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
74
|
this.emit('connected');
|
|
@@ -91,9 +91,9 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
91
91
|
}
|
|
92
92
|
handleIncomingDisconnection() {
|
|
93
93
|
if (!this.stopped) {
|
|
94
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
94
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ' handleIncomingDisconnection()');
|
|
95
95
|
this.stopped = true;
|
|
96
|
-
this.doDisconnect(
|
|
96
|
+
this.doDisconnect(false);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
logger.trace('tried to call handleIncomingDisconnection() a stopped connection');
|
|
@@ -101,20 +101,20 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
101
101
|
}
|
|
102
102
|
destroy() {
|
|
103
103
|
if (!this.stopped) {
|
|
104
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
104
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ' destroy()');
|
|
105
105
|
this.removeAllListeners();
|
|
106
|
-
this.close(
|
|
106
|
+
this.close(false).catch((_e) => { });
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
109
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ' tried to call destroy() a stopped connection');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
doDisconnect(
|
|
113
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
112
|
+
doDisconnect(gracefulLeave) {
|
|
113
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ' doDisconnect()');
|
|
114
114
|
this.stopped = true;
|
|
115
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.
|
|
115
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.localPeerDescriptor) + ', '
|
|
116
116
|
+ (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.targetPeerDescriptor) + ' doDisconnect emitting');
|
|
117
|
-
this.emit('disconnected',
|
|
117
|
+
this.emit('disconnected', gracefulLeave);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
exports.SimulatorConnection = SimulatorConnection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulatorConnection.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorConnection.ts"],"names":[],"mappings":";;;AAEA,mEAAgF;AAChF,8CAA0C;AAC1C,0CAAuC;AACvC,+DAA2D;AAC3D,qFAA8E;AAE9E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,mBAAoB,SAAQ,uBAAU;IAO/C,YACI,mBAAmC,EACnC,oBAAoC,EACpC,cAA8B,EAC9B,SAAoB;QA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 import { SimulatorConnection } from './SimulatorConnection';
|
|
|
5
5
|
export declare class SimulatorConnector {
|
|
6
6
|
private connectingConnections;
|
|
7
7
|
private stopped;
|
|
8
|
-
private
|
|
8
|
+
private localPeerDescriptor;
|
|
9
9
|
private simulator;
|
|
10
10
|
private onIncomingConnection;
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(localPeerDescriptor: PeerDescriptor, simulator: Simulator, onIncomingConnection: (connection: ManagedConnection) => boolean);
|
|
12
12
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
13
13
|
getPeerDescriptor(): PeerDescriptor;
|
|
14
14
|
handleIncomingConnection(sourceConnection: SimulatorConnection): void;
|
|
@@ -8,10 +8,10 @@ const SimulatorConnection_1 = require("./SimulatorConnection");
|
|
|
8
8
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
9
9
|
const logger = new utils_1.Logger(module);
|
|
10
10
|
class SimulatorConnector {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(localPeerDescriptor, simulator, onIncomingConnection) {
|
|
12
12
|
this.connectingConnections = new Map();
|
|
13
13
|
this.stopped = false;
|
|
14
|
-
this.
|
|
14
|
+
this.localPeerDescriptor = localPeerDescriptor;
|
|
15
15
|
this.simulator = simulator;
|
|
16
16
|
this.onIncomingConnection = onIncomingConnection;
|
|
17
17
|
}
|
|
@@ -22,8 +22,8 @@ class SimulatorConnector {
|
|
|
22
22
|
if (existingConnection) {
|
|
23
23
|
return existingConnection;
|
|
24
24
|
}
|
|
25
|
-
const connection = new SimulatorConnection_1.SimulatorConnection(this.
|
|
26
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
25
|
+
const connection = new SimulatorConnection_1.SimulatorConnection(this.localPeerDescriptor, targetPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_CLIENT, this.simulator);
|
|
26
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_CLIENT, connection, undefined);
|
|
27
27
|
managedConnection.setPeerDescriptor(targetPeerDescriptor);
|
|
28
28
|
this.connectingConnections.set(peerKey, managedConnection);
|
|
29
29
|
connection.once('disconnected', () => {
|
|
@@ -36,21 +36,21 @@ class SimulatorConnector {
|
|
|
36
36
|
return managedConnection;
|
|
37
37
|
}
|
|
38
38
|
getPeerDescriptor() {
|
|
39
|
-
return this.
|
|
39
|
+
return this.localPeerDescriptor;
|
|
40
40
|
}
|
|
41
41
|
handleIncomingConnection(sourceConnection) {
|
|
42
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.
|
|
42
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' incoming connection, stopped: ' + this.stopped);
|
|
43
43
|
if (this.stopped) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const connection = new SimulatorConnection_1.SimulatorConnection(this.
|
|
47
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
46
|
+
const connection = new SimulatorConnection_1.SimulatorConnection(this.localPeerDescriptor, sourceConnection.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_SERVER, this.simulator);
|
|
47
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_SERVER, undefined, connection);
|
|
48
48
|
logger.trace('connected');
|
|
49
49
|
managedConnection.once('handshakeRequest', () => {
|
|
50
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.
|
|
50
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' incoming handshake request');
|
|
51
51
|
logger.trace('incoming handshake request');
|
|
52
52
|
if (this.onIncomingConnection(managedConnection)) {
|
|
53
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.
|
|
53
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' calling acceptHandshake');
|
|
54
54
|
managedConnection.acceptHandshake();
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -63,7 +63,7 @@ class SimulatorConnector {
|
|
|
63
63
|
async stop() {
|
|
64
64
|
this.stopped = true;
|
|
65
65
|
const conns = Array.from(this.connectingConnections.values());
|
|
66
|
-
await Promise.allSettled(conns.map((conn) => conn.close(
|
|
66
|
+
await Promise.allSettled(conns.map((conn) => conn.close(false)));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
exports.SimulatorConnector = SimulatorConnector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimulatorConnector.js","sourceRoot":"","sources":["../../../../src/connection/
|
|
1
|
+
{"version":3,"file":"SimulatorConnector.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorConnector.ts"],"names":[],"mappings":";;;AAAA,gDAA+C;AAK/C,0CAAuC;AACvC,4DAAwD;AAGxD,+DAA2D;AAC3D,qFAA8E;AAE9E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,kBAAkB;IAQ3B,YACI,mBAAmC,EACnC,SAAoB,EACpB,oBAAgE;QAT5D,0BAAqB,GAAsC,IAAI,GAAG,EAAE,CAAA;QACpE,YAAO,GAAG,KAAK,CAAA;QAUnB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;IACpD,CAAC;IAEM,OAAO,CAAC,oBAAoC;QAC/C,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,IAAA,gDAAqB,EAAC,oBAAoB,CAAC,CAAC,CAAA;QACxE,MAAM,OAAO,GAAG,IAAA,gDAAqB,EAAC,oBAAoB,CAA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C,KAAK,CAAC,CACpB,CAAC,CAAA;IACN,CAAC;CACJ;AAnFD,gDAmFC"}
|
|
@@ -2,5 +2,5 @@ import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
|
2
2
|
import { ConnectionManager } from '../ConnectionManager';
|
|
3
3
|
import { Simulator } from './Simulator';
|
|
4
4
|
export declare class SimulatorTransport extends ConnectionManager {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(localPeerDescriptor: PeerDescriptor, simulator: Simulator);
|
|
6
6
|
}
|
|
@@ -5,9 +5,9 @@ const utils_1 = require("@streamr/utils");
|
|
|
5
5
|
const ConnectionManager_1 = require("../ConnectionManager");
|
|
6
6
|
const ConnectorFacade_1 = require("../ConnectorFacade");
|
|
7
7
|
class SimulatorTransport extends ConnectionManager_1.ConnectionManager {
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(localPeerDescriptor, simulator) {
|
|
9
9
|
super({
|
|
10
|
-
createConnectorFacade: () => new ConnectorFacade_1.SimulatorConnectorFacade(
|
|
10
|
+
createConnectorFacade: () => new ConnectorFacade_1.SimulatorConnectorFacade(localPeerDescriptor, simulator),
|
|
11
11
|
metricsContext: new utils_1.MetricsContext()
|
|
12
12
|
});
|
|
13
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulatorTransport.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorTransport.ts"],"names":[],"mappings":";;;AAAA,0CAA+C;AAE/C,4DAAwD;AAExD,wDAA6D;AAE7D,MAAa,kBAAmB,SAAQ,qCAAiB;IACrD,YAAY,mBAAmC,EAAE,SAAoB;QACjE,KAAK,CAAC;YACF,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,0CAAwB,CAAC,mBAAmB,EAAE,SAAS,CAAC;YACzF,cAAc,EAAE,IAAI,sBAAc,EAAE;SACvC,CAAC,CAAA;IACN,CAAC;CACJ;AAPD,gDAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pings.js","sourceRoot":"","sources":["../../../../src/connection/
|
|
1
|
+
{"version":3,"file":"pings.js","sourceRoot":"","sources":["../../../../src/connection/simulator/pings.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D,mEAAmE;AACnE,kEAAkE;AAClE,gDAAgD;AAEhD,IAAY,WAA0N;AAAtO,WAAY,WAAW;IAAG,6DAAY,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,yDAAU,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,6DAAY,CAAA;IAAE,0DAAU,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,wDAAS,CAAA;AAAC,CAAC,EAA1N,WAAW,2BAAX,WAAW,QAA+M;AAEzN,QAAA,gBAAgB,GAAG;IAC5B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;IACnI,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;IACvI,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;I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CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC;CAChJ,CAAA;AAED,SAAgB,oBAAoB;IAChC,MAAM,GAAG,GAAG,EAAE,CAAA;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC9C,MAAM,GAAG,GAAG,EAAE,CAAA;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACjD,GAAG,CAAC,IAAI,CAAC,wBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;SACvC;QACD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;KAChB;IACD,OAAO,GAAG,CAAA;AACd,CAAC;AAVD,oDAUC;AAED,SAAgB,eAAe;IAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;AACzC,CAAC;AAFD,0CAEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface WebrtcConnectionEvents {
|
|
2
2
|
localDescription: (description: string, type: string) => void;
|
|
3
3
|
localCandidate: (candidate: string, mid: string) => void;
|
|
4
4
|
}
|
|
@@ -6,7 +6,7 @@ export declare enum RtcDescription {
|
|
|
6
6
|
OFFER = "offer",
|
|
7
7
|
ANSWER = "answer"
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface IWebrtcConnection {
|
|
10
10
|
start(isOffering: boolean): void;
|
|
11
11
|
on(event: 'localDescription', listener: (description: string, type: string) => void): this;
|
|
12
12
|
on(event: 'localCandidate', listener: (candidate: string, mid: string) => void): this;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/IWebrtcConnection.ts"],"names":[],"mappings":";;;AAKA,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,iCAAe,CAAA;IACf,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB"}
|
package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IWebrtcConnection, WebrtcConnectionEvents } from './IWebrtcConnection';
|
|
2
2
|
import { ConnectionType, IConnection, ConnectionID, ConnectionEvents } from '../IConnection';
|
|
3
3
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
|
-
import {
|
|
6
|
-
import { IceServer } from './WebRtcConnectorRpcLocal';
|
|
5
|
+
import { IceServer } from './WebrtcConnector';
|
|
7
6
|
import { PortRange } from '../ConnectionManager';
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const WEBRTC_CLEANUP: {
|
|
9
8
|
cleanUp(): void;
|
|
10
9
|
};
|
|
11
10
|
export interface Params {
|
|
@@ -17,8 +16,8 @@ export interface Params {
|
|
|
17
16
|
iceServers?: IceServer[];
|
|
18
17
|
portRange?: PortRange;
|
|
19
18
|
}
|
|
20
|
-
type Events =
|
|
21
|
-
export declare class
|
|
19
|
+
type Events = WebrtcConnectionEvents & ConnectionEvents;
|
|
20
|
+
export declare class NodeWebrtcConnection extends EventEmitter<Events> implements IConnection, IWebrtcConnection {
|
|
22
21
|
connectionId: ConnectionID;
|
|
23
22
|
private connection?;
|
|
24
23
|
private dataChannel?;
|
|
@@ -39,7 +38,7 @@ export declare class NodeWebRtcConnection extends EventEmitter<Events> implement
|
|
|
39
38
|
setRemoteDescription(description: string, type: string): Promise<void>;
|
|
40
39
|
addRemoteCandidate(candidate: string, mid: string): void;
|
|
41
40
|
send(data: Uint8Array): void;
|
|
42
|
-
close(
|
|
41
|
+
close(gracefulLeave: boolean, reason?: string): Promise<void>;
|
|
43
42
|
private doClose;
|
|
44
43
|
destroy(): void;
|
|
45
44
|
private onDataChannel;
|
package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js}
RENAMED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.NodeWebrtcConnection = exports.WEBRTC_CLEANUP = void 0;
|
|
30
30
|
const IConnection_1 = require("../IConnection");
|
|
31
31
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
32
32
|
const node_datachannel_1 = __importStar(require("node-datachannel"));
|
|
@@ -35,7 +35,7 @@ const errors_1 = require("../../helpers/errors");
|
|
|
35
35
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
36
36
|
const iceServerAsString_1 = require("./iceServerAsString");
|
|
37
37
|
const logger = new utils_1.Logger(module);
|
|
38
|
-
exports.
|
|
38
|
+
exports.WEBRTC_CLEANUP = new class {
|
|
39
39
|
// eslint-disable-next-line class-methods-use-this
|
|
40
40
|
cleanUp() {
|
|
41
41
|
node_datachannel_1.default.cleanup();
|
|
@@ -43,17 +43,17 @@ exports.WEB_RTC_CLEANUP = new class {
|
|
|
43
43
|
};
|
|
44
44
|
// Re-defined accoring to https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts
|
|
45
45
|
// because importing single dom definitions in not possible
|
|
46
|
-
var
|
|
47
|
-
(function (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})(
|
|
46
|
+
var RtcPeerConnectionStateEnum;
|
|
47
|
+
(function (RtcPeerConnectionStateEnum) {
|
|
48
|
+
RtcPeerConnectionStateEnum["closed"] = "closed";
|
|
49
|
+
RtcPeerConnectionStateEnum["connected"] = "connected";
|
|
50
|
+
RtcPeerConnectionStateEnum["connecting"] = "connecting";
|
|
51
|
+
RtcPeerConnectionStateEnum["disconnected"] = "disconnected";
|
|
52
|
+
RtcPeerConnectionStateEnum["failed"] = "failed";
|
|
53
|
+
RtcPeerConnectionStateEnum["new"] = "new";
|
|
54
|
+
})(RtcPeerConnectionStateEnum || (RtcPeerConnectionStateEnum = {}));
|
|
55
55
|
node_datachannel_1.default.initLogger('Fatal');
|
|
56
|
-
class
|
|
56
|
+
class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
57
57
|
constructor(params) {
|
|
58
58
|
super();
|
|
59
59
|
this.lastState = 'connecting';
|
|
@@ -82,7 +82,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
82
82
|
});
|
|
83
83
|
this.connectingTimeoutRef = setTimeout(() => {
|
|
84
84
|
logger.trace('connectingTimeout, this.closed === ' + this.closed);
|
|
85
|
-
this.doClose(
|
|
85
|
+
this.doClose(false);
|
|
86
86
|
}, this.connectingTimeout);
|
|
87
87
|
this.connection.onStateChange((state) => this.onStateChange(state));
|
|
88
88
|
this.connection.onGatheringStateChange(() => { });
|
|
@@ -108,11 +108,11 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
108
108
|
this.remoteDescriptionSet = true;
|
|
109
109
|
}
|
|
110
110
|
catch (err) {
|
|
111
|
-
logger.
|
|
111
|
+
logger.debug(`Failed to set remote descriptor for peer ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
this.doClose(
|
|
115
|
+
this.doClose(false, `Tried to set description for non-existent connection`);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
addRemoteCandidate(candidate, mid) {
|
|
@@ -123,16 +123,16 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
123
123
|
this.connection.addRemoteCandidate(candidate, mid);
|
|
124
124
|
}
|
|
125
125
|
catch (err) {
|
|
126
|
-
logger.
|
|
127
|
-
this.doClose('OTHER');
|
|
126
|
+
logger.debug(`Failed to set remote candidate for peer ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
else {
|
|
131
|
-
|
|
130
|
+
// TODO: should queue candidates until remote description is set?
|
|
131
|
+
this.doClose(false, `Tried to set candidate before description`);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
else {
|
|
135
|
-
this.doClose(
|
|
135
|
+
this.doClose(false, `Tried to set candidate for non-existent connection`);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
send(data) {
|
|
@@ -141,19 +141,19 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
141
141
|
this.dataChannel.sendMessageBinary(data);
|
|
142
142
|
}
|
|
143
143
|
catch (err) {
|
|
144
|
-
logger.
|
|
144
|
+
logger.debug('Failed to send binary message to ' + (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor) + err);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
async close(
|
|
149
|
-
this.doClose(
|
|
148
|
+
async close(gracefulLeave, reason) {
|
|
149
|
+
this.doClose(gracefulLeave, reason);
|
|
150
150
|
}
|
|
151
|
-
doClose(
|
|
151
|
+
doClose(gracefulLeave, reason) {
|
|
152
152
|
if (!this.closed) {
|
|
153
153
|
logger.trace(`Closing Node WebRTC Connection to ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`
|
|
154
154
|
+ `${reason ? `, reason: ${reason}` : ''}`);
|
|
155
155
|
this.closed = true;
|
|
156
|
-
this.emit('disconnected',
|
|
156
|
+
this.emit('disconnected', gracefulLeave, undefined, reason);
|
|
157
157
|
this.removeAllListeners();
|
|
158
158
|
if (this.connectingTimeoutRef) {
|
|
159
159
|
clearTimeout(this.connectingTimeoutRef);
|
|
@@ -164,7 +164,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
164
164
|
this.dataChannel.close();
|
|
165
165
|
}
|
|
166
166
|
catch (e) {
|
|
167
|
-
logger.
|
|
167
|
+
logger.trace('dc.close() errored: %s', e);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
if (this.connection) {
|
|
@@ -172,14 +172,14 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
172
172
|
this.connection.close();
|
|
173
173
|
}
|
|
174
174
|
catch (e) {
|
|
175
|
-
logger.
|
|
175
|
+
logger.trace('conn.close() errored: %s', e);
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
destroy() {
|
|
181
181
|
this.removeAllListeners();
|
|
182
|
-
this.doClose(
|
|
182
|
+
this.doClose(false);
|
|
183
183
|
}
|
|
184
184
|
onDataChannel(dataChannel) {
|
|
185
185
|
this.openDataChannel(dataChannel);
|
|
@@ -193,7 +193,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
193
193
|
});
|
|
194
194
|
dataChannel.onClosed(() => {
|
|
195
195
|
logger.trace(`dc.closed`);
|
|
196
|
-
this.doClose(
|
|
196
|
+
this.doClose(false, 'DataChannel closed');
|
|
197
197
|
});
|
|
198
198
|
dataChannel.onError((err) => logger.error('error', { err }));
|
|
199
199
|
dataChannel.onBufferedAmountLow(() => {
|
|
@@ -214,16 +214,16 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
214
214
|
}
|
|
215
215
|
onStateChange(state) {
|
|
216
216
|
logger.trace('onStateChange ' + state);
|
|
217
|
-
if (!Object.keys(
|
|
218
|
-
throw new errors_1.
|
|
217
|
+
if (!Object.keys(RtcPeerConnectionStateEnum).filter((s) => isNaN(+s)).includes(state)) {
|
|
218
|
+
throw new errors_1.IllegalRtcPeerConnectionState('NodeWebrtcConnection used an unknown state: ' + state);
|
|
219
219
|
}
|
|
220
220
|
else {
|
|
221
221
|
this.lastState = state;
|
|
222
222
|
}
|
|
223
|
-
if (state ===
|
|
224
|
-
|| state ===
|
|
225
|
-
|| state ===
|
|
226
|
-
this.doClose(
|
|
223
|
+
if (state === RtcPeerConnectionStateEnum.closed
|
|
224
|
+
|| state === RtcPeerConnectionStateEnum.disconnected
|
|
225
|
+
|| state === RtcPeerConnectionStateEnum.failed) {
|
|
226
|
+
this.doClose(false);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
isOpen() {
|
|
@@ -233,5 +233,5 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
233
233
|
this.connectionId = new IConnection_1.ConnectionID(connectionID);
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
exports.
|
|
237
|
-
//# sourceMappingURL=
|
|
236
|
+
exports.NodeWebrtcConnection = NodeWebrtcConnection;
|
|
237
|
+
//# sourceMappingURL=NodeWebrtcConnection.js.map
|