@streamr/dht 100.0.0-pretestnet.2 → 100.0.0-pretestnet.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/connection/ConnectionLockHandler.d.ts +7 -8
- package/dist/src/connection/ConnectionLockHandler.js +16 -14
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +20 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js +47 -0
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -0
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +4 -3
- package/dist/src/connection/ConnectionLockRpcRemote.js +9 -9
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +9 -16
- package/dist/src/connection/ConnectionManager.js +101 -132
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.d.ts +7 -10
- package/dist/src/connection/ConnectivityChecker.js +30 -32
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +19 -13
- package/dist/src/connection/ConnectorFacade.js +74 -29
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +8 -8
- package/dist/src/connection/Handshaker.js +30 -33
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/IConnection.d.ts +5 -6
- package/dist/src/connection/IConnection.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +9 -13
- package/dist/src/connection/ManagedConnection.js +63 -99
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebrtcConnection.d.ts +7 -0
- package/dist/src/connection/ManagedWebrtcConnection.js +20 -0
- package/dist/src/connection/ManagedWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/Simulator.js +3 -3
- package/dist/src/connection/{Simulator → simulator}/Simulator.js.map +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.d.ts +3 -4
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnection.js +25 -24
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.d.ts +3 -3
- package/dist/src/connection/{Simulator → simulator}/SimulatorConnector.js +17 -18
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.d.ts +1 -1
- package/dist/src/connection/{Simulator → simulator}/SimulatorTransport.js +2 -2
- package/dist/src/connection/simulator/SimulatorTransport.js.map +1 -0
- package/dist/src/connection/{Simulator → simulator}/pings.js.map +1 -1
- package/dist/src/connection/{WebRTC/IWebRtcConnection.d.ts → webrtc/IWebrtcConnection.d.ts} +2 -2
- package/dist/src/connection/{WebRTC/IWebRtcConnection.js → webrtc/IWebrtcConnection.js} +1 -1
- package/dist/src/connection/webrtc/IWebrtcConnection.js.map +1 -0
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts} +6 -7
- package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js} +41 -42
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +38 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +178 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +26 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +99 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.d.ts → webrtc/WebrtcConnectorRpcRemote.d.ts} +4 -4
- package/dist/src/connection/{WebRTC/WebRtcConnectorRpcRemote.js → webrtc/WebrtcConnectorRpcRemote.js} +6 -8
- package/dist/src/connection/webrtc/WebrtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +26 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +37 -0
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -0
- package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts} +5 -4
- package/dist/src/connection/{WebSocket/ClientWebSocket.js → websocket/ClientWebsocket.js} +23 -16
- package/dist/src/connection/websocket/ClientWebsocket.js.map +1 -0
- package/dist/src/connection/{WebSocket/ServerWebSocket.d.ts → websocket/ServerWebsocket.d.ts} +2 -2
- package/dist/src/connection/{WebSocket/ServerWebSocket.js → websocket/ServerWebsocket.js} +25 -27
- package/dist/src/connection/websocket/ServerWebsocket.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnector.d.ts +53 -0
- package/dist/src/connection/websocket/WebsocketConnector.js +242 -0
- package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +17 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +26 -0
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.d.ts → websocket/WebsocketConnectorRpcRemote.d.ts} +3 -3
- package/dist/src/connection/{WebSocket/WebSocketConnectorRpcRemote.js → websocket/WebsocketConnectorRpcRemote.js} +6 -11
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/{WebSocket/WebSocketServer.d.ts → websocket/WebsocketServer.d.ts} +6 -3
- package/dist/src/connection/{WebSocket/WebSocketServer.js → websocket/WebsocketServer.js} +39 -19
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +11 -19
- package/dist/src/dht/DhtNode.js +135 -163
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +22 -0
- package/dist/src/dht/DhtNodeRpcLocal.js +42 -0
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -0
- package/dist/src/dht/{RemoteDhtNode.d.ts → DhtNodeRpcRemote.d.ts} +5 -3
- package/dist/src/dht/{RemoteDhtNode.js → DhtNodeRpcRemote.js} +20 -24
- package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +16 -0
- package/dist/src/dht/ExternalApiRpcLocal.js +30 -0
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -0
- package/dist/src/dht/ExternalApiRpcRemote.d.ts +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/contact/Remote.d.ts +4 -1
- package/dist/src/dht/contact/Remote.js +28 -2
- package/dist/src/dht/contact/Remote.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +2 -2
- package/dist/src/dht/contact/SortedContactList.js +3 -3
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +9 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -9
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +7 -10
- package/dist/src/dht/discovery/PeerDiscovery.js +6 -6
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/FindRpcLocal.d.ts +14 -0
- package/dist/src/dht/find/FindRpcLocal.js +25 -0
- package/dist/src/dht/find/FindRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFindSession.d.ts → FindSession.d.ts} +12 -13
- package/dist/src/dht/find/{RecursiveFindSession.js → FindSession.js} +17 -15
- package/dist/src/dht/find/FindSession.js.map +1 -0
- package/dist/src/dht/find/FindSessionRpcLocal.d.ts +12 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js +17 -0
- package/dist/src/dht/find/FindSessionRpcLocal.js.map +1 -0
- package/dist/src/dht/find/{RemoteRecursiveFindSession.d.ts → FindSessionRpcRemote.d.ts} +2 -2
- package/dist/src/dht/find/{RemoteRecursiveFindSession.js → FindSessionRpcRemote.js} +5 -5
- package/dist/src/dht/find/FindSessionRpcRemote.js.map +1 -0
- package/dist/src/dht/find/{RecursiveFinder.d.ts → Finder.d.ts} +16 -19
- package/dist/src/dht/find/{RecursiveFinder.js → Finder.js} +50 -46
- package/dist/src/dht/find/Finder.js.map +1 -0
- package/dist/src/dht/routing/FindRpcRemote.d.ts +6 -0
- package/dist/src/dht/routing/FindRpcRemote.js +41 -0
- package/dist/src/dht/routing/FindRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/Router.d.ts +10 -17
- package/dist/src/dht/routing/Router.js +50 -93
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +22 -0
- package/dist/src/dht/routing/RouterRpcLocal.js +66 -0
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -0
- package/dist/src/dht/routing/RouterRpcRemote.d.ts +0 -1
- package/dist/src/dht/routing/RouterRpcRemote.js +17 -45
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +17 -8
- package/dist/src/dht/routing/RoutingSession.js +124 -131
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/routing/getPreviousPeer.d.ts +2 -0
- package/dist/src/dht/routing/getPreviousPeer.js +9 -0
- package/dist/src/dht/routing/getPreviousPeer.js.map +1 -0
- package/dist/src/dht/store/StoreRpcLocal.d.ts +11 -8
- package/dist/src/dht/store/StoreRpcLocal.js +26 -25
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/dht/store/StoreRpcRemote.js +6 -10
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -1
- package/dist/src/exports.d.ts +11 -5
- package/dist/src/exports.js +17 -4
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/Connectivity.d.ts +4 -0
- package/dist/src/helpers/Connectivity.js +24 -0
- package/dist/src/helpers/Connectivity.js.map +1 -0
- package/dist/src/helpers/errors.d.ts +3 -3
- package/dist/src/helpers/errors.js +7 -7
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +7 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +56 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +49 -36
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +85 -96
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +82 -71
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +26 -21
- package/dist/src/rpc-protocol/DhtCallContext.d.ts +0 -1
- package/dist/src/rpc-protocol/DhtCallContext.js.map +1 -1
- package/dist/src/transport/ITransport.d.ts +5 -6
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -1
- package/dist/src/transport/RoutingRpcCommunicator.js +0 -1
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/dist/src/types/ServiceID.d.ts +1 -0
- package/dist/src/types/ServiceID.js +3 -0
- package/dist/src/types/ServiceID.js.map +1 -0
- package/karma.config.js +4 -4
- package/package.json +10 -8
- package/protos/DhtRpc.proto +41 -40
- package/src/connection/ConnectionLockHandler.ts +19 -17
- package/src/connection/ConnectionLockRpcLocal.ts +74 -0
- package/src/connection/ConnectionLockRpcRemote.ts +11 -11
- package/src/connection/ConnectionManager.ts +88 -130
- package/src/connection/ConnectivityChecker.ts +36 -34
- package/src/connection/ConnectorFacade.ts +91 -40
- package/src/connection/Handshaker.ts +20 -23
- package/src/connection/IConnection.ts +5 -6
- package/src/connection/ManagedConnection.ts +76 -101
- package/src/connection/{ManagedWebRtcConnection.ts → ManagedWebrtcConnection.ts} +12 -10
- package/src/connection/{Simulator → simulator}/Simulator.ts +4 -4
- package/src/connection/{Simulator → simulator}/SimulatorConnection.ts +27 -27
- package/src/connection/{Simulator → simulator}/SimulatorConnector.ts +22 -23
- package/src/connection/{Simulator → simulator}/SimulatorTransport.ts +2 -2
- package/src/connection/{WebRTC/BrowserWebRtcConnection.ts → webrtc/BrowserWebrtcConnection.ts} +13 -14
- package/src/connection/{WebRTC/IWebRtcConnection.ts → webrtc/IWebrtcConnection.ts} +2 -2
- package/src/connection/{WebRTC/NodeWebRtcConnection.ts → webrtc/NodeWebrtcConnection.ts} +38 -40
- package/src/connection/webrtc/WebrtcConnector.ts +226 -0
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +132 -0
- package/src/connection/{WebRTC/WebRtcConnectorRpcRemote.ts → webrtc/WebrtcConnectorRpcRemote.ts} +6 -7
- package/src/connection/{WebRTC → webrtc}/iceServerAsString.ts +1 -1
- package/src/connection/websocket/AutoCertifierClientFacade.ts +91 -0
- package/src/connection/{WebSocket/ClientWebSocket.ts → websocket/ClientWebsocket.ts} +22 -17
- package/src/connection/{WebSocket/ServerWebSocket.ts → websocket/ServerWebsocket.ts} +23 -27
- package/src/connection/websocket/WebsocketConnector.ts +328 -0
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +41 -0
- package/src/connection/{WebSocket/WebSocketConnectorRpcRemote.ts → websocket/WebsocketConnectorRpcRemote.ts} +8 -14
- package/src/connection/{WebSocket/WebSocketServer.ts → websocket/WebsocketServer.ts} +40 -22
- package/src/dht/DhtNode.ts +166 -193
- package/src/dht/DhtNodeRpcLocal.ts +68 -0
- package/src/dht/{RemoteDhtNode.ts → DhtNodeRpcRemote.ts} +17 -18
- package/src/dht/ExternalApiRpcLocal.ts +46 -0
- package/src/dht/ExternalApiRpcRemote.ts +4 -4
- package/src/dht/contact/Remote.ts +32 -4
- package/src/dht/contact/SortedContactList.ts +4 -4
- package/src/dht/discovery/DiscoverySession.ts +25 -22
- package/src/dht/discovery/PeerDiscovery.ts +16 -19
- package/src/dht/find/FindRpcLocal.ts +35 -0
- package/src/dht/find/{RecursiveFindSession.ts → FindSession.ts} +25 -25
- package/src/dht/find/FindSessionRpcLocal.ts +25 -0
- package/src/dht/find/{RemoteRecursiveFindSession.ts → FindSessionRpcRemote.ts} +9 -5
- package/src/dht/find/{RecursiveFinder.ts → Finder.ts} +77 -71
- package/src/dht/routing/FindRpcRemote.ts +40 -0
- package/src/dht/routing/Router.ts +78 -109
- package/src/dht/routing/RouterRpcLocal.ts +81 -0
- package/src/dht/routing/RouterRpcRemote.ts +18 -49
- package/src/dht/routing/RoutingSession.ts +58 -63
- package/src/dht/routing/getPreviousPeer.ts +6 -0
- package/src/dht/store/StoreRpcLocal.ts +46 -39
- package/src/dht/store/StoreRpcRemote.ts +8 -12
- package/src/exports.ts +11 -5
- package/src/helpers/Connectivity.ts +19 -0
- package/src/helpers/errors.ts +3 -3
- package/src/helpers/peerIdFromPeerDescriptor.ts +6 -0
- package/src/helpers/protoClasses.ts +6 -6
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +75 -59
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +26 -21
- package/src/proto/packages/dht/protos/DhtRpc.ts +112 -131
- package/src/rpc-protocol/DhtCallContext.ts +0 -1
- package/src/transport/ITransport.ts +5 -8
- package/src/transport/ListeningRpcCommunicator.ts +2 -1
- package/src/transport/RoutingRpcCommunicator.ts +3 -4
- package/src/types/ServiceID.ts +1 -0
- package/test/benchmark/{RecursiveFind.test.ts → Find.test.ts} +7 -7
- package/test/benchmark/KademliaCorrectness.test.ts +3 -3
- package/test/benchmark/kademlia-simulation/SimulationNode.ts +3 -3
- package/test/end-to-end/Layer0-Layer1.test.ts +13 -5
- package/test/end-to-end/Layer0.test.ts +35 -17
- package/test/end-to-end/Layer0MixedConnectionTypes.test.ts +28 -9
- package/test/end-to-end/{Layer0WebRTC-Layer1.test.ts → Layer0Webrtc-Layer1.test.ts} +1 -1
- package/test/end-to-end/{Layer0WebRTC.test.ts → Layer0Webrtc.test.ts} +14 -10
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +8 -4
- package/test/end-to-end/{Layer1-Scale-WebRTC.test.ts → Layer1-Scale-Webrtc.test.ts} +2 -2
- package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +52 -0
- package/test/end-to-end/{WebSocketConnectionRequest.test.ts → WebsocketConnectionRequest.test.ts} +16 -8
- package/test/end-to-end/memory-leak.test.ts +85 -0
- package/test/integration/ConnectionLocking.test.ts +10 -7
- package/test/integration/ConnectionManager.test.ts +107 -30
- package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -2
- package/test/integration/DhtNodeExternalAPI.test.ts +10 -10
- package/test/integration/{RemoteDhtNode.test.ts → DhtNodeRpcRemote.test.ts} +10 -10
- package/test/integration/DhtRpc.test.ts +5 -5
- package/test/integration/{RecursiveFind.test.ts → Find.test.ts} +6 -9
- package/test/integration/Layer1-scale.test.ts +1 -1
- package/test/integration/MigrateData.test.ts +8 -7
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -1
- package/test/integration/MultipleEntryPointJoining.test.ts +8 -8
- package/test/integration/RouteMessage.test.ts +26 -26
- package/test/integration/RpcErrors.test.ts +10 -10
- package/test/integration/ScaleDownDht.test.ts +6 -6
- package/test/integration/SimultaneousConnections.test.ts +10 -7
- package/test/integration/Store.test.ts +4 -7
- package/test/integration/StoreAndDelete.test.ts +4 -7
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +12 -12
- package/test/integration/{WebRtcConnectionManagement.test.ts → WebrtcConnectionManagement.test.ts} +5 -5
- package/test/integration/{WebRtcConnectorRpc.test.ts → WebrtcConnectorRpc.test.ts} +7 -8
- package/test/integration/{WebSocket.test.ts → Websocket.test.ts} +14 -13
- package/test/integration/{WebSocketConnectionManagement.test.ts → WebsocketConnectionManagement.test.ts} +4 -4
- package/test/integration/{WebSocketConnectorRpc.test.ts → WebsocketConnectorRpc.test.ts} +15 -15
- package/test/unit/AutoCertifierClientFacade.test.ts +58 -0
- package/test/unit/ConnectivityHelpers.test.ts +69 -0
- package/test/unit/{RecursiveFinder.test.ts → Finder.test.ts} +19 -17
- package/test/unit/Router.test.ts +26 -26
- package/test/unit/UUID.test.ts +1 -1
- package/test/unit/{WebSocketConnectorRpcLocal.test.ts → WebsocketConnector.test.ts} +8 -8
- package/test/unit/{WebSocketServer.test.ts → WebsocketServer.test.ts} +20 -14
- package/test/unit/webrtcReplaceInternalIpWithExternalIp.test.ts +1 -1
- package/test/utils/FakeRpcCommunicator.ts +23 -0
- package/test/utils/mock/Transport.ts +1 -1
- package/test/utils/utils.ts +22 -26
- package/tsconfig.browser.json +1 -1
- package/tsconfig.jest.json +3 -2
- package/tsconfig.node.json +3 -2
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +0 -7
- package/dist/src/connection/ManagedWebRtcConnection.js +0 -20
- package/dist/src/connection/ManagedWebRtcConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +0 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +0 -1
- package/dist/src/connection/WebRTC/IWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.d.ts +0 -51
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js +0 -249
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/ClientWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/ServerWebSocket.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.d.ts +0 -45
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js +0 -234
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +0 -1
- package/dist/src/dht/RemoteDhtNode.js.map +0 -1
- package/dist/src/dht/find/RecursiveFindSession.js.map +0 -1
- package/dist/src/dht/find/RecursiveFinder.js.map +0 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +0 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +0 -2
- package/dist/src/dht/registerExternalApiRpcMethods.js +0 -32
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +0 -1
- package/src/connection/WebRTC/WebRtcConnectorRpcLocal.ts +0 -335
- package/src/connection/WebSocket/WebSocketConnectorRpcLocal.ts +0 -295
- package/src/dht/registerExternalApiRpcMethods.ts +0 -44
- package/test/utils/mock/RecursiveFinder.ts +0 -19
- /package/dist/src/connection/{Simulator → simulator}/Simulator.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.d.ts +0 -0
- /package/dist/src/connection/{Simulator → simulator}/pings.js +0 -0
- /package/dist/src/connection/{WebRTC → webrtc}/iceServerAsString.js +0 -0
- /package/src/connection/{Simulator → simulator}/pings.ts +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.WebrtcConnector = exports.replaceInternalIpWithExternalIp = void 0;
|
|
27
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
28
|
+
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
29
|
+
const NodeWebrtcConnection_1 = require("./NodeWebrtcConnection");
|
|
30
|
+
const WebrtcConnectorRpcRemote_1 = require("./WebrtcConnectorRpcRemote");
|
|
31
|
+
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
32
|
+
const ManagedWebrtcConnection_1 = require("../ManagedWebrtcConnection");
|
|
33
|
+
const utils_1 = require("@streamr/utils");
|
|
34
|
+
const Err = __importStar(require("../../helpers/errors"));
|
|
35
|
+
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
36
|
+
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
37
|
+
const WebrtcConnectorRpcLocal_1 = require("./WebrtcConnectorRpcLocal");
|
|
38
|
+
const logger = new utils_1.Logger(module);
|
|
39
|
+
const replaceInternalIpWithExternalIp = (candidate, ip) => {
|
|
40
|
+
const parsed = candidate.split(' ');
|
|
41
|
+
const type = parsed[7];
|
|
42
|
+
if (type === 'host') {
|
|
43
|
+
parsed[4] = ip;
|
|
44
|
+
}
|
|
45
|
+
return parsed.join(' ');
|
|
46
|
+
};
|
|
47
|
+
exports.replaceInternalIpWithExternalIp = replaceInternalIpWithExternalIp;
|
|
48
|
+
class WebrtcConnector {
|
|
49
|
+
constructor(config, onNewConnection) {
|
|
50
|
+
this.ongoingConnectAttempts = new Map();
|
|
51
|
+
this.stopped = false;
|
|
52
|
+
this.config = config;
|
|
53
|
+
this.iceServers = config.iceServers ?? [];
|
|
54
|
+
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID, config.transport, {
|
|
55
|
+
rpcRequestTimeout: 15000
|
|
56
|
+
});
|
|
57
|
+
this.registerLocalRpcMethods(config, onNewConnection);
|
|
58
|
+
}
|
|
59
|
+
registerLocalRpcMethods(config, onNewConnection) {
|
|
60
|
+
const localRpc = new WebrtcConnectorRpcLocal_1.WebrtcConnectorRpcLocal({
|
|
61
|
+
connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
62
|
+
onNewConnection,
|
|
63
|
+
ongoingConnectAttempts: this.ongoingConnectAttempts,
|
|
64
|
+
rpcCommunicator: this.rpcCommunicator,
|
|
65
|
+
getLocalPeerDescriptor: () => this.localPeerDescriptor,
|
|
66
|
+
allowPrivateAddresses: config.allowPrivateAddresses ?? true
|
|
67
|
+
});
|
|
68
|
+
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.WebrtcConnectionRequest, 'requestConnection', async (_req, context) => {
|
|
69
|
+
if (!this.stopped) {
|
|
70
|
+
return localRpc.requestConnection(context);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.RtcOffer, 'rtcOffer', async (req, context) => {
|
|
77
|
+
if (!this.stopped) {
|
|
78
|
+
return localRpc.rtcOffer(req, context);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.RtcAnswer, 'rtcAnswer', async (req, context) => {
|
|
85
|
+
if (!this.stopped) {
|
|
86
|
+
return localRpc.rtcAnswer(req, context);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return {};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.IceCandidate, 'iceCandidate', async (req, context) => {
|
|
93
|
+
if (!this.stopped) {
|
|
94
|
+
return localRpc.iceCandidate(req, context);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return {};
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
connect(targetPeerDescriptor) {
|
|
102
|
+
if ((0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.localPeerDescriptor)) {
|
|
103
|
+
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self');
|
|
104
|
+
}
|
|
105
|
+
logger.trace(`Opening WebRTC connection to ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor)}`);
|
|
106
|
+
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor);
|
|
107
|
+
const existingConnection = this.ongoingConnectAttempts.get(peerKey);
|
|
108
|
+
if (existingConnection) {
|
|
109
|
+
return existingConnection;
|
|
110
|
+
}
|
|
111
|
+
const connection = new NodeWebrtcConnection_1.NodeWebrtcConnection({
|
|
112
|
+
remotePeerDescriptor: targetPeerDescriptor,
|
|
113
|
+
iceServers: this.iceServers,
|
|
114
|
+
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
115
|
+
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
116
|
+
connectingTimeout: this.config.connectionTimeout,
|
|
117
|
+
portRange: this.config.portRange
|
|
118
|
+
});
|
|
119
|
+
const offering = this.isOffering(targetPeerDescriptor);
|
|
120
|
+
let managedConnection;
|
|
121
|
+
if (offering) {
|
|
122
|
+
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.localPeerDescriptor, connection);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.localPeerDescriptor, undefined, connection);
|
|
126
|
+
}
|
|
127
|
+
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
128
|
+
this.ongoingConnectAttempts.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
129
|
+
const delFunc = () => {
|
|
130
|
+
this.ongoingConnectAttempts.delete(peerKey);
|
|
131
|
+
connection.off('disconnected', delFunc);
|
|
132
|
+
managedConnection.off('handshakeCompleted', delFunc);
|
|
133
|
+
};
|
|
134
|
+
connection.on('disconnected', delFunc);
|
|
135
|
+
managedConnection.on('handshakeCompleted', delFunc);
|
|
136
|
+
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.localPeerDescriptor, targetPeerDescriptor, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebrtcConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
|
|
137
|
+
connection.on('localCandidate', (candidate, mid) => {
|
|
138
|
+
if (this.config.externalIp) {
|
|
139
|
+
candidate = (0, exports.replaceInternalIpWithExternalIp)(candidate, this.config.externalIp);
|
|
140
|
+
logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`);
|
|
141
|
+
}
|
|
142
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString());
|
|
143
|
+
});
|
|
144
|
+
if (offering) {
|
|
145
|
+
connection.once('localDescription', (description) => {
|
|
146
|
+
remoteConnector.sendRtcOffer(description, connection.connectionId.toString());
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
connection.once('localDescription', (description) => {
|
|
151
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId.toString());
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
connection.start(offering);
|
|
155
|
+
if (!offering) {
|
|
156
|
+
remoteConnector.requestConnection();
|
|
157
|
+
}
|
|
158
|
+
return managedConnection;
|
|
159
|
+
}
|
|
160
|
+
setLocalPeerDescriptor(peerDescriptor) {
|
|
161
|
+
this.localPeerDescriptor = peerDescriptor;
|
|
162
|
+
}
|
|
163
|
+
async stop() {
|
|
164
|
+
logger.trace('stop()');
|
|
165
|
+
this.stopped = true;
|
|
166
|
+
const attempts = Array.from(this.ongoingConnectAttempts.values());
|
|
167
|
+
await Promise.allSettled(attempts.map((conn) => conn.close(false)));
|
|
168
|
+
this.rpcCommunicator.destroy();
|
|
169
|
+
}
|
|
170
|
+
isOffering(targetPeerDescriptor) {
|
|
171
|
+
const myId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(this.localPeerDescriptor);
|
|
172
|
+
const theirId = (0, peerIdFromPeerDescriptor_1.peerIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
173
|
+
return myId.hasSmallerHashThan(theirId);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.WebrtcConnector = WebrtcConnector;
|
|
177
|
+
WebrtcConnector.WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector';
|
|
178
|
+
//# sourceMappingURL=WebrtcConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebrtcConnector.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAK+C;AAE/C,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,iFAAwF;AAExF,wEAAoE;AACpE,0CAAuC;AACvC,0DAA2C;AAE3C,kDAAqD;AACrD,qFAK+C;AAG/C,uEAAmE;AAEnE,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,+BAA+B,GAAG,CAAC,SAAiB,EAAE,EAAU,EAAU,EAAE;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACtB,IAAI,IAAI,KAAK,MAAM,EAAE;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;KACjB;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC,CAAA;AAPY,QAAA,+BAA+B,mCAO3C;AAsBD,MAAa,eAAe;IAUxB,YACI,MAA6B,EAC7B,eAA2D;QAR9C,2BAAsB,GAA4C,IAAI,GAAG,EAAE,CAAA;QAEpF,YAAO,GAAG,KAAK,CAAA;QAQnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,EAAE,CAAA;QACzC,IAAI,CAAC,eAAe,GAAG,IAAI,mDAAwB,CAAC,eAAe,CAAC,2BAA2B,EAAE,MAAM,CAAC,SAAS,EAAE;YAC/G,iBAAiB,EAAE,KAAK;SAC3B,CAAC,CAAA;QACF,IAAI,CAAC,uBAAuB,CAAC,MAAM,EA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,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;IAEM,UAAU,CAAC,oBAAoC;QAClD,MAAM,IAAI,GAAG,IAAA,mDAAwB,EAAC,IAAI,CAAC,mBAAoB,CAAC,CAAA;QAChE,MAAM,OAAO,GAAG,IAAA,mDAAwB,EAAC,oBAAoB,CAAC,CAAA;QAC9D,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;;AAtKL,0CAuKC;AArK2B,2CAA2B,GAAG,yBAAyB,AAA5B,CAA4B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
2
|
+
import { PeerIDKey } from '../../helpers/PeerID';
|
|
3
|
+
import { Empty } from '../../proto/google/protobuf/empty';
|
|
4
|
+
import { IceCandidate, PeerDescriptor, RtcAnswer, RtcOffer } from '../../proto/packages/dht/protos/DhtRpc';
|
|
5
|
+
import { IWebrtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
6
|
+
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator';
|
|
7
|
+
import { ManagedConnection } from '../ManagedConnection';
|
|
8
|
+
import { ManagedWebrtcConnection } from '../ManagedWebrtcConnection';
|
|
9
|
+
interface WebrtcConnectorRpcLocalConfig {
|
|
10
|
+
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
11
|
+
onNewConnection: (connection: ManagedConnection) => boolean;
|
|
12
|
+
ongoingConnectAttempts: Map<PeerIDKey, ManagedWebrtcConnection>;
|
|
13
|
+
rpcCommunicator: ListeningRpcCommunicator;
|
|
14
|
+
getLocalPeerDescriptor: () => PeerDescriptor;
|
|
15
|
+
allowPrivateAddresses: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
18
|
+
private readonly config;
|
|
19
|
+
constructor(config: WebrtcConnectorRpcLocalConfig);
|
|
20
|
+
requestConnection(context: ServerCallContext): Promise<Empty>;
|
|
21
|
+
rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty>;
|
|
22
|
+
rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty>;
|
|
23
|
+
iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty>;
|
|
24
|
+
private isIceCandidateAllowed;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebrtcConnectorRpcLocal = void 0;
|
|
4
|
+
const proto_rpc_1 = require("@streamr/proto-rpc");
|
|
5
|
+
const utils_1 = require("@streamr/utils");
|
|
6
|
+
const AddressTools_1 = require("../../helpers/AddressTools");
|
|
7
|
+
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
8
|
+
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
9
|
+
const ManagedWebrtcConnection_1 = require("../ManagedWebrtcConnection");
|
|
10
|
+
const NodeWebrtcConnection_1 = require("./NodeWebrtcConnection");
|
|
11
|
+
const WebrtcConnectorRpcRemote_1 = require("./WebrtcConnectorRpcRemote");
|
|
12
|
+
const logger = new utils_1.Logger(module);
|
|
13
|
+
class WebrtcConnectorRpcLocal {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
async requestConnection(context) {
|
|
18
|
+
const targetPeerDescriptor = context.incomingSourceDescriptor;
|
|
19
|
+
if (this.config.ongoingConnectAttempts.has((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor))) {
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
const managedConnection = this.config.connect(targetPeerDescriptor);
|
|
23
|
+
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
24
|
+
this.config.onNewConnection(managedConnection);
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
async rtcOffer(request, context) {
|
|
28
|
+
const remotePeer = context.incomingSourceDescriptor;
|
|
29
|
+
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeer);
|
|
30
|
+
let managedConnection = this.config.ongoingConnectAttempts.get(peerKey);
|
|
31
|
+
let connection = managedConnection?.getWebrtcConnection();
|
|
32
|
+
if (!managedConnection) {
|
|
33
|
+
connection = new NodeWebrtcConnection_1.NodeWebrtcConnection({ remotePeerDescriptor: remotePeer });
|
|
34
|
+
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection);
|
|
35
|
+
managedConnection.setRemotePeerDescriptor(remotePeer);
|
|
36
|
+
this.config.ongoingConnectAttempts.set(peerKey, managedConnection);
|
|
37
|
+
this.config.onNewConnection(managedConnection);
|
|
38
|
+
const remoteConnector = new WebrtcConnectorRpcRemote_1.WebrtcConnectorRpcRemote(this.config.getLocalPeerDescriptor(), remotePeer, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebrtcConnectorRpcClient(this.config.rpcCommunicator.getRpcClientTransport())));
|
|
39
|
+
connection.on('localCandidate', (candidate, mid) => {
|
|
40
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString());
|
|
41
|
+
});
|
|
42
|
+
connection.once('localDescription', (description) => {
|
|
43
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId.toString());
|
|
44
|
+
});
|
|
45
|
+
connection.start(false);
|
|
46
|
+
}
|
|
47
|
+
// Always use offerers connectionId
|
|
48
|
+
connection.setConnectionId(request.connectionId);
|
|
49
|
+
connection.setRemoteDescription(request.description, 'offer');
|
|
50
|
+
managedConnection.on('handshakeRequest', () => {
|
|
51
|
+
if (this.config.ongoingConnectAttempts.has(peerKey)) {
|
|
52
|
+
this.config.ongoingConnectAttempts.delete(peerKey);
|
|
53
|
+
}
|
|
54
|
+
managedConnection.acceptHandshake();
|
|
55
|
+
});
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
async rtcAnswer(request, context) {
|
|
59
|
+
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
60
|
+
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeerDescriptor);
|
|
61
|
+
const connection = this.config.ongoingConnectAttempts.get(peerKey)?.getWebrtcConnection();
|
|
62
|
+
if (!connection) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
else if (connection.connectionId.toString() !== request.connectionId) {
|
|
66
|
+
logger.trace(`Ignoring RTC answer due to connectionId mismatch`);
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
connection.setRemoteDescription(request.description, 'answer');
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
async iceCandidate(request, context) {
|
|
73
|
+
const remotePeerDescriptor = context.incomingSourceDescriptor;
|
|
74
|
+
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeerDescriptor);
|
|
75
|
+
const connection = this.config.ongoingConnectAttempts.get(peerKey)?.getWebrtcConnection();
|
|
76
|
+
if (!connection) {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
else if (connection.connectionId.toString() !== request.connectionId) {
|
|
80
|
+
logger.trace(`Ignoring remote candidate due to connectionId mismatch`);
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
else if (this.isIceCandidateAllowed(request.candidate)) {
|
|
84
|
+
connection.addRemoteCandidate(request.candidate, request.mid);
|
|
85
|
+
}
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
isIceCandidateAllowed(candidate) {
|
|
89
|
+
if (!this.config.allowPrivateAddresses) {
|
|
90
|
+
const address = (0, AddressTools_1.getAddressFromIceCandidate)(candidate);
|
|
91
|
+
if (address && (0, AddressTools_1.isPrivateIPv4)(address)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.WebrtcConnectorRpcLocal = WebrtcConnectorRpcLocal;
|
|
99
|
+
//# sourceMappingURL=WebrtcConnectorRpcLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,kDAAqD;AACrD,0CAAuC;AACvC,6DAAsF;AAEtF,qFAA8E;AAQ9E,iFAAwF;AAKxF,wEAAoE;AACpE,iEAA6D;AAC7D,yEAAqE;AAErE,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAYjC,MAAa,uBAAuB;IAIhC,YAAY,MAAqC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,OAA0B;QAC9C,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAA,gDAAqB,EAAC,oBAAoB,CAAC,CAAC,EAAE;YACrF,OAAO,EAAE,CAAA;SACZ;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;QACnE,iBAAiB,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;QAC/D,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;QAC9C,OAAO,EAAE,CAAA;IACb,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAiB,EAAE,OAA0B;QACxD,MAAM,UAAU,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QACxE,MAAM,OAAO,GAAG,IAAA,gDAAqB,EAAC,UAAU,CAAC,CAAA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,GAAG,IAAA,gDAAqB,EAAC,oBAAoB,CAAC,CAAA;QAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,CAAA;QAEzF,IAAI,CAAC,UAAU,EAAE;YACb,OAAO,EAAE,CAAA;SACZ;aAAM,IAAI,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,YAAY,EAAE;YACpE,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAA;YACtE,OAAO,EAAE,CAAA;SACZ;aAAM,IAAI,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACtD,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;SAChE;QACD,OAAO,EAAE,CAAA;IACb,CAAC;IAEO,qBAAqB,CAAC,SAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACpC,MAAM,OAAO,GAAG,IAAA,yCAA0B,EAAC,SAAS,CAAC,CAAA;YACrD,IAAI,OAAO,IAAI,IAAA,4BAAa,EAAC,OAAO,CAAC,EAAE;gBACnC,OAAO,KAAK,CAAA;aACf;SACJ;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAjGD,0DAiGC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Remote } from '../../dht/contact/Remote';
|
|
2
2
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
-
import {
|
|
3
|
+
import { IWebrtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
4
4
|
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
5
|
-
export declare class
|
|
6
|
-
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<
|
|
7
|
-
requestConnection(
|
|
5
|
+
export declare class WebrtcConnectorRpcRemote extends Remote<IWebrtcConnectorRpcClient> {
|
|
6
|
+
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebrtcConnectorRpcClient>);
|
|
7
|
+
requestConnection(): void;
|
|
8
8
|
sendRtcOffer(description: string, connectionId: string): void;
|
|
9
9
|
sendRtcAnswer(description: string, connectionId: string): void;
|
|
10
10
|
sendIceCandidate(candidate: string, mid: string, connectionId: string): void;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebrtcConnectorRpcRemote = void 0;
|
|
4
4
|
const Remote_1 = require("../../dht/contact/Remote");
|
|
5
5
|
const utils_1 = require("@streamr/utils");
|
|
6
6
|
const logger = new utils_1.Logger(module);
|
|
7
|
-
class
|
|
7
|
+
class WebrtcConnectorRpcRemote extends Remote_1.Remote {
|
|
8
8
|
constructor(localPeerDescriptor, remotePeerDescriptor, client) {
|
|
9
9
|
super(localPeerDescriptor, remotePeerDescriptor, 'DUMMY', client);
|
|
10
10
|
}
|
|
11
|
-
requestConnection(
|
|
12
|
-
const request = {
|
|
13
|
-
connectionId
|
|
14
|
-
};
|
|
11
|
+
requestConnection() {
|
|
12
|
+
const request = {};
|
|
15
13
|
const options = this.formDhtRpcOptions({
|
|
16
14
|
notification: true
|
|
17
15
|
});
|
|
@@ -51,5 +49,5 @@ class WebRtcConnectorRpcRemote extends Remote_1.Remote {
|
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
|
-
exports.
|
|
55
|
-
//# sourceMappingURL=
|
|
52
|
+
exports.WebrtcConnectorRpcRemote = WebrtcConnectorRpcRemote;
|
|
53
|
+
//# sourceMappingURL=WebrtcConnectorRpcRemote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Web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AE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACtD,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACN,CAAC;IAED,gBAAgB,CAAC,SAAiB,EAAE,GAAW,EAAE,YAAoB;QACjE,MAAM,OAAO,GAAiB;YAC1B,YAAY;YACZ,GAAG;YACH,SAAS;SACZ,CAAA;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACzD,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAtDD,4DAsDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IceServer } from './
|
|
1
|
+
import { IceServer } from './WebrtcConnector';
|
|
2
2
|
export declare function iceServerAsString({ url, port, username, password, tcp }: IceServer): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iceServerAsString.js","sourceRoot":"","sources":["../../../../src/connection/
|
|
1
|
+
{"version":3,"file":"iceServerAsString.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/iceServerAsString.ts"],"names":[],"mappings":";;;AAEA,SAAgB,iBAAiB,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAa;IAC/E,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC3C,IAAI,QAAQ,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAA;KACtD;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE;QAClD,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAA;KAC3C;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,SAAS,EAAE;QAClD,OAAO,GAAG,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,QAAQ,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;KACjG;IACD,MAAM,IAAI,KAAK,CAAC,aAAa,QAAQ,mBAAmB,QAAQ,6BAA6B,CAAC,CAAA;AAClG,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CertifiedSubdomain } from '@streamr/autocertifier-client';
|
|
2
|
+
import { ITransport } from '../../transport/ITransport';
|
|
3
|
+
export interface IAutoCertifierClient {
|
|
4
|
+
start(): Promise<void>;
|
|
5
|
+
stop(): void;
|
|
6
|
+
on(eventName: string, cb: (subdomain: CertifiedSubdomain) => void): void;
|
|
7
|
+
}
|
|
8
|
+
interface AutoCertifierClientFacadeConfig {
|
|
9
|
+
url: string;
|
|
10
|
+
configFile: string;
|
|
11
|
+
transport: ITransport;
|
|
12
|
+
wsServerPort: number;
|
|
13
|
+
setHost: (host: string) => void;
|
|
14
|
+
updateCertificate: (certificate: string, privateKey: string) => void;
|
|
15
|
+
createClientFactory?: () => IAutoCertifierClient;
|
|
16
|
+
}
|
|
17
|
+
export declare class AutoCertifierClientFacade {
|
|
18
|
+
private autoCertifierClient;
|
|
19
|
+
private readonly rpcCommunicator;
|
|
20
|
+
private readonly setHost;
|
|
21
|
+
private readonly updateCertificate;
|
|
22
|
+
constructor(config: AutoCertifierClientFacadeConfig);
|
|
23
|
+
start(): Promise<void>;
|
|
24
|
+
stop(): void;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AutoCertifierClientFacade = void 0;
|
|
4
|
+
const autocertifier_client_1 = require("@streamr/autocertifier-client");
|
|
5
|
+
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
6
|
+
const utils_1 = require("@streamr/utils");
|
|
7
|
+
const START_TIMEOUT = 60 * 1000;
|
|
8
|
+
const defaultAutoCertifierClientFactory = (configFile, autoCertifierUrl, autoCertifierRpcCommunicator, wsServerPort) => new autocertifier_client_1.AutoCertifierClient(configFile, wsServerPort, autoCertifierUrl, (_serviceId, rpcMethodName, method) => {
|
|
9
|
+
autoCertifierRpcCommunicator.registerRpcMethod(autocertifier_client_1.HasSessionRequest, autocertifier_client_1.HasSessionResponse, rpcMethodName, method);
|
|
10
|
+
});
|
|
11
|
+
const logger = new utils_1.Logger(module);
|
|
12
|
+
class AutoCertifierClientFacade {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.setHost = config.setHost;
|
|
15
|
+
this.updateCertificate = config.updateCertificate;
|
|
16
|
+
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(autocertifier_client_1.SERVICE_ID, config.transport);
|
|
17
|
+
this.autoCertifierClient = config.createClientFactory ? config.createClientFactory()
|
|
18
|
+
: defaultAutoCertifierClientFactory(config.configFile, config.url, this.rpcCommunicator, config.wsServerPort);
|
|
19
|
+
}
|
|
20
|
+
async start() {
|
|
21
|
+
this.autoCertifierClient.on('updatedCertificate', (subdomain) => {
|
|
22
|
+
this.setHost(subdomain.fqdn);
|
|
23
|
+
this.updateCertificate(subdomain.certificate, subdomain.privateKey);
|
|
24
|
+
logger.trace(`Updated certificate`);
|
|
25
|
+
});
|
|
26
|
+
await Promise.all([
|
|
27
|
+
(0, utils_1.waitForEvent3)(this.autoCertifierClient, 'updatedCertificate', START_TIMEOUT),
|
|
28
|
+
this.autoCertifierClient.start()
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
stop() {
|
|
32
|
+
this.autoCertifierClient.stop();
|
|
33
|
+
this.rpcCommunicator.destroy();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.AutoCertifierClientFacade = AutoCertifierClientFacade;
|
|
37
|
+
//# sourceMappingURL=AutoCertifierClientFacade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoCertifierClientFacade.js","sourceRoot":"","sources":["../../../../src/connection/websocket/AutoCertifierClientFacade.ts"],"names":[],"mappings":";;;AAAA,wEAOsC;AACtC,uFAAmF;AACnF,0CAAsD;AAGtD,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAA;AAE/B,MAAM,iCAAiC,GAAG,CACtC,UAAkB,EAClB,gBAAwB,EACxB,4BAAsD,EACtD,YAAoB,EACtB,EAAE,CAAC,IAAI,0CAAmB,CACxB,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,CAAC,UAAkB,EAAE,aAAqB,EAAE,MAAkB,EAAE,EAAE;IAC9D,4BAA4B,CAAC,iBAAiB,CAC1C,wCAAiB,EACjB,yCAAkB,EAClB,aAAa,EACb,MAAM,CACT,CAAA;AACL,CAAC,CACJ,CAAA;AAoBD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,yBAAyB;IAOlC,YAAY,MAAuC;QAC/C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;QACjD,IAAI,CAAC,eAAe,GAAG,IAAI,mDAAwB,CAAC,iCAAyB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAA;QAChG,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE;YAChF,CAAC,CAAC,iCAAiC,CAC/B,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,GAAG,EACV,IAAI,CAAC,eAAe,EACpB,MAAM,CAAC,YAAY,CACtB,CAAA;IACT,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,SAA6B,EAAE,EAAE;YAChF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;YAC5B,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;YACnE,MAAM,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;QACF,MAAM,OAAO,CAAC,GAAG,CAAC;YACd,IAAA,qBAAa,EAAC,IAAI,CAAC,mBAA0B,EAAE,oBAAoB,EAAE,aAAa,CAAC;YACnF,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE;SACnC,CAAC,CAAA;IACN,CAAC;IAED,IAAI;QACA,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;CAEJ;AArCD,8DAqCC"}
|
package/dist/src/connection/{WebSocket/ClientWebSocket.d.ts → websocket/ClientWebsocket.d.ts}
RENAMED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { IConnection, ConnectionID, ConnectionType, ConnectionEvents } from '../IConnection';
|
|
2
1
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
|
|
2
|
+
import { ConnectionEvents, ConnectionID, ConnectionType, IConnection } from '../IConnection';
|
|
3
|
+
export declare const GOING_AWAY = 1001;
|
|
4
|
+
export declare class ClientWebsocket extends EventEmitter<ConnectionEvents> implements IConnection {
|
|
4
5
|
readonly connectionId: ConnectionID;
|
|
5
6
|
private socket?;
|
|
6
7
|
connectionType: ConnectionType;
|
|
7
8
|
private destroyed;
|
|
8
9
|
constructor();
|
|
9
|
-
connect(address: string): void;
|
|
10
|
+
connect(address: string, selfSigned?: boolean): void;
|
|
10
11
|
private doDisconnect;
|
|
11
12
|
send(data: Uint8Array): void;
|
|
12
|
-
close(): Promise<void>;
|
|
13
|
+
close(gracefulLeave: boolean): Promise<void>;
|
|
13
14
|
private stopListening;
|
|
14
15
|
destroy(): void;
|
|
15
16
|
}
|
|
@@ -3,27 +3,30 @@ 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.
|
|
7
|
-
const IConnection_1 = require("../IConnection");
|
|
8
|
-
const websocket_1 = require("websocket");
|
|
9
|
-
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
6
|
+
exports.ClientWebsocket = exports.GOING_AWAY = void 0;
|
|
10
7
|
const utils_1 = require("@streamr/utils");
|
|
8
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
9
|
+
const websocket_1 = require("websocket");
|
|
10
|
+
const IConnection_1 = require("../IConnection");
|
|
11
11
|
const logger = new utils_1.Logger(module);
|
|
12
|
+
// https://kapeli.com/cheat_sheets/WebSocket_Status_Codes.docset/Contents/Resources/Documents/index
|
|
13
|
+
// Browsers send this automatically when closing a tab
|
|
14
|
+
exports.GOING_AWAY = 1001;
|
|
12
15
|
const BINARY_TYPE = 'arraybuffer';
|
|
13
|
-
class
|
|
16
|
+
class ClientWebsocket extends eventemitter3_1.default {
|
|
14
17
|
constructor() {
|
|
15
18
|
super();
|
|
16
19
|
this.connectionType = IConnection_1.ConnectionType.WEBSOCKET_CLIENT;
|
|
17
20
|
this.destroyed = false;
|
|
18
21
|
this.connectionId = new IConnection_1.ConnectionID();
|
|
19
22
|
}
|
|
20
|
-
connect(address) {
|
|
23
|
+
connect(address, selfSigned) {
|
|
21
24
|
if (!this.destroyed) {
|
|
22
|
-
this.socket = new websocket_1.w3cwebsocket(address);
|
|
25
|
+
this.socket = new websocket_1.w3cwebsocket(address, undefined, undefined, undefined, { rejectUnauthorized: !selfSigned });
|
|
23
26
|
this.socket.binaryType = BINARY_TYPE;
|
|
24
27
|
this.socket.onerror = (error) => {
|
|
25
28
|
if (!this.destroyed) {
|
|
26
|
-
logger.trace('WebSocket Client error: ' + error);
|
|
29
|
+
logger.trace('WebSocket Client error: ' + error?.message, { error });
|
|
27
30
|
this.emit('error', error.name);
|
|
28
31
|
}
|
|
29
32
|
};
|
|
@@ -38,7 +41,7 @@ class ClientWebSocket extends eventemitter3_1.default {
|
|
|
38
41
|
this.socket.onclose = (event) => {
|
|
39
42
|
if (!this.destroyed) {
|
|
40
43
|
logger.trace('Websocket Closed');
|
|
41
|
-
this.doDisconnect(
|
|
44
|
+
this.doDisconnect(event.code, event.reason);
|
|
42
45
|
}
|
|
43
46
|
};
|
|
44
47
|
this.socket.onmessage = (message) => {
|
|
@@ -56,11 +59,12 @@ class ClientWebSocket extends eventemitter3_1.default {
|
|
|
56
59
|
logger.debug('Tried to connect() a stopped connection');
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
doDisconnect(
|
|
62
|
+
doDisconnect(code, reason) {
|
|
60
63
|
this.destroyed = true;
|
|
61
64
|
this.stopListening();
|
|
62
65
|
this.socket = undefined;
|
|
63
|
-
|
|
66
|
+
const gracefulLeave = code === exports.GOING_AWAY;
|
|
67
|
+
this.emit('disconnected', gracefulLeave, code, reason);
|
|
64
68
|
this.removeAllListeners();
|
|
65
69
|
}
|
|
66
70
|
send(data) {
|
|
@@ -70,17 +74,19 @@ class ClientWebSocket extends eventemitter3_1.default {
|
|
|
70
74
|
this.socket?.send(data.buffer);
|
|
71
75
|
}
|
|
72
76
|
else {
|
|
73
|
-
logger.
|
|
77
|
+
logger.debug('Tried to send data on a non-open connection');
|
|
74
78
|
}
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
81
|
logger.debug('Tried to send() on stopped connection');
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
|
-
async close() {
|
|
84
|
+
async close(gracefulLeave) {
|
|
85
|
+
this.emit('disconnected', gracefulLeave, undefined, 'close() called');
|
|
86
|
+
this.removeAllListeners();
|
|
81
87
|
if (!this.destroyed) {
|
|
82
88
|
logger.trace(`Closing socket for connection ${this.connectionId.toString()}`);
|
|
83
|
-
this.socket?.close();
|
|
89
|
+
this.socket?.close(gracefulLeave === true ? exports.GOING_AWAY : undefined);
|
|
84
90
|
}
|
|
85
91
|
else {
|
|
86
92
|
logger.debug('Tried to close() a stopped connection');
|
|
@@ -95,6 +101,7 @@ class ClientWebSocket extends eventemitter3_1.default {
|
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
103
|
destroy() {
|
|
104
|
+
logger.trace('destroy() a connection');
|
|
98
105
|
if (!this.destroyed) {
|
|
99
106
|
this.removeAllListeners();
|
|
100
107
|
if (this.socket) {
|
|
@@ -109,5 +116,5 @@ class ClientWebSocket extends eventemitter3_1.default {
|
|
|
109
116
|
}
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
|
-
exports.
|
|
113
|
-
//# sourceMappingURL=
|
|
119
|
+
exports.ClientWebsocket = ClientWebsocket;
|
|
120
|
+
//# sourceMappingURL=ClientWebsocket.js.map
|
|
@@ -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,SAAQ,uBAA8B;IAO/D;QACI,KAAK,EAAE,CAAA;QALJ,mBAAc,GAAG,4BAAc,CAAC,gBAAgB,CAAA;QAE/C,cAAS,GA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CAAC,SAAS,GAAG,IAAI,CAAA;SACxB;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAA;SAC1D;IACL,CAAC;CACJ;AA7GD,0CA6GC"}
|
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
|
}
|