@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":"ClientWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ClientWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAuC;AACvC,kEAAwC;AACxC,yCAAiF;AACjF,gDAA4F;AAE5F,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,mGAAmG;AACnG,sDAAsD;AACzC,QAAA,UAAU,GAAG,IAAI,CAAA;AAE9B,MAAM,WAAW,GAAG,aAAa,CAAA;AAEjC,MAAa,eAAgB,SAA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yCAAyC,CAAC,CAAA;SAC1D;IACL,CAAC;CACJ;AA1GD,0CA0GC"}
|
package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts}
RENAMED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
3
3
|
import { IConnection, ConnectionID, ConnectionEvents, ConnectionType } from '../IConnection';
|
|
4
4
|
import { connection as WsConnection } from 'websocket';
|
|
5
5
|
import { Url } from 'url';
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class ServerWebsocket extends EventEmitter<ConnectionEvents> implements IConnection {
|
|
7
7
|
readonly connectionId: ConnectionID;
|
|
8
8
|
readonly connectionType = ConnectionType.WEBSOCKET_SERVER;
|
|
9
9
|
readonly resourceURL: Url;
|
|
@@ -12,7 +12,7 @@ export declare class ServerWebSocket extends EventEmitter<ConnectionEvents> impl
|
|
|
12
12
|
constructor(socket: WsConnection, resourceURL: Url);
|
|
13
13
|
private doDisconnect;
|
|
14
14
|
send(data: Uint8Array): void;
|
|
15
|
-
close(): Promise<void>;
|
|
15
|
+
close(gracefulLeave: boolean): Promise<void>;
|
|
16
16
|
destroy(): void;
|
|
17
17
|
getRemoteAddress(): string;
|
|
18
18
|
}
|
|
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.ServerWebsocket = void 0;
|
|
7
7
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
8
8
|
const IConnection_1 = require("../IConnection");
|
|
9
9
|
const utils_1 = require("@streamr/utils");
|
|
10
|
+
const ClientWebsocket_1 = require("./ClientWebsocket");
|
|
10
11
|
const logger = new utils_1.Logger(module);
|
|
11
12
|
var MessageType;
|
|
12
13
|
(function (MessageType) {
|
|
13
14
|
MessageType["UTF8"] = "utf8";
|
|
14
15
|
MessageType["BINARY"] = "binary";
|
|
15
16
|
})(MessageType || (MessageType = {}));
|
|
16
|
-
class
|
|
17
|
+
class ServerWebsocket extends eventemitter3_1.default {
|
|
17
18
|
constructor(socket, resourceURL) {
|
|
18
19
|
super();
|
|
19
20
|
this.connectionType = IConnection_1.ConnectionType.WEBSOCKET_SERVER;
|
|
@@ -21,35 +22,30 @@ class ServerWebSocket extends eventemitter3_1.default {
|
|
|
21
22
|
this.resourceURL = resourceURL;
|
|
22
23
|
this.connectionId = new IConnection_1.ConnectionID();
|
|
23
24
|
socket.on('message', (message) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.emit('data', new Uint8Array(message.binaryData.buffer, message.binaryData.byteOffset, message.binaryData.byteLength / Uint8Array.BYTES_PER_ELEMENT));
|
|
32
|
-
}
|
|
25
|
+
logger.trace('ServerWebsocket::onMessage');
|
|
26
|
+
if (message.type === MessageType.UTF8) {
|
|
27
|
+
logger.debug('Received string Message: ' + message.utf8Data);
|
|
28
|
+
}
|
|
29
|
+
else if (message.type === MessageType.BINARY) {
|
|
30
|
+
logger.trace('Received Binary Message of ' + message.binaryData.length + ' bytes');
|
|
31
|
+
this.emit('data', new Uint8Array(message.binaryData.buffer, message.binaryData.byteOffset, message.binaryData.byteLength / Uint8Array.BYTES_PER_ELEMENT));
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
socket.on('close', (reasonCode, description) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
this.doDisconnect('OTHER', reasonCode, description);
|
|
39
|
-
}
|
|
35
|
+
logger.trace('Peer ' + socket.remoteAddress + ' disconnected.');
|
|
36
|
+
this.doDisconnect(reasonCode, description);
|
|
40
37
|
});
|
|
41
38
|
socket.on('error', (error) => {
|
|
42
|
-
|
|
43
|
-
this.emit('error', error.name);
|
|
44
|
-
}
|
|
39
|
+
this.emit('error', error.name);
|
|
45
40
|
});
|
|
46
41
|
this.socket = socket;
|
|
47
42
|
}
|
|
48
|
-
doDisconnect(
|
|
43
|
+
doDisconnect(reasonCode, description) {
|
|
49
44
|
this.stopped = true;
|
|
50
45
|
this.socket?.removeAllListeners();
|
|
51
46
|
this.socket = undefined;
|
|
52
|
-
|
|
47
|
+
const gracefulLeave = reasonCode === ClientWebsocket_1.GOING_AWAY;
|
|
48
|
+
this.emit('disconnected', gracefulLeave, reasonCode, description);
|
|
53
49
|
}
|
|
54
50
|
send(data) {
|
|
55
51
|
// If in an Karma / Electron test, use the NodeJS implementation
|
|
@@ -63,15 +59,15 @@ class ServerWebSocket extends eventemitter3_1.default {
|
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
else {
|
|
66
|
-
logger.
|
|
62
|
+
logger.debug('Tried to call send() on a stopped socket');
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
|
-
async close() {
|
|
65
|
+
async close(gracefulLeave) {
|
|
70
66
|
if (!this.stopped) {
|
|
71
|
-
this.socket?.close();
|
|
67
|
+
this.socket?.close(gracefulLeave === true ? ClientWebsocket_1.GOING_AWAY : undefined);
|
|
72
68
|
}
|
|
73
69
|
else {
|
|
74
|
-
logger.
|
|
70
|
+
logger.debug('Tried to close a stopped connection');
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
destroy() {
|
|
@@ -85,7 +81,7 @@ class ServerWebSocket extends eventemitter3_1.default {
|
|
|
85
81
|
this.stopped = true;
|
|
86
82
|
}
|
|
87
83
|
else {
|
|
88
|
-
logger.
|
|
84
|
+
logger.debug('Tried to destroy() a stopped connection');
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
getRemoteAddress() {
|
|
@@ -98,5 +94,5 @@ class ServerWebSocket extends eventemitter3_1.default {
|
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
96
|
}
|
|
101
|
-
exports.
|
|
102
|
-
//# sourceMappingURL=
|
|
97
|
+
exports.ServerWebsocket = ServerWebsocket;
|
|
98
|
+
//# sourceMappingURL=ServerWebsocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServerWebsocket.js","sourceRoot":"","sources":["../../../../src/connection/websocket/ServerWebsocket.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AACxC,gDAA4F;AAE5F,0CAAuC;AAEvC,uDAA8C;AAE9C,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAQjC,IAAK,WAGJ;AAHD,WAAK,WAAW;IACZ,4BAAa,CAAA;IACb,gCAAiB,CAAA;AACrB,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAED,MAAa,eAAgB,SAAQ,uBAA8B;IAQ/D,YAAY,MAAoB,EAAE,WAAgB;QAC9C,KAAK,EAAE,CAAA;QANK,mBAAc,GAAG,4BAAc,CAAC,gBAAgB,CAAA;QAGxD,YAAO,GAAG,KAAK,CAAA;QAKnB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAA;QAEtC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;YAC7B,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;YAC1C,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,EAAE;gBACnC,MAAM,CAAC,KAAK,CAAC,2BAA2B,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;aAC/D;iBAAM,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,MAAM,EAAE;gBAC5C,MAAM,CAAC,KAAK,CAAC,6BAA6B,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAA;gBAClF,IAAI,CAAC,IAAI,CAAC,MAAM,EACZ,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,UAA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AC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;aAC3C;SACJ;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAA;SAC3D;IAEL,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,aAAsB;QACrC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,4BAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;SACtE;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;SACtD;IACL,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACzB,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAA;gBAChC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;gBACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;aAC1B;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;SACtB;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC1D;IACL,CAAC;IAEM,gBAAgB;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAA;SACnC;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAA;YACtE,OAAO,EAAE,CAAA;SACZ;IACL,CAAC;CACJ;AA3FD,0CA2FC"}
|
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
import { ITransport } from '../../transport/ITransport';
|
|
2
|
-
import { ConnectivityMethod, ConnectivityResponse, PeerDescriptor
|
|
3
|
-
import { IWebSocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
2
|
+
import { ConnectivityMethod, ConnectivityResponse, PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
3
|
import { ManagedConnection } from '../ManagedConnection';
|
|
5
4
|
import { PortRange, TlsCertificate } from '../ConnectionManager';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface WebSocketConnectorRpcLocalConfig {
|
|
5
|
+
export declare const connectivityMethodToWebsocketUrl: (ws: ConnectivityMethod) => string;
|
|
6
|
+
interface WebsocketConnectorConfig {
|
|
9
7
|
transport: ITransport;
|
|
10
|
-
canConnect: (peerDescriptor: PeerDescriptor
|
|
8
|
+
canConnect: (peerDescriptor: PeerDescriptor) => boolean;
|
|
11
9
|
onIncomingConnection: (connection: ManagedConnection) => boolean;
|
|
12
10
|
portRange?: PortRange;
|
|
13
11
|
maxMessageSize?: number;
|
|
14
12
|
host?: string;
|
|
15
13
|
entrypoints?: PeerDescriptor[];
|
|
16
14
|
tlsCertificate?: TlsCertificate;
|
|
15
|
+
autoCertifierTransport: ITransport;
|
|
16
|
+
autoCertifierUrl: string;
|
|
17
|
+
autoCertifierConfigFile: string;
|
|
18
|
+
serverEnableTls: boolean;
|
|
17
19
|
}
|
|
18
|
-
export declare class
|
|
20
|
+
export declare class WebsocketConnector {
|
|
19
21
|
private static readonly WEBSOCKET_CONNECTOR_SERVICE_ID;
|
|
20
22
|
private readonly rpcCommunicator;
|
|
21
|
-
private readonly
|
|
22
|
-
private readonly webSocketServer?;
|
|
23
|
+
private readonly websocketServer?;
|
|
23
24
|
private connectivityChecker?;
|
|
24
25
|
private readonly ongoingConnectRequests;
|
|
25
26
|
private onIncomingConnection;
|
|
26
27
|
private host?;
|
|
27
28
|
private readonly entrypoints?;
|
|
28
29
|
private readonly tlsCertificate?;
|
|
30
|
+
private readonly autoCertifierTransport;
|
|
31
|
+
private readonly autoCertifierUrl;
|
|
32
|
+
private readonly autoCertifierConfigFile;
|
|
33
|
+
private readonly serverEnableTls;
|
|
34
|
+
private autoCertifierClient?;
|
|
29
35
|
private selectedPort?;
|
|
30
|
-
private
|
|
36
|
+
private localPeerDescriptor?;
|
|
31
37
|
private connectingConnections;
|
|
32
|
-
private
|
|
33
|
-
constructor(config:
|
|
38
|
+
private abortController;
|
|
39
|
+
constructor(config: WebsocketConnectorConfig);
|
|
40
|
+
private registerLocalRpcMethods;
|
|
34
41
|
private attachHandshaker;
|
|
42
|
+
autoCertify(): Promise<void>;
|
|
43
|
+
private setHost;
|
|
35
44
|
start(): Promise<void>;
|
|
36
|
-
checkConnectivity(): Promise<ConnectivityResponse>;
|
|
45
|
+
checkConnectivity(selfSigned: boolean): Promise<ConnectivityResponse>;
|
|
37
46
|
isPossibleToFormConnection(targetPeerDescriptor: PeerDescriptor): boolean;
|
|
38
47
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
39
48
|
private requestConnectionFromPeer;
|
|
40
49
|
private onServerSocketHandshakeRequest;
|
|
41
|
-
|
|
50
|
+
setLocalPeerDescriptor(localPeerDescriptor: PeerDescriptor): void;
|
|
42
51
|
destroy(): Promise<void>;
|
|
43
|
-
requestConnection(request: WebSocketConnectionRequest, context: ServerCallContext): Promise<WebSocketConnectionResponse>;
|
|
44
52
|
}
|
|
45
53
|
export {};
|
|
@@ -1,81 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.WebsocketConnector = exports.connectivityMethodToWebsocketUrl = void 0;
|
|
4
|
+
const ClientWebsocket_1 = require("./ClientWebsocket");
|
|
5
5
|
const IConnection_1 = require("../IConnection");
|
|
6
6
|
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
7
|
-
const
|
|
7
|
+
const WebsocketConnectorRpcLocal_1 = require("./WebsocketConnectorRpcLocal");
|
|
8
|
+
const WebsocketConnectorRpcRemote_1 = require("./WebsocketConnectorRpcRemote");
|
|
8
9
|
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
9
10
|
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
10
11
|
const utils_1 = require("@streamr/utils");
|
|
11
12
|
const ManagedConnection_1 = require("../ManagedConnection");
|
|
12
|
-
const
|
|
13
|
+
const WebsocketServer_1 = require("./WebsocketServer");
|
|
13
14
|
const ConnectivityChecker_1 = require("../ConnectivityChecker");
|
|
14
15
|
const ConnectionManager_1 = require("../ConnectionManager");
|
|
15
16
|
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
16
17
|
const Handshaker_1 = require("../Handshaker");
|
|
17
18
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
18
19
|
const lodash_1 = require("lodash");
|
|
19
|
-
const
|
|
20
|
+
const Connectivity_1 = require("../../helpers/Connectivity");
|
|
21
|
+
const errors_1 = require("../../helpers/errors");
|
|
22
|
+
const AutoCertifierClientFacade_1 = require("./AutoCertifierClientFacade");
|
|
20
23
|
const logger = new utils_1.Logger(module);
|
|
21
|
-
const
|
|
24
|
+
const connectivityMethodToWebsocketUrl = (ws) => {
|
|
22
25
|
return (ws.tls ? 'wss://' : 'ws://') + ws.host + ':' + ws.port;
|
|
23
26
|
};
|
|
24
|
-
exports.
|
|
25
|
-
const canOpenConnectionFromBrowser = (websocketServer) => {
|
|
26
|
-
const hasPrivateAddress = ((websocketServer.host === 'localhost') || (0, AddressTools_1.isPrivateIPv4)(websocketServer.host));
|
|
27
|
-
return websocketServer.tls || hasPrivateAddress;
|
|
28
|
-
};
|
|
27
|
+
exports.connectivityMethodToWebsocketUrl = connectivityMethodToWebsocketUrl;
|
|
29
28
|
const ENTRY_POINT_CONNECTION_ATTEMPTS = 5;
|
|
30
|
-
class
|
|
29
|
+
class WebsocketConnector {
|
|
31
30
|
constructor(config) {
|
|
32
31
|
this.ongoingConnectRequests = new Map();
|
|
33
32
|
this.connectingConnections = new Map();
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
const peerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(peerDescriptor);
|
|
37
|
-
if (this.ongoingConnectRequests.has(peerId.toKey())) {
|
|
38
|
-
const ongoingConnectReguest = this.ongoingConnectRequests.get(peerId.toKey());
|
|
39
|
-
ongoingConnectReguest.attachImplementation(serverWebSocket);
|
|
40
|
-
ongoingConnectReguest.acceptHandshake();
|
|
41
|
-
this.ongoingConnectRequests.delete(peerId.toKey());
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.ownPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, serverWebSocket);
|
|
45
|
-
managedConnection.setPeerDescriptor(peerDescriptor);
|
|
46
|
-
if (this.onIncomingConnection(managedConnection)) {
|
|
47
|
-
managedConnection.acceptHandshake();
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
managedConnection.rejectHandshake('Duplicate connection');
|
|
51
|
-
managedConnection.destroy();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
this.webSocketServer = config.portRange ? new WebSocketServer_1.WebSocketServer({
|
|
33
|
+
this.abortController = new AbortController();
|
|
34
|
+
this.websocketServer = config.portRange ? new WebsocketServer_1.WebsocketServer({
|
|
56
35
|
portRange: config.portRange,
|
|
57
36
|
tlsCertificate: config.tlsCertificate,
|
|
58
|
-
maxMessageSize: config.maxMessageSize
|
|
37
|
+
maxMessageSize: config.maxMessageSize,
|
|
38
|
+
enableTls: config.serverEnableTls
|
|
59
39
|
}) : undefined;
|
|
60
40
|
this.onIncomingConnection = config.onIncomingConnection;
|
|
61
41
|
this.host = config.host;
|
|
62
42
|
this.entrypoints = config.entrypoints;
|
|
63
43
|
this.tlsCertificate = config.tlsCertificate;
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
44
|
+
this.autoCertifierTransport = config.autoCertifierTransport;
|
|
45
|
+
this.autoCertifierUrl = config.autoCertifierUrl;
|
|
46
|
+
this.autoCertifierConfigFile = config.autoCertifierConfigFile;
|
|
47
|
+
this.serverEnableTls = config.serverEnableTls;
|
|
48
|
+
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebsocketConnector.WEBSOCKET_CONNECTOR_SERVICE_ID, config.transport, {
|
|
66
49
|
rpcRequestTimeout: 15000
|
|
67
50
|
});
|
|
68
|
-
this.
|
|
51
|
+
this.registerLocalRpcMethods(config);
|
|
52
|
+
}
|
|
53
|
+
registerLocalRpcMethods(config) {
|
|
54
|
+
const rpcLocal = new WebsocketConnectorRpcLocal_1.WebsocketConnectorRpcLocal({
|
|
55
|
+
canConnect: (peerDescriptor) => config.canConnect(peerDescriptor),
|
|
56
|
+
connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
57
|
+
onIncomingConnection: (connection) => config.onIncomingConnection(connection),
|
|
58
|
+
abortSignal: this.abortController.signal
|
|
59
|
+
});
|
|
60
|
+
this.rpcCommunicator.registerRpcMethod(DhtRpc_1.WebsocketConnectionRequest, DhtRpc_1.WebsocketConnectionResponse, 'requestConnection', async (req, context) => {
|
|
61
|
+
if (!this.abortController.signal.aborted) {
|
|
62
|
+
return rpcLocal.requestConnection(req, context);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return { accepted: false };
|
|
66
|
+
}
|
|
67
|
+
});
|
|
69
68
|
}
|
|
70
69
|
attachHandshaker(connection) {
|
|
71
|
-
const handshaker = new Handshaker_1.Handshaker(this.
|
|
70
|
+
const handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, connection);
|
|
72
71
|
handshaker.once('handshakeRequest', (peerDescriptor) => {
|
|
73
72
|
this.onServerSocketHandshakeRequest(peerDescriptor, connection);
|
|
74
73
|
});
|
|
75
74
|
}
|
|
75
|
+
async autoCertify() {
|
|
76
|
+
this.autoCertifierClient = new AutoCertifierClientFacade_1.AutoCertifierClientFacade({
|
|
77
|
+
configFile: this.autoCertifierConfigFile,
|
|
78
|
+
transport: this.autoCertifierTransport,
|
|
79
|
+
url: this.autoCertifierUrl,
|
|
80
|
+
wsServerPort: this.selectedPort,
|
|
81
|
+
setHost: (hostName) => this.setHost(hostName),
|
|
82
|
+
updateCertificate: (certificate, privateKey) => this.websocketServer.updateCertificate(certificate, privateKey)
|
|
83
|
+
});
|
|
84
|
+
logger.trace(`AutoCertifying subdomain...`);
|
|
85
|
+
await this.autoCertifierClient.start();
|
|
86
|
+
}
|
|
87
|
+
setHost(hostName) {
|
|
88
|
+
logger.trace(`Setting host name to ${hostName}`);
|
|
89
|
+
this.host = hostName;
|
|
90
|
+
this.connectivityChecker.setHost(hostName);
|
|
91
|
+
}
|
|
76
92
|
async start() {
|
|
77
|
-
if (!this.
|
|
78
|
-
this.
|
|
93
|
+
if (!this.abortController.signal.aborted && this.websocketServer) {
|
|
94
|
+
this.websocketServer.on('connected', (connection) => {
|
|
79
95
|
const serverSocket = connection;
|
|
80
96
|
if (serverSocket.resourceURL &&
|
|
81
97
|
serverSocket.resourceURL.query) {
|
|
@@ -95,33 +111,30 @@ class WebSocketConnectorRpcLocal {
|
|
|
95
111
|
this.attachHandshaker(connection);
|
|
96
112
|
}
|
|
97
113
|
});
|
|
98
|
-
const port = await this.
|
|
114
|
+
const port = await this.websocketServer.start();
|
|
99
115
|
this.selectedPort = port;
|
|
100
|
-
this.connectivityChecker = new ConnectivityChecker_1.ConnectivityChecker(this.selectedPort, this.
|
|
116
|
+
this.connectivityChecker = new ConnectivityChecker_1.ConnectivityChecker(this.selectedPort, this.serverEnableTls, this.host);
|
|
101
117
|
}
|
|
102
118
|
}
|
|
103
|
-
async checkConnectivity() {
|
|
119
|
+
async checkConnectivity(selfSigned) {
|
|
104
120
|
// TODO: this could throw if the server is not running
|
|
105
121
|
const noServerConnectivityResponse = {
|
|
106
|
-
openInternet: false,
|
|
107
122
|
host: '127.0.0.1',
|
|
108
123
|
natType: ConnectionManager_1.NatType.UNKNOWN
|
|
109
124
|
};
|
|
110
|
-
if (this.
|
|
125
|
+
if (this.abortController.signal.aborted) {
|
|
111
126
|
return noServerConnectivityResponse;
|
|
112
127
|
}
|
|
113
128
|
for (const reattempt of (0, lodash_1.range)(ENTRY_POINT_CONNECTION_ATTEMPTS)) {
|
|
114
129
|
const entryPoint = (0, lodash_1.sample)(this.entrypoints);
|
|
115
130
|
try {
|
|
116
|
-
if (!this.
|
|
117
|
-
// If no websocket server, return openInternet: false
|
|
131
|
+
if (!this.websocketServer) {
|
|
118
132
|
return noServerConnectivityResponse;
|
|
119
133
|
}
|
|
120
134
|
else {
|
|
121
|
-
if (!this.entrypoints || this.entrypoints.length
|
|
135
|
+
if (!this.entrypoints || this.entrypoints.length === 0) {
|
|
122
136
|
// return connectivity info given in config
|
|
123
137
|
const preconfiguredConnectivityResponse = {
|
|
124
|
-
openInternet: true,
|
|
125
138
|
host: this.host,
|
|
126
139
|
natType: ConnectionManager_1.NatType.OPEN_INTERNET,
|
|
127
140
|
websocket: { host: this.host, port: this.selectedPort, tls: this.tlsCertificate !== undefined }
|
|
@@ -129,32 +142,25 @@ class WebSocketConnectorRpcLocal {
|
|
|
129
142
|
return preconfiguredConnectivityResponse;
|
|
130
143
|
}
|
|
131
144
|
else {
|
|
132
|
-
// Do real connectivity checking
|
|
133
|
-
return await this.connectivityChecker.sendConnectivityRequest(entryPoint);
|
|
145
|
+
// Do real connectivity checking
|
|
146
|
+
return await this.connectivityChecker.sendConnectivityRequest(entryPoint, selfSigned);
|
|
134
147
|
}
|
|
135
148
|
}
|
|
136
149
|
}
|
|
137
150
|
catch (err) {
|
|
138
151
|
if (reattempt < ENTRY_POINT_CONNECTION_ATTEMPTS) {
|
|
139
152
|
const error = `Failed to connect to entrypoint with id ${(0, utils_1.binaryToHex)(entryPoint.kademliaId)} `
|
|
140
|
-
+ `and URL ${(0, exports.
|
|
153
|
+
+ `and URL ${(0, exports.connectivityMethodToWebsocketUrl)(entryPoint.websocket)}`;
|
|
141
154
|
logger.error(error, { error: err });
|
|
142
155
|
await (0, utils_1.wait)(2000);
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
|
-
throw
|
|
159
|
+
throw new errors_1.WebsocketServerStartError(`Failed to connect to the entrypoints after ${ENTRY_POINT_CONNECTION_ATTEMPTS} attempts`);
|
|
147
160
|
}
|
|
148
161
|
isPossibleToFormConnection(targetPeerDescriptor) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
else if (targetPeerDescriptor.websocket !== undefined) {
|
|
153
|
-
return (this.ownPeerDescriptor.type !== DhtRpc_1.NodeType.BROWSER) || canOpenConnectionFromBrowser(targetPeerDescriptor.websocket);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
162
|
+
const connectionType = (0, Connectivity_1.expectedConnectionType)(this.localPeerDescriptor, targetPeerDescriptor);
|
|
163
|
+
return (connectionType === IConnection_1.ConnectionType.WEBSOCKET_CLIENT || connectionType === IConnection_1.ConnectionType.WEBSOCKET_SERVER);
|
|
158
164
|
}
|
|
159
165
|
connect(targetPeerDescriptor) {
|
|
160
166
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor);
|
|
@@ -162,13 +168,13 @@ class WebSocketConnectorRpcLocal {
|
|
|
162
168
|
if (existingConnection) {
|
|
163
169
|
return existingConnection;
|
|
164
170
|
}
|
|
165
|
-
if (this.
|
|
166
|
-
return this.requestConnectionFromPeer(this.
|
|
171
|
+
if (this.localPeerDescriptor.websocket && !targetPeerDescriptor.websocket) {
|
|
172
|
+
return this.requestConnectionFromPeer(this.localPeerDescriptor, targetPeerDescriptor);
|
|
167
173
|
}
|
|
168
174
|
else {
|
|
169
|
-
const socket = new
|
|
170
|
-
const url = (0, exports.
|
|
171
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
175
|
+
const socket = new ClientWebsocket_1.ClientWebsocket();
|
|
176
|
+
const url = (0, exports.connectivityMethodToWebsocketUrl)(targetPeerDescriptor.websocket);
|
|
177
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_CLIENT, socket, undefined);
|
|
172
178
|
managedConnection.setPeerDescriptor(targetPeerDescriptor);
|
|
173
179
|
this.connectingConnections.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
174
180
|
const delFunc = () => {
|
|
@@ -184,51 +190,51 @@ class WebSocketConnectorRpcLocal {
|
|
|
184
190
|
return managedConnection;
|
|
185
191
|
}
|
|
186
192
|
}
|
|
187
|
-
requestConnectionFromPeer(
|
|
193
|
+
requestConnectionFromPeer(localPeerDescriptor, targetPeerDescriptor) {
|
|
188
194
|
setImmediate(() => {
|
|
189
|
-
const remoteConnector = new
|
|
190
|
-
remoteConnector.requestConnection(
|
|
195
|
+
const remoteConnector = new WebsocketConnectorRpcRemote_1.WebsocketConnectorRpcRemote(localPeerDescriptor, targetPeerDescriptor, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebsocketConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
|
|
196
|
+
remoteConnector.requestConnection(localPeerDescriptor.websocket.host, localPeerDescriptor.websocket.port);
|
|
191
197
|
});
|
|
192
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
198
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER);
|
|
193
199
|
managedConnection.on('disconnected', () => this.ongoingConnectRequests.delete((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor)));
|
|
194
200
|
managedConnection.setPeerDescriptor(targetPeerDescriptor);
|
|
195
201
|
this.ongoingConnectRequests.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
196
202
|
return managedConnection;
|
|
197
203
|
}
|
|
198
|
-
|
|
199
|
-
|
|
204
|
+
onServerSocketHandshakeRequest(peerDescriptor, serverWebsocket) {
|
|
205
|
+
const peerId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(peerDescriptor);
|
|
206
|
+
if (this.ongoingConnectRequests.has(peerId.toKey())) {
|
|
207
|
+
const ongoingConnectReguest = this.ongoingConnectRequests.get(peerId.toKey());
|
|
208
|
+
ongoingConnectReguest.attachImplementation(serverWebsocket);
|
|
209
|
+
ongoingConnectReguest.acceptHandshake();
|
|
210
|
+
this.ongoingConnectRequests.delete(peerId.toKey());
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.WEBSOCKET_SERVER, undefined, serverWebsocket);
|
|
214
|
+
managedConnection.setPeerDescriptor(peerDescriptor);
|
|
215
|
+
if (this.onIncomingConnection(managedConnection)) {
|
|
216
|
+
managedConnection.acceptHandshake();
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
managedConnection.rejectHandshake('Duplicate connection');
|
|
220
|
+
managedConnection.destroy();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
setLocalPeerDescriptor(localPeerDescriptor) {
|
|
225
|
+
this.localPeerDescriptor = localPeerDescriptor;
|
|
200
226
|
}
|
|
201
227
|
async destroy() {
|
|
202
|
-
this.
|
|
228
|
+
this.abortController.abort();
|
|
203
229
|
this.rpcCommunicator.destroy();
|
|
204
230
|
const requests = Array.from(this.ongoingConnectRequests.values());
|
|
205
|
-
await Promise.allSettled(requests.map((conn) => conn.close(
|
|
231
|
+
await Promise.allSettled(requests.map((conn) => conn.close(false)));
|
|
206
232
|
const attempts = Array.from(this.connectingConnections.values());
|
|
207
|
-
await Promise.allSettled(attempts.map((conn) => conn.close(
|
|
233
|
+
await Promise.allSettled(attempts.map((conn) => conn.close(false)));
|
|
208
234
|
this.connectivityChecker?.destroy();
|
|
209
|
-
await this.
|
|
210
|
-
}
|
|
211
|
-
// IWebSocketConnectorRpc implementation
|
|
212
|
-
async requestConnection(request, context) {
|
|
213
|
-
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
214
|
-
if (!this.destroyed && this.canConnectFunction(senderPeerDescriptor, request.ip, request.port)) {
|
|
215
|
-
setImmediate(() => {
|
|
216
|
-
if (this.destroyed) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const connection = this.connect(senderPeerDescriptor);
|
|
220
|
-
this.onIncomingConnection(connection);
|
|
221
|
-
});
|
|
222
|
-
const res = {
|
|
223
|
-
accepted: true
|
|
224
|
-
};
|
|
225
|
-
return res;
|
|
226
|
-
}
|
|
227
|
-
return {
|
|
228
|
-
accepted: false
|
|
229
|
-
};
|
|
235
|
+
await this.websocketServer?.stop();
|
|
230
236
|
}
|
|
231
237
|
}
|
|
232
|
-
exports.
|
|
233
|
-
|
|
234
|
-
//# sourceMappingURL=
|
|
238
|
+
exports.WebsocketConnector = WebsocketConnector;
|
|
239
|
+
WebsocketConnector.WEBSOCKET_CONNECTOR_SERVICE_ID = 'system/websocket-connector';
|
|
240
|
+
//# sourceMappingURL=WebsocketConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebsocketConnector.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnector.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,gDAA4D;AAE5D,uFAAmF;AACnF,6EAAyE;AACzE,+EAA2E;AAC3E,mEAM+C;AAC/C,iFAA2F;AAC3F,0CAA0D;AAC1D,4DAAwD;AACxD,uDAAmD;AACnD,gEAA4D;AAC5D,4DAAyE;AAGzE,kDAAqD;AACrD,8CAA0C;AAC1C,qFAAwG;AAExG,mCAAsC;AAEtC,6DAAmE;AACnE,iDAAgE;AAChE,2EAAuE;AACvE,MAAM,MAAM,GAAG,IAAI,cAAM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,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,mBAAmB,EAAE,OAAO,EAAE,CAAA;QACnC,MAAM,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAA;IACtC,CAAC;;AAzPL,gDA0PC;AAxP2B,iDAA8B,GAAG,4BAA4B,AAA/B,CAA+B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
3
|
+
import { PeerDescriptor, WebsocketConnectionRequest, WebsocketConnectionResponse } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
|
+
import { IWebsocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
5
|
+
import { ManagedConnection } from '../ManagedConnection';
|
|
6
|
+
interface WebsocketConnectorRpcLocalConfig {
|
|
7
|
+
canConnect: (peerDescriptor: PeerDescriptor) => boolean;
|
|
8
|
+
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
9
|
+
onIncomingConnection: (connection: ManagedConnection) => boolean;
|
|
10
|
+
abortSignal: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export declare class WebsocketConnectorRpcLocal implements IWebsocketConnectorRpc {
|
|
13
|
+
private readonly config;
|
|
14
|
+
constructor(config: WebsocketConnectorRpcLocalConfig);
|
|
15
|
+
requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<WebsocketConnectionResponse>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebsocketConnectorRpcLocal = void 0;
|
|
4
|
+
class WebsocketConnectorRpcLocal {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
async requestConnection(_request, context) {
|
|
9
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
10
|
+
if (this.config.canConnect(senderPeerDescriptor)) {
|
|
11
|
+
setImmediate(() => {
|
|
12
|
+
if (this.config.abortSignal.aborted) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const connection = this.config.connect(senderPeerDescriptor);
|
|
16
|
+
this.config.onIncomingConnection(connection);
|
|
17
|
+
});
|
|
18
|
+
return { accepted: true };
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return { accepted: false };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.WebsocketConnectorRpcLocal = WebsocketConnectorRpcLocal;
|
|
26
|
+
//# sourceMappingURL=WebsocketConnectorRpcLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebsocketConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcLocal.ts"],"names":[],"mappings":";;;AAiBA,MAAa,0BAA0B;IAInC,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAoC,EAAE,OAA0B;QAC3F,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YAC9C,YAAY,CAAC,GAAG,EAAE;gBACd,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;oBACjC,OAAM;iBACT;gBACD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAA;YAChD,CAAC,CAAC,CAAA;YACF,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;SAC5B;aAAM;YACH,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;SAC7B;IACL,CAAC;CACJ;AAvBD,gEAuBC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
-
import {
|
|
2
|
+
import { IWebsocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
3
|
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
4
4
|
import { Remote } from '../../dht/contact/Remote';
|
|
5
|
-
export declare class
|
|
6
|
-
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<
|
|
5
|
+
export declare class WebsocketConnectorRpcRemote extends Remote<IWebsocketConnectorRpcClient> {
|
|
6
|
+
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebsocketConnectorRpcClient>);
|
|
7
7
|
requestConnection(ip: string, port: number): Promise<boolean>;
|
|
8
8
|
}
|