@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
|
@@ -8,10 +8,10 @@ const protoToString_1 = require("../../helpers/protoToString");
|
|
|
8
8
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
9
9
|
const logger = new utils_1.Logger(module);
|
|
10
10
|
class SimulatorConnection extends Connection_1.Connection {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(localPeerDescriptor, targetPeerDescriptor, connectionType, simulator) {
|
|
12
12
|
super(connectionType);
|
|
13
13
|
this.stopped = false;
|
|
14
|
-
this.
|
|
14
|
+
this.localPeerDescriptor = localPeerDescriptor;
|
|
15
15
|
this.setPeerDescriptor(targetPeerDescriptor);
|
|
16
16
|
this.targetPeerDescriptor = targetPeerDescriptor;
|
|
17
17
|
this.connectionType = connectionType;
|
|
@@ -30,35 +30,36 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
30
30
|
this.simulator.send(this, data);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
logger.error((0, peerIdFromPeerDescriptor_1.
|
|
33
|
+
logger.error((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
34
34
|
'tried to send() on a stopped connection');
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
async close(
|
|
38
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
37
|
+
async close(gracefulLeave) {
|
|
38
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor)
|
|
39
|
+
+ ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) + ' close()');
|
|
39
40
|
if (!this.stopped) {
|
|
40
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
41
|
-
+ (0, peerIdFromPeerDescriptor_1.
|
|
41
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', '
|
|
42
|
+
+ (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) + ' close() not stopped');
|
|
42
43
|
this.stopped = true;
|
|
43
44
|
try {
|
|
44
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
45
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
45
46
|
' close() calling simulator.disconnect()');
|
|
46
47
|
this.simulator.close(this);
|
|
47
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
48
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
48
49
|
' close() simulator.disconnect returned');
|
|
49
50
|
}
|
|
50
51
|
catch (e) {
|
|
51
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
52
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
52
53
|
'close aborted' + e);
|
|
53
54
|
}
|
|
54
55
|
finally {
|
|
55
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
56
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
56
57
|
' calling this.doDisconnect');
|
|
57
|
-
this.doDisconnect(
|
|
58
|
+
this.doDisconnect(gracefulLeave);
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
62
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) +
|
|
62
63
|
' close() tried to close a stopped connection');
|
|
63
64
|
}
|
|
64
65
|
}
|
|
@@ -68,7 +69,7 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
68
69
|
this.simulator.connect(this, this.targetPeerDescriptor, (error) => {
|
|
69
70
|
if (error) {
|
|
70
71
|
logger.trace(error);
|
|
71
|
-
this.doDisconnect(
|
|
72
|
+
this.doDisconnect(false);
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
75
|
this.emit('connected');
|
|
@@ -91,9 +92,9 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
91
92
|
}
|
|
92
93
|
handleIncomingDisconnection() {
|
|
93
94
|
if (!this.stopped) {
|
|
94
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
95
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ' handleIncomingDisconnection()');
|
|
95
96
|
this.stopped = true;
|
|
96
|
-
this.doDisconnect(
|
|
97
|
+
this.doDisconnect(false);
|
|
97
98
|
}
|
|
98
99
|
else {
|
|
99
100
|
logger.trace('tried to call handleIncomingDisconnection() a stopped connection');
|
|
@@ -101,20 +102,20 @@ class SimulatorConnection extends Connection_1.Connection {
|
|
|
101
102
|
}
|
|
102
103
|
destroy() {
|
|
103
104
|
if (!this.stopped) {
|
|
104
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
105
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ' destroy()');
|
|
105
106
|
this.removeAllListeners();
|
|
106
|
-
this.close(
|
|
107
|
+
this.close(false).catch((_e) => { });
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
109
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
110
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ' tried to call destroy() a stopped connection');
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
doDisconnect(
|
|
113
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
113
|
+
doDisconnect(gracefulLeave) {
|
|
114
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ' doDisconnect()');
|
|
114
115
|
this.stopped = true;
|
|
115
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
116
|
-
+ (0, peerIdFromPeerDescriptor_1.
|
|
117
|
-
this.emit('disconnected',
|
|
116
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor) + ', '
|
|
117
|
+
+ (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.targetPeerDescriptor) + ' doDisconnect emitting');
|
|
118
|
+
this.emit('disconnected', gracefulLeave);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
exports.SimulatorConnection = SimulatorConnection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulatorConnection.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorConnection.ts"],"names":[],"mappings":";;;AAEA,mEAAgF;AAChF,8CAA0C;AAC1C,0CAAuC;AACvC,+DAA2D;AAC3D,qFAAoF;AAEpF,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,mBAAoB,SAAQ,uBAAU;IAO/C,YACI,mBAAmC,EACnC,oBAAoC,EACpC,cAA8B,EAC9B,SAAoB;QAEpB,KAAK,CAAC,cAAc,CAAC,CAAA;QAXjB,YAAO,GAAG,KAAK,CAAA;QAanB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;QAC9C,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,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,gCAAgC,CAAC,CAAA;YACtG,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;SAC3B;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAA;SACnF;IACL,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,MAAM,CAAC,KAAK,CAAC,IAAA,sDAA2B,EAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,YAAY,CAAC,CAAA;YAClF,IAAI,CAAC,kBAAkB,EAAE,CAAA;YACzB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAA;SACvC;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,IAAA,sDAA2B,EAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,+CAA+C,CAAC,CAAA;SACxH;IACL,CAAC;IAEO,YAAY,CAAC,aAAsB;QACvC,MAAM,CAAC,KAAK,CAAC,IAAA,sDAA2B,EAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC,CAAA;QACvF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QAEnB,MAAM,CAAC,KAAK,CAAC,IAAA,sDAA2B,EAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI;cACnE,IAAA,sDAA2B,EAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,wBAAwB,CAAC,CAAA;QAExF,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;IAE5C,CAAC;CACJ;AAjID,kDAiIC"}
|
|
@@ -5,10 +5,10 @@ import { SimulatorConnection } from './SimulatorConnection';
|
|
|
5
5
|
export declare class SimulatorConnector {
|
|
6
6
|
private connectingConnections;
|
|
7
7
|
private stopped;
|
|
8
|
-
private
|
|
8
|
+
private localPeerDescriptor;
|
|
9
9
|
private simulator;
|
|
10
|
-
private
|
|
11
|
-
constructor(
|
|
10
|
+
private onNewConnection;
|
|
11
|
+
constructor(localPeerDescriptor: PeerDescriptor, simulator: Simulator, onNewConnection: (connection: ManagedConnection) => boolean);
|
|
12
12
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
13
13
|
getPeerDescriptor(): PeerDescriptor;
|
|
14
14
|
handleIncomingConnection(sourceConnection: SimulatorConnection): void;
|
|
@@ -2,29 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SimulatorConnector = void 0;
|
|
4
4
|
const IConnection_1 = require("../IConnection");
|
|
5
|
+
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
5
6
|
const utils_1 = require("@streamr/utils");
|
|
6
7
|
const ManagedConnection_1 = require("../ManagedConnection");
|
|
7
8
|
const SimulatorConnection_1 = require("./SimulatorConnection");
|
|
8
9
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
9
10
|
const logger = new utils_1.Logger(module);
|
|
10
11
|
class SimulatorConnector {
|
|
11
|
-
constructor(
|
|
12
|
+
constructor(localPeerDescriptor, simulator, onNewConnection) {
|
|
12
13
|
this.connectingConnections = new Map();
|
|
13
14
|
this.stopped = false;
|
|
14
|
-
this.
|
|
15
|
+
this.localPeerDescriptor = localPeerDescriptor;
|
|
15
16
|
this.simulator = simulator;
|
|
16
|
-
this.
|
|
17
|
+
this.onNewConnection = onNewConnection;
|
|
17
18
|
}
|
|
18
19
|
connect(targetPeerDescriptor) {
|
|
19
|
-
logger.trace('connect() ' + (0, peerIdFromPeerDescriptor_1.
|
|
20
|
+
logger.trace('connect() ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor));
|
|
20
21
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor);
|
|
21
22
|
const existingConnection = this.connectingConnections.get(peerKey);
|
|
22
23
|
if (existingConnection) {
|
|
23
24
|
return existingConnection;
|
|
24
25
|
}
|
|
25
|
-
const connection = new SimulatorConnection_1.SimulatorConnection(this.
|
|
26
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
27
|
-
managedConnection.
|
|
26
|
+
const connection = new SimulatorConnection_1.SimulatorConnection(this.localPeerDescriptor, targetPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_CLIENT, this.simulator);
|
|
27
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_CLIENT, connection, undefined);
|
|
28
|
+
managedConnection.setRemotePeerDescriptor(targetPeerDescriptor);
|
|
28
29
|
this.connectingConnections.set(peerKey, managedConnection);
|
|
29
30
|
connection.once('disconnected', () => {
|
|
30
31
|
this.connectingConnections.delete(peerKey);
|
|
@@ -36,26 +37,24 @@ class SimulatorConnector {
|
|
|
36
37
|
return managedConnection;
|
|
37
38
|
}
|
|
38
39
|
getPeerDescriptor() {
|
|
39
|
-
return this.
|
|
40
|
+
return this.localPeerDescriptor;
|
|
40
41
|
}
|
|
41
42
|
handleIncomingConnection(sourceConnection) {
|
|
42
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
43
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' incoming connection, stopped: ' + this.stopped);
|
|
43
44
|
if (this.stopped) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
const connection = new SimulatorConnection_1.SimulatorConnection(this.
|
|
47
|
-
const managedConnection = new ManagedConnection_1.ManagedConnection(this.
|
|
47
|
+
const connection = new SimulatorConnection_1.SimulatorConnection(this.localPeerDescriptor, sourceConnection.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_SERVER, this.simulator);
|
|
48
|
+
const managedConnection = new ManagedConnection_1.ManagedConnection(this.localPeerDescriptor, IConnection_1.ConnectionType.SIMULATOR_SERVER, undefined, connection);
|
|
48
49
|
logger.trace('connected');
|
|
49
50
|
managedConnection.once('handshakeRequest', () => {
|
|
50
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
logger.trace((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(sourceConnection.ownPeerDescriptor) + ' calling acceptHandshake');
|
|
51
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' incoming handshake request');
|
|
52
|
+
if (this.onNewConnection(managedConnection)) {
|
|
53
|
+
logger.trace((0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(sourceConnection.localPeerDescriptor) + ' calling acceptHandshake');
|
|
54
54
|
managedConnection.acceptHandshake();
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
managedConnection.rejectHandshake(
|
|
58
|
-
managedConnection.destroy();
|
|
57
|
+
managedConnection.rejectHandshake(DhtRpc_1.HandshakeError.DUPLICATE_CONNECTION);
|
|
59
58
|
}
|
|
60
59
|
});
|
|
61
60
|
this.simulator.accept(sourceConnection, connection);
|
|
@@ -63,7 +62,7 @@ class SimulatorConnector {
|
|
|
63
62
|
async stop() {
|
|
64
63
|
this.stopped = true;
|
|
65
64
|
const conns = Array.from(this.connectingConnections.values());
|
|
66
|
-
await Promise.allSettled(conns.map((conn) => conn.close(
|
|
65
|
+
await Promise.allSettled(conns.map((conn) => conn.close(false)));
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
exports.SimulatorConnector = SimulatorConnector;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulatorConnector.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorConnector.ts"],"names":[],"mappings":";;;AAAA,gDAA+C;AAE/C,mEAG+C;AAC/C,0CAAuC;AACvC,4DAAwD;AAGxD,+DAA2D;AAC3D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BACH,iBAAiB,CAAC,eAAe,CAAC,uBAAc,CAAC,oBAAoB,CAAC,CAAA;aACzE;QACL,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;IACvD,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAA;QAC7D,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CACpB,CAAC,CAAA;IACN,CAAC;CACJ;AAjFD,gDAiFC"}
|
|
@@ -2,5 +2,5 @@ import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
|
2
2
|
import { ConnectionManager } from '../ConnectionManager';
|
|
3
3
|
import { Simulator } from './Simulator';
|
|
4
4
|
export declare class SimulatorTransport extends ConnectionManager {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(localPeerDescriptor: PeerDescriptor, simulator: Simulator);
|
|
6
6
|
}
|
|
@@ -5,9 +5,9 @@ const utils_1 = require("@streamr/utils");
|
|
|
5
5
|
const ConnectionManager_1 = require("../ConnectionManager");
|
|
6
6
|
const ConnectorFacade_1 = require("../ConnectorFacade");
|
|
7
7
|
class SimulatorTransport extends ConnectionManager_1.ConnectionManager {
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(localPeerDescriptor, simulator) {
|
|
9
9
|
super({
|
|
10
|
-
createConnectorFacade: () => new ConnectorFacade_1.SimulatorConnectorFacade(
|
|
10
|
+
createConnectorFacade: () => new ConnectorFacade_1.SimulatorConnectorFacade(localPeerDescriptor, simulator),
|
|
11
11
|
metricsContext: new utils_1.MetricsContext()
|
|
12
12
|
});
|
|
13
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SimulatorTransport.js","sourceRoot":"","sources":["../../../../src/connection/simulator/SimulatorTransport.ts"],"names":[],"mappings":";;;AAAA,0CAA+C;AAE/C,4DAAwD;AAExD,wDAA6D;AAE7D,MAAa,kBAAmB,SAAQ,qCAAiB;IACrD,YAAY,mBAAmC,EAAE,SAAoB;QACjE,KAAK,CAAC;YACF,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,0CAAwB,CAAC,mBAAmB,EAAE,SAAS,CAAC;YACzF,cAAc,EAAE,IAAI,sBAAc,EAAE;SACvC,CAAC,CAAA;IACN,CAAC;CACJ;AAPD,gDAOC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pings.js","sourceRoot":"","sources":["../../../../src/connection/
|
|
1
|
+
{"version":3,"file":"pings.js","sourceRoot":"","sources":["../../../../src/connection/simulator/pings.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D,mEAAmE;AACnE,kEAAkE;AAClE,gDAAgD;AAEhD,IAAY,WAA0N;AAAtO,WAAY,WAAW;IAAG,6DAAY,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,yDAAU,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,uDAAS,CAAA;IAAE,6DAAY,CAAA;IAAE,0DAAU,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,kEAAc,CAAA;IAAE,wDAAS,CAAA;AAAC,CAAC,EAA1N,WAAW,2BAAX,WAAW,QAA+M;AAEzN,QAAA,gBAAgB,GAAG;IAC5B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,O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AC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;AACzC,CAAC;AAFD,0CAEC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface WebrtcConnectionEvents {
|
|
2
2
|
localDescription: (description: string, type: string) => void;
|
|
3
3
|
localCandidate: (candidate: string, mid: string) => void;
|
|
4
4
|
}
|
|
@@ -6,7 +6,7 @@ export declare enum RtcDescription {
|
|
|
6
6
|
OFFER = "offer",
|
|
7
7
|
ANSWER = "answer"
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface IWebrtcConnection {
|
|
10
10
|
start(isOffering: boolean): void;
|
|
11
11
|
on(event: 'localDescription', listener: (description: string, type: string) => void): this;
|
|
12
12
|
on(event: 'localCandidate', listener: (candidate: string, mid: string) => void): this;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/IWebrtcConnection.ts"],"names":[],"mappings":";;;AAKA,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,iCAAe,CAAA;IACf,mCAAiB,CAAA;AACrB,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB"}
|
package/dist/src/connection/{WebRTC/NodeWebRtcConnection.d.ts → webrtc/NodeWebrtcConnection.d.ts}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IWebrtcConnection, WebrtcConnectionEvents } from './IWebrtcConnection';
|
|
2
2
|
import { ConnectionType, IConnection, ConnectionID, ConnectionEvents } from '../IConnection';
|
|
3
3
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
|
-
import {
|
|
6
|
-
import { IceServer } from './WebRtcConnectorRpcLocal';
|
|
5
|
+
import { IceServer } from './WebrtcConnector';
|
|
7
6
|
import { PortRange } from '../ConnectionManager';
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const WEBRTC_CLEANUP: {
|
|
9
8
|
cleanUp(): void;
|
|
10
9
|
};
|
|
11
10
|
export interface Params {
|
|
@@ -17,8 +16,8 @@ export interface Params {
|
|
|
17
16
|
iceServers?: IceServer[];
|
|
18
17
|
portRange?: PortRange;
|
|
19
18
|
}
|
|
20
|
-
type Events =
|
|
21
|
-
export declare class
|
|
19
|
+
type Events = WebrtcConnectionEvents & ConnectionEvents;
|
|
20
|
+
export declare class NodeWebrtcConnection extends EventEmitter<Events> implements IConnection, IWebrtcConnection {
|
|
22
21
|
connectionId: ConnectionID;
|
|
23
22
|
private connection?;
|
|
24
23
|
private dataChannel?;
|
|
@@ -39,7 +38,7 @@ export declare class NodeWebRtcConnection extends EventEmitter<Events> implement
|
|
|
39
38
|
setRemoteDescription(description: string, type: string): Promise<void>;
|
|
40
39
|
addRemoteCandidate(candidate: string, mid: string): void;
|
|
41
40
|
send(data: Uint8Array): void;
|
|
42
|
-
close(
|
|
41
|
+
close(gracefulLeave: boolean, reason?: string): Promise<void>;
|
|
43
42
|
private doClose;
|
|
44
43
|
destroy(): void;
|
|
45
44
|
private onDataChannel;
|
package/dist/src/connection/{WebRTC/NodeWebRtcConnection.js → webrtc/NodeWebrtcConnection.js}
RENAMED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.NodeWebrtcConnection = exports.WEBRTC_CLEANUP = void 0;
|
|
30
30
|
const IConnection_1 = require("../IConnection");
|
|
31
31
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
32
32
|
const node_datachannel_1 = __importStar(require("node-datachannel"));
|
|
@@ -35,7 +35,7 @@ const errors_1 = require("../../helpers/errors");
|
|
|
35
35
|
const peerIdFromPeerDescriptor_1 = require("../../helpers/peerIdFromPeerDescriptor");
|
|
36
36
|
const iceServerAsString_1 = require("./iceServerAsString");
|
|
37
37
|
const logger = new utils_1.Logger(module);
|
|
38
|
-
exports.
|
|
38
|
+
exports.WEBRTC_CLEANUP = new class {
|
|
39
39
|
// eslint-disable-next-line class-methods-use-this
|
|
40
40
|
cleanUp() {
|
|
41
41
|
node_datachannel_1.default.cleanup();
|
|
@@ -43,17 +43,17 @@ exports.WEB_RTC_CLEANUP = new class {
|
|
|
43
43
|
};
|
|
44
44
|
// Re-defined accoring to https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts
|
|
45
45
|
// because importing single dom definitions in not possible
|
|
46
|
-
var
|
|
47
|
-
(function (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})(
|
|
46
|
+
var RtcPeerConnectionStateEnum;
|
|
47
|
+
(function (RtcPeerConnectionStateEnum) {
|
|
48
|
+
RtcPeerConnectionStateEnum["closed"] = "closed";
|
|
49
|
+
RtcPeerConnectionStateEnum["connected"] = "connected";
|
|
50
|
+
RtcPeerConnectionStateEnum["connecting"] = "connecting";
|
|
51
|
+
RtcPeerConnectionStateEnum["disconnected"] = "disconnected";
|
|
52
|
+
RtcPeerConnectionStateEnum["failed"] = "failed";
|
|
53
|
+
RtcPeerConnectionStateEnum["new"] = "new";
|
|
54
|
+
})(RtcPeerConnectionStateEnum || (RtcPeerConnectionStateEnum = {}));
|
|
55
55
|
node_datachannel_1.default.initLogger('Fatal');
|
|
56
|
-
class
|
|
56
|
+
class NodeWebrtcConnection extends eventemitter3_1.default {
|
|
57
57
|
constructor(params) {
|
|
58
58
|
super();
|
|
59
59
|
this.lastState = 'connecting';
|
|
@@ -71,9 +71,8 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
71
71
|
this.portRange = params.portRange;
|
|
72
72
|
}
|
|
73
73
|
start(isOffering) {
|
|
74
|
-
logger.trace(`Staring new connection for peer: ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
75
74
|
const peerIdKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
76
|
-
logger.trace(`
|
|
75
|
+
logger.trace(`Starting new connection for peer ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`, { isOffering });
|
|
77
76
|
this.connection = new node_datachannel_1.PeerConnection(peerIdKey, {
|
|
78
77
|
iceServers: this.iceServers.map(iceServerAsString_1.iceServerAsString),
|
|
79
78
|
maxMessageSize: this.maxMessageSize,
|
|
@@ -82,7 +81,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
82
81
|
});
|
|
83
82
|
this.connectingTimeoutRef = setTimeout(() => {
|
|
84
83
|
logger.trace('connectingTimeout, this.closed === ' + this.closed);
|
|
85
|
-
this.doClose(
|
|
84
|
+
this.doClose(false);
|
|
86
85
|
}, this.connectingTimeout);
|
|
87
86
|
this.connection.onStateChange((state) => this.onStateChange(state));
|
|
88
87
|
this.connection.onGatheringStateChange(() => { });
|
|
@@ -103,36 +102,36 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
103
102
|
async setRemoteDescription(description, type) {
|
|
104
103
|
if (this.connection) {
|
|
105
104
|
try {
|
|
106
|
-
logger.trace(`Setting remote descriptor for peer: ${(0, peerIdFromPeerDescriptor_1.
|
|
105
|
+
logger.trace(`Setting remote descriptor for peer: ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
107
106
|
this.connection.setRemoteDescription(description, type);
|
|
108
107
|
this.remoteDescriptionSet = true;
|
|
109
108
|
}
|
|
110
109
|
catch (err) {
|
|
111
|
-
logger.
|
|
110
|
+
logger.debug(`Failed to set remote descriptor for peer ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
else {
|
|
115
|
-
this.doClose(
|
|
114
|
+
this.doClose(false, `Tried to set description for non-existent connection`);
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
addRemoteCandidate(candidate, mid) {
|
|
119
118
|
if (this.connection) {
|
|
120
119
|
if (this.remoteDescriptionSet) {
|
|
121
120
|
try {
|
|
122
|
-
logger.trace(`Setting remote candidate for peer: ${(0, peerIdFromPeerDescriptor_1.
|
|
121
|
+
logger.trace(`Setting remote candidate for peer: ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
123
122
|
this.connection.addRemoteCandidate(candidate, mid);
|
|
124
123
|
}
|
|
125
124
|
catch (err) {
|
|
126
|
-
logger.
|
|
127
|
-
this.doClose('OTHER');
|
|
125
|
+
logger.debug(`Failed to set remote candidate for peer ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
128
|
else {
|
|
131
|
-
|
|
129
|
+
// TODO: should queue candidates until remote description is set?
|
|
130
|
+
this.doClose(false, `Tried to set candidate before description`);
|
|
132
131
|
}
|
|
133
132
|
}
|
|
134
133
|
else {
|
|
135
|
-
this.doClose(
|
|
134
|
+
this.doClose(false, `Tried to set candidate for non-existent connection`);
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
send(data) {
|
|
@@ -141,19 +140,19 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
141
140
|
this.dataChannel.sendMessageBinary(data);
|
|
142
141
|
}
|
|
143
142
|
catch (err) {
|
|
144
|
-
logger.
|
|
143
|
+
logger.debug('Failed to send binary message to ' + (0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor) + err);
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
}
|
|
148
|
-
async close(
|
|
149
|
-
this.doClose(
|
|
147
|
+
async close(gracefulLeave, reason) {
|
|
148
|
+
this.doClose(gracefulLeave, reason);
|
|
150
149
|
}
|
|
151
|
-
doClose(
|
|
150
|
+
doClose(gracefulLeave, reason) {
|
|
152
151
|
if (!this.closed) {
|
|
153
|
-
logger.trace(`Closing Node WebRTC Connection to ${(0, peerIdFromPeerDescriptor_1.
|
|
152
|
+
logger.trace(`Closing Node WebRTC Connection to ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`
|
|
154
153
|
+ `${reason ? `, reason: ${reason}` : ''}`);
|
|
155
154
|
this.closed = true;
|
|
156
|
-
this.emit('disconnected',
|
|
155
|
+
this.emit('disconnected', gracefulLeave, undefined, reason);
|
|
157
156
|
this.removeAllListeners();
|
|
158
157
|
if (this.connectingTimeoutRef) {
|
|
159
158
|
clearTimeout(this.connectingTimeoutRef);
|
|
@@ -164,7 +163,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
164
163
|
this.dataChannel.close();
|
|
165
164
|
}
|
|
166
165
|
catch (e) {
|
|
167
|
-
logger.
|
|
166
|
+
logger.trace('dc.close() errored: %s', e);
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
if (this.connection) {
|
|
@@ -172,14 +171,14 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
172
171
|
this.connection.close();
|
|
173
172
|
}
|
|
174
173
|
catch (e) {
|
|
175
|
-
logger.
|
|
174
|
+
logger.trace('conn.close() errored: %s', e);
|
|
176
175
|
}
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
destroy() {
|
|
181
180
|
this.removeAllListeners();
|
|
182
|
-
this.doClose(
|
|
181
|
+
this.doClose(false);
|
|
183
182
|
}
|
|
184
183
|
onDataChannel(dataChannel) {
|
|
185
184
|
this.openDataChannel(dataChannel);
|
|
@@ -193,7 +192,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
193
192
|
});
|
|
194
193
|
dataChannel.onClosed(() => {
|
|
195
194
|
logger.trace(`dc.closed`);
|
|
196
|
-
this.doClose(
|
|
195
|
+
this.doClose(false, 'DataChannel closed');
|
|
197
196
|
});
|
|
198
197
|
dataChannel.onError((err) => logger.error('error', { err }));
|
|
199
198
|
dataChannel.onBufferedAmountLow(() => {
|
|
@@ -209,21 +208,21 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
209
208
|
clearTimeout(this.connectingTimeoutRef);
|
|
210
209
|
}
|
|
211
210
|
this.dataChannel = dataChannel;
|
|
212
|
-
logger.trace(`DataChannel opened for peer ${(0, peerIdFromPeerDescriptor_1.
|
|
211
|
+
logger.trace(`DataChannel opened for peer ${(0, peerIdFromPeerDescriptor_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
213
212
|
this.emit('connected');
|
|
214
213
|
}
|
|
215
214
|
onStateChange(state) {
|
|
216
215
|
logger.trace('onStateChange ' + state);
|
|
217
|
-
if (!Object.keys(
|
|
218
|
-
throw new errors_1.
|
|
216
|
+
if (!Object.keys(RtcPeerConnectionStateEnum).filter((s) => isNaN(+s)).includes(state)) {
|
|
217
|
+
throw new errors_1.IllegalRtcPeerConnectionState('NodeWebrtcConnection used an unknown state: ' + state);
|
|
219
218
|
}
|
|
220
219
|
else {
|
|
221
220
|
this.lastState = state;
|
|
222
221
|
}
|
|
223
|
-
if (state ===
|
|
224
|
-
|| state ===
|
|
225
|
-
|| state ===
|
|
226
|
-
this.doClose(
|
|
222
|
+
if (state === RtcPeerConnectionStateEnum.closed
|
|
223
|
+
|| state === RtcPeerConnectionStateEnum.disconnected
|
|
224
|
+
|| state === RtcPeerConnectionStateEnum.failed) {
|
|
225
|
+
this.doClose(false);
|
|
227
226
|
}
|
|
228
227
|
}
|
|
229
228
|
isOpen() {
|
|
@@ -233,5 +232,5 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
233
232
|
this.connectionId = new IConnection_1.ConnectionID(connectionID);
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
exports.
|
|
237
|
-
//# sourceMappingURL=
|
|
235
|
+
exports.NodeWebrtcConnection = NodeWebrtcConnection;
|
|
236
|
+
//# sourceMappingURL=NodeWebrtcConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/NodeWebrtcConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA4F;AAE5F,kEAAwC;AACxC,qEAAgG;AAChG,0CAAuC;AACvC,iDAAoE;AACpE,qFAA2G;AAC3G,2DAAuD;AAIvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEpB,QAAA,cAAc,GAAG,IAAI;IAC9B,kDAAkD;IAClD,OAAO;QACH,0BAAe,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;CACJ,CAAA;AAYD,sGAAsG;AACtG,2DAA2D;AAE3D,IAAK,0BAOJ;AAPD,WAAK,0BAA0B;IAC3B,+CAAiB,CAAA;IACjB,qDAAuB,CAAA;IACvB,uDAAyB,CAAA;IACzB,2DAA6B,CAAA;IAC7B,+CAAiB,CAAA;IACjB,yCAAW,CAAA;AACf,CAAC,EAPI,0BAA0B,KAA1B,0BAA0B,QAO9B;AAED,0BAAe,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AAMnC,MAAa,oBAAqB,SAAQ,uBAAoB;IAmB1D,YAAY,MAAc;QACtB,KAAK,EAAE,CAAA;QAfH,cAAS,GAA2B,YAAY,CAAA;QAChD,yBAAoB,GAAG,KAAK,CAAA;QAGpB,mBAAc,GAAmB,4BAAc,CAAC,MAAM,CAAA;QAQ9D,WAAM,GAAG,KAAK,CAAA;QAIlB,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,EAAE,CAAA;QACtC,IAAI,CAAC,UAA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AC,EAAE,CAAC,CAAA;QACrG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC1B,CAAC;IAEO,aAAa,CAAC,KAAa;QAC/B,MAAM,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACnF,MAAM,IAAI,sCAA6B,CAAC,8CAA8C,GAAG,KAAK,CAAC,CAAA;SAClG;aAAM;YACH,IAAI,CAAC,SAAS,GAAG,KAA+B,CAAA;SACnD;QAED,IAAI,KAAK,KAAK,0BAA0B,CAAC,MAAM;eACxC,KAAK,KAAK,0BAA0B,CAAC,YAAY;eACjD,KAAK,KAAK,0BAA0B,CAAC,MAAM,EAChD;YACE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SACtB;IAEL,CAAC;IAED,MAAM;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAA;IAC/E,CAAC;IAEM,eAAe,CAAC,YAAoB;QACvC,IAAI,CAAC,YAAY,GAAG,IAAI,0BAAY,CAAC,YAAY,CAAC,CAAA;IACtD,CAAC;CACJ;AApND,oDAoNC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
+
import { ITransport } from '../../transport/ITransport';
|
|
3
|
+
import { ManagedConnection } from '../ManagedConnection';
|
|
4
|
+
import { PortRange } from '../ConnectionManager';
|
|
5
|
+
export declare const replaceInternalIpWithExternalIp: (candidate: string, ip: string) => string;
|
|
6
|
+
export interface WebrtcConnectorConfig {
|
|
7
|
+
transport: ITransport;
|
|
8
|
+
iceServers?: IceServer[];
|
|
9
|
+
allowPrivateAddresses?: boolean;
|
|
10
|
+
bufferThresholdLow?: number;
|
|
11
|
+
bufferThresholdHigh?: number;
|
|
12
|
+
maxMessageSize?: number;
|
|
13
|
+
connectionTimeout?: number;
|
|
14
|
+
externalIp?: string;
|
|
15
|
+
portRange?: PortRange;
|
|
16
|
+
}
|
|
17
|
+
export interface IceServer {
|
|
18
|
+
url: string;
|
|
19
|
+
port: number;
|
|
20
|
+
username?: string;
|
|
21
|
+
password?: string;
|
|
22
|
+
tcp?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare class WebrtcConnector {
|
|
25
|
+
private static readonly WEBRTC_CONNECTOR_SERVICE_ID;
|
|
26
|
+
private readonly rpcCommunicator;
|
|
27
|
+
private readonly ongoingConnectAttempts;
|
|
28
|
+
private localPeerDescriptor?;
|
|
29
|
+
private stopped;
|
|
30
|
+
private iceServers;
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: WebrtcConnectorConfig, onNewConnection: (connection: ManagedConnection) => boolean);
|
|
33
|
+
private registerLocalRpcMethods;
|
|
34
|
+
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
35
|
+
setLocalPeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
36
|
+
stop(): Promise<void>;
|
|
37
|
+
isOffering(targetPeerDescriptor: PeerDescriptor): boolean;
|
|
38
|
+
}
|