@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.1
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/package.json +8 -8
- package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
- package/dist/src/connection/ConnectionLockRpcLocal.js +8 -8
- package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
- package/dist/src/connection/ConnectionManager.d.ts +4 -6
- package/dist/src/connection/ConnectionManager.js +128 -103
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +15 -14
- package/dist/src/connection/ConnectorFacade.js +70 -52
- package/dist/src/connection/ConnectorFacade.js.map +1 -1
- package/dist/src/connection/Handshaker.d.ts +9 -2
- package/dist/src/connection/Handshaker.js +117 -27
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +13 -38
- package/dist/src/connection/ManagedConnection.js +31 -252
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/OutputBuffer.d.ts +9 -0
- package/dist/src/connection/OutputBuffer.js +26 -0
- package/dist/src/connection/OutputBuffer.js.map +1 -0
- package/dist/src/connection/PendingConnection.d.ts +19 -0
- package/dist/src/connection/PendingConnection.js +59 -0
- package/dist/src/connection/PendingConnection.js.map +1 -0
- package/dist/src/connection/connectivityChecker.js +3 -3
- package/dist/src/connection/connectivityChecker.js.map +1 -1
- package/dist/src/connection/connectivityRequestHandler.js +2 -2
- package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
- package/dist/src/connection/simulator/Simulator.d.ts +1 -3
- package/dist/src/connection/simulator/Simulator.js +1 -4
- package/dist/src/connection/simulator/Simulator.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnection.js +1 -2
- package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/simulator/SimulatorConnector.d.ts +3 -3
- package/dist/src/connection/simulator/SimulatorConnector.js +28 -21
- package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -6
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js +3 -20
- package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +11 -6
- package/dist/src/connection/webrtc/WebrtcConnector.js +57 -42
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +8 -10
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +21 -44
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +8 -2
- package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -1
- package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +3 -3
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js +8 -8
- package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +1 -1
- package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -1
- package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +26 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.js +86 -0
- package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +19 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +23 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +5 -0
- package/dist/src/connection/websocket/{WebsocketConnectorRpcRemote.js → WebsocketClientConnectorRpcRemote.js} +4 -4
- package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/websocket/WebsocketServer.d.ts +8 -5
- package/dist/src/connection/websocket/WebsocketServer.js +11 -11
- package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
- package/dist/src/connection/websocket/{WebsocketConnector.d.ts → WebsocketServerConnector.d.ts} +16 -21
- package/dist/src/connection/websocket/{WebsocketConnector.js → WebsocketServerConnector.js} +112 -160
- package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -0
- package/dist/src/dht/DhtNode.d.ts +4 -4
- package/dist/src/dht/DhtNode.js +85 -84
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
- package/dist/src/dht/DhtNodeRpcLocal.js +9 -9
- package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
- package/dist/src/dht/ExternalApiRpcLocal.js +5 -5
- package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
- package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
- package/dist/src/dht/PeerManager.d.ts +4 -4
- package/dist/src/dht/PeerManager.js +22 -22
- package/dist/src/dht/PeerManager.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +3 -3
- package/dist/src/dht/contact/SortedContactList.js +9 -9
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -3
- package/dist/src/dht/discovery/DiscoverySession.js +21 -21
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -3
- package/dist/src/dht/discovery/PeerDiscovery.js +46 -44
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/discovery/RingDiscoverySession.d.ts +3 -3
- package/dist/src/dht/discovery/RingDiscoverySession.js +19 -19
- package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +33 -33
- package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +3 -3
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +8 -8
- package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +4 -4
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +24 -24
- package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -4
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -5
- package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +3 -3
- package/dist/src/dht/routing/Router.js +20 -20
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -3
- package/dist/src/dht/routing/RouterRpcLocal.js +16 -16
- package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
- package/dist/src/dht/routing/RoutingSession.js +24 -24
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/StoreManager.d.ts +3 -3
- package/dist/src/dht/store/StoreManager.js +25 -25
- package/dist/src/dht/store/StoreManager.js.map +1 -1
- package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
- package/dist/src/dht/store/StoreRpcLocal.js +12 -12
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
- package/dist/src/exports.d.ts +3 -0
- package/dist/src/exports.js +5 -1
- package/dist/src/exports.js.map +1 -1
- package/dist/src/proto/google/protobuf/any.d.ts +5 -8
- package/dist/src/proto/google/protobuf/any.js.map +1 -1
- package/dist/src/proto/google/protobuf/empty.d.ts +1 -0
- package/dist/src/proto/google/protobuf/empty.js.map +1 -1
- package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -10
- package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +3 -3
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +4 -4
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
- package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
- package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -2
- package/dist/src/transport/ListeningRpcCommunicator.js +2 -2
- package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
- package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -2
- package/dist/src/transport/RoutingRpcCommunicator.js +2 -2
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +8 -8
- package/protos/DhtRpc.proto +1 -1
- package/src/connection/ConnectionLockRpcLocal.ts +9 -9
- package/src/connection/ConnectionLockRpcRemote.ts +1 -1
- package/src/connection/ConnectionManager.ts +153 -111
- package/src/connection/ConnectorFacade.ts +84 -61
- package/src/connection/Handshaker.ts +131 -27
- package/src/connection/ManagedConnection.ts +41 -304
- package/src/connection/OutputBuffer.ts +28 -0
- package/src/connection/PendingConnection.ts +68 -0
- package/src/connection/connectivityChecker.ts +2 -2
- package/src/connection/connectivityRequestHandler.ts +1 -1
- package/src/connection/simulator/Simulator.ts +1 -5
- package/src/connection/simulator/SimulatorConnection.ts +1 -2
- package/src/connection/simulator/SimulatorConnector.ts +34 -33
- package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -6
- package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -24
- package/src/connection/webrtc/WebrtcConnector.ts +73 -62
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +26 -56
- package/src/connection/websocket/AbstractWebsocketClientConnection.ts +8 -2
- package/src/connection/websocket/AutoCertifierClientFacade.ts +11 -11
- package/src/connection/websocket/NodeWebsocketClientConnection.ts +1 -1
- package/src/connection/websocket/WebsocketClientConnector.ts +119 -0
- package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +39 -0
- package/src/connection/websocket/{WebsocketConnectorRpcRemote.ts → WebsocketClientConnectorRpcRemote.ts} +2 -2
- package/src/connection/websocket/WebsocketServer.ts +18 -14
- package/src/connection/websocket/{WebsocketConnector.ts → WebsocketServerConnector.ts} +128 -205
- package/src/dht/DhtNode.ts +90 -89
- package/src/dht/DhtNodeRpcLocal.ts +11 -11
- package/src/dht/ExternalApiRpcLocal.ts +6 -6
- package/src/dht/ExternalApiRpcRemote.ts +2 -2
- package/src/dht/PeerManager.ts +24 -24
- package/src/dht/contact/SortedContactList.ts +10 -10
- package/src/dht/discovery/DiscoverySession.ts +24 -24
- package/src/dht/discovery/PeerDiscovery.ts +47 -45
- package/src/dht/discovery/RingDiscoverySession.ts +23 -23
- package/src/dht/recursive-operation/RecursiveOperationManager.ts +36 -36
- package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +9 -9
- package/src/dht/recursive-operation/RecursiveOperationSession.ts +25 -25
- package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +7 -7
- package/src/dht/routing/Router.ts +21 -21
- package/src/dht/routing/RouterRpcLocal.ts +17 -17
- package/src/dht/routing/RoutingSession.ts +26 -26
- package/src/dht/store/StoreManager.ts +27 -27
- package/src/dht/store/StoreRpcLocal.ts +13 -13
- package/src/exports.ts +3 -0
- package/src/proto/google/protobuf/any.ts +6 -9
- package/src/proto/google/protobuf/empty.ts +2 -1
- package/src/proto/google/protobuf/timestamp.ts +2 -11
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
- package/src/proto/packages/dht/protos/DhtRpc.ts +4 -4
- package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
- package/src/transport/ListeningRpcCommunicator.ts +3 -3
- package/src/transport/RoutingRpcCommunicator.ts +3 -3
- package/test/end-to-end/Layer0Webrtc.test.ts +0 -10
- package/test/integration/ConnectionManager.test.ts +3 -2
- package/test/integration/GeoIpConnectivityChecking.test.ts +1 -1
- package/test/integration/SimultaneousConnections.test.ts +2 -2
- package/test/integration/WebrtcConnectionManagement.test.ts +2 -10
- package/test/integration/{WebsocketConnectorRpc.test.ts → WebsocketClientConnectorRpc.test.ts} +9 -9
- package/test/integration/WebsocketConnectionManagement.test.ts +11 -29
- package/test/unit/ConnectionManager.test.ts +64 -0
- package/test/unit/DiscoverySession.test.ts +1 -1
- package/test/unit/Handshaker.test.ts +169 -0
- package/test/unit/ManagedConnection.test.ts +58 -0
- package/test/unit/PendingConnection.test.ts +57 -0
- package/test/unit/WebrtcConnector.test.ts +56 -0
- package/test/unit/{WebsocketConnector.test.ts → WebsocketClientConnector.test.ts} +56 -11
- package/test/unit/WebsocketServerConnector.test.ts +102 -0
- package/test/utils/FakeConnectorFacade.ts +41 -0
- package/test/utils/mock/MockConnection.ts +26 -0
- package/test/utils/utils.ts +2 -2
- package/dist/src/connection/IConnectionSource.d.ts +0 -4
- package/dist/src/connection/IConnectionSource.js +0 -3
- package/dist/src/connection/IConnectionSource.js.map +0 -1
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.d.ts +0 -7
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.js +0 -20
- package/dist/src/connection/webrtc/ManagedWebrtcConnection.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnector.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +0 -19
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +0 -23
- package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +0 -1
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +0 -5
- package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +0 -1
- package/src/connection/IConnectionSource.ts +0 -6
- package/src/connection/webrtc/ManagedWebrtcConnection.ts +0 -27
- package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +0 -39
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { wait, waitForEvent3 } from '@streamr/utils'
|
|
2
|
+
import { PendingConnection } from '../../src/exports'
|
|
3
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
4
|
+
import { PendingConnectionEvents } from '../../src/connection/PendingConnection'
|
|
5
|
+
import { MockConnection } from '../utils/mock/MockConnection'
|
|
6
|
+
|
|
7
|
+
describe('PendingConnection', () => {
|
|
8
|
+
|
|
9
|
+
let pendingConnection: PendingConnection
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
pendingConnection = new PendingConnection(createMockPeerDescriptor(), 500)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
pendingConnection.close(false)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('does not emit disconnected after replacedAsDuplicate', async () => {
|
|
20
|
+
pendingConnection.once('disconnected', () => {
|
|
21
|
+
throw new Error('disconnected')
|
|
22
|
+
})
|
|
23
|
+
pendingConnection.replaceAsDuplicate()
|
|
24
|
+
await pendingConnection.close(false)
|
|
25
|
+
await wait(50)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('emits disconnected after timed out', async () => {
|
|
29
|
+
await waitForEvent3<PendingConnectionEvents>(pendingConnection, 'disconnected')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('does not emit disconnected if destroyed', async () => {
|
|
33
|
+
pendingConnection.once('disconnected', () => {
|
|
34
|
+
throw new Error('disconnected')
|
|
35
|
+
})
|
|
36
|
+
pendingConnection.destroy()
|
|
37
|
+
await wait(50)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('emites connected', (done) => {
|
|
41
|
+
const mockConnection = new MockConnection()
|
|
42
|
+
pendingConnection.once('connected', (_peerDescriptor, connection) => {
|
|
43
|
+
expect(mockConnection).toEqual(connection)
|
|
44
|
+
done()
|
|
45
|
+
})
|
|
46
|
+
pendingConnection.onHandshakeCompleted(mockConnection)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('does not emit connected if replaced', async () => {
|
|
50
|
+
pendingConnection.once('connected', () => {
|
|
51
|
+
throw new Error('connected')
|
|
52
|
+
})
|
|
53
|
+
pendingConnection.replaceAsDuplicate()
|
|
54
|
+
await wait(50)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { WebrtcConnector } from '../../src/connection/webrtc/WebrtcConnector'
|
|
2
|
+
import { MockConnection } from '../utils/mock/MockConnection'
|
|
3
|
+
import { MockTransport } from '../utils/mock/MockTransport'
|
|
4
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
5
|
+
|
|
6
|
+
describe('WebrtcConnector', () => {
|
|
7
|
+
|
|
8
|
+
let connector: WebrtcConnector
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
|
|
12
|
+
connector = new WebrtcConnector({
|
|
13
|
+
transport: new MockTransport()
|
|
14
|
+
} as any)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
connector.stop()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('Connect', () => {
|
|
22
|
+
|
|
23
|
+
it('Returns existing connecting connection', () => {
|
|
24
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
25
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
26
|
+
const firstConnection = connector.connect(remotePeerDescriptor, false)
|
|
27
|
+
const secondConnection = connector.connect(remotePeerDescriptor, false)
|
|
28
|
+
expect(firstConnection).toEqual(secondConnection)
|
|
29
|
+
firstConnection.close(false)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('Disconnected event removes connecting connection', () => {
|
|
33
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
34
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
35
|
+
const firstConnection = connector.connect(remotePeerDescriptor, false)
|
|
36
|
+
firstConnection.emit('disconnected', false)
|
|
37
|
+
const secondConnection = connector.connect(remotePeerDescriptor, false)
|
|
38
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
39
|
+
firstConnection.close(false)
|
|
40
|
+
secondConnection.close(false)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('Connected event removes connecting connection', () => {
|
|
44
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
45
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
46
|
+
const firstConnection = connector.connect(remotePeerDescriptor, false)
|
|
47
|
+
firstConnection.onHandshakeCompleted(new MockConnection())
|
|
48
|
+
const secondConnection = connector.connect(remotePeerDescriptor, false)
|
|
49
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
50
|
+
firstConnection.close(false)
|
|
51
|
+
secondConnection.close(false)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
})
|
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
import {
|
|
2
|
+
import { WebsocketClientConnector } from '../../src/connection/websocket/WebsocketClientConnector'
|
|
3
3
|
import { NodeType } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
-
import {
|
|
4
|
+
import { MockConnection } from '../utils/mock/MockConnection'
|
|
5
|
+
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
5
6
|
import { createMockPeerDescriptor } from '../utils/utils'
|
|
6
7
|
|
|
7
|
-
describe('
|
|
8
|
+
describe('WebsocketClientConnector', () => {
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
let connector: WebsocketClientConnector
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
connector = new WebsocketClientConnector({
|
|
14
|
+
rpcCommunicator: new MockRpcCommunicator(),
|
|
13
15
|
canConnect: () => {}
|
|
14
16
|
} as any)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
connector.destroy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('isPossibleToFormConnection', () => {
|
|
15
24
|
|
|
16
25
|
it('node without server', () => {
|
|
17
26
|
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS }))
|
|
@@ -25,15 +34,15 @@ describe('WebsocketConnector', () => {
|
|
|
25
34
|
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: true } }))
|
|
26
35
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(true)
|
|
27
36
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(true)
|
|
28
|
-
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(
|
|
29
|
-
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(
|
|
37
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(false)
|
|
38
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
30
39
|
})
|
|
31
40
|
|
|
32
41
|
it('node with non-TLS server', () => {
|
|
33
42
|
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } }))
|
|
34
43
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(true)
|
|
35
44
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(true)
|
|
36
|
-
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(
|
|
45
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(false)
|
|
37
46
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
38
47
|
})
|
|
39
48
|
|
|
@@ -41,8 +50,8 @@ describe('WebsocketConnector', () => {
|
|
|
41
50
|
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '192.168.11.11', port: 11, tls: false } }))
|
|
42
51
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(true)
|
|
43
52
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(true)
|
|
44
|
-
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(
|
|
45
|
-
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(
|
|
53
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(false)
|
|
54
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
46
55
|
})
|
|
47
56
|
|
|
48
57
|
it('browser', () => {
|
|
@@ -53,4 +62,40 @@ describe('WebsocketConnector', () => {
|
|
|
53
62
|
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
54
63
|
})
|
|
55
64
|
})
|
|
65
|
+
|
|
66
|
+
describe('Connect', () => {
|
|
67
|
+
|
|
68
|
+
it('Returns existing connecting connection', () => {
|
|
69
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
70
|
+
const remotePeerDescriptor = createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } })
|
|
71
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
72
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
73
|
+
expect(firstConnection).toEqual(secondConnection)
|
|
74
|
+
firstConnection.close(false)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('Disconnected event removes connecting connection', () => {
|
|
78
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
79
|
+
const remotePeerDescriptor = createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } })
|
|
80
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
81
|
+
firstConnection.emit('disconnected', false)
|
|
82
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
83
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
84
|
+
firstConnection.close(false)
|
|
85
|
+
secondConnection.close(false)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it('Connected event removes connecting connection', () => {
|
|
89
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor())
|
|
90
|
+
const remotePeerDescriptor = createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } })
|
|
91
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
92
|
+
firstConnection.onHandshakeCompleted(new MockConnection())
|
|
93
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
94
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
95
|
+
firstConnection.close(false)
|
|
96
|
+
secondConnection.close(false)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
})
|
|
100
|
+
|
|
56
101
|
})
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import { WebsocketServerConnector } from '../../src/connection/websocket/WebsocketServerConnector'
|
|
3
|
+
import { NodeType } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { MockConnection } from '../utils/mock/MockConnection'
|
|
5
|
+
import { MockRpcCommunicator } from '../utils/mock/MockRpcCommunicator'
|
|
6
|
+
import { createMockPeerDescriptor } from '../utils/utils'
|
|
7
|
+
|
|
8
|
+
describe('WebsocketServerConnector', () => {
|
|
9
|
+
|
|
10
|
+
let connector: WebsocketServerConnector
|
|
11
|
+
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
connector = new WebsocketServerConnector({
|
|
14
|
+
rpcCommunicator: new MockRpcCommunicator(),
|
|
15
|
+
canConnect: () => {}
|
|
16
|
+
} as any)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
connector.destroy()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
describe('isPossibleToFormConnection', () => {
|
|
24
|
+
|
|
25
|
+
it('node without server', () => {
|
|
26
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS }))
|
|
27
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(false)
|
|
28
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(false)
|
|
29
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(false)
|
|
30
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it('node with TLS server', () => {
|
|
34
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: true } }))
|
|
35
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(false)
|
|
36
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(false)
|
|
37
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(true)
|
|
38
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(true)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('node with non-TLS server', () => {
|
|
42
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } }))
|
|
43
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(false)
|
|
44
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(false)
|
|
45
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(true)
|
|
46
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('node with non-TLS server in local network', () => {
|
|
50
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '192.168.11.11', port: 11, tls: false } }))
|
|
51
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(false)
|
|
52
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(false)
|
|
53
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(true)
|
|
54
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(true)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('browser', () => {
|
|
58
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.BROWSER }))
|
|
59
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: false } }))).toBe(false)
|
|
60
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '2.2.2.2', port: 22, tls: true } }))).toBe(false)
|
|
61
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.NODEJS }))).toBe(false)
|
|
62
|
+
expect(connector.isPossibleToFormConnection(createMockPeerDescriptor({ type: NodeType.BROWSER }))).toBe(false)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('Connect', () => {
|
|
68
|
+
|
|
69
|
+
it('Returns existing connecting connection', () => {
|
|
70
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } }))
|
|
71
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
72
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
73
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
74
|
+
expect(firstConnection).toEqual(secondConnection)
|
|
75
|
+
firstConnection.close(false)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('Disconnected event removes connecting connection', () => {
|
|
79
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } }))
|
|
80
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
81
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
82
|
+
firstConnection.emit('disconnected', false)
|
|
83
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
84
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
85
|
+
firstConnection.close(false)
|
|
86
|
+
secondConnection.close(false)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('Connected event removes connecting connection', () => {
|
|
90
|
+
connector.setLocalPeerDescriptor(createMockPeerDescriptor({ type: NodeType.NODEJS, websocket: { host: '1.1.1.1', port: 11, tls: false } }))
|
|
91
|
+
const remotePeerDescriptor = createMockPeerDescriptor()
|
|
92
|
+
const firstConnection = connector.connect(remotePeerDescriptor)
|
|
93
|
+
firstConnection.onHandshakeCompleted(new MockConnection())
|
|
94
|
+
const secondConnection = connector.connect(remotePeerDescriptor)
|
|
95
|
+
expect(firstConnection).not.toEqual(secondConnection)
|
|
96
|
+
firstConnection.close(false)
|
|
97
|
+
secondConnection.close(false)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PendingConnection } from '../../src/connection/PendingConnection'
|
|
2
|
+
import { DhtAddress } from '../../src/identifiers'
|
|
3
|
+
import { PeerDescriptor } from '../../src/proto/packages/dht/protos/DhtRpc'
|
|
4
|
+
import { ITransport } from '../../src/transport/ITransport'
|
|
5
|
+
|
|
6
|
+
export class FakeConnectorFacade {
|
|
7
|
+
|
|
8
|
+
private readonly localPeerDescriptor: PeerDescriptor
|
|
9
|
+
private onNewConnection?: (connection: PendingConnection) => boolean
|
|
10
|
+
|
|
11
|
+
constructor(localPeerDescriptor: PeerDescriptor) {
|
|
12
|
+
this.localPeerDescriptor = localPeerDescriptor
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line class-methods-use-this
|
|
16
|
+
createConnection(peerDescriptor: PeerDescriptor): PendingConnection {
|
|
17
|
+
return new PendingConnection(peerDescriptor)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getLocalPeerDescriptor(): PeerDescriptor | undefined {
|
|
21
|
+
return this.localPeerDescriptor
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
callOnNewConnection(connection: PendingConnection): boolean {
|
|
25
|
+
return this.onNewConnection!(connection)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async start(
|
|
29
|
+
onNewConnection: (connection: PendingConnection) => boolean,
|
|
30
|
+
_hasConnection: (nodeId: DhtAddress) => boolean,
|
|
31
|
+
_autoCertifierTransport: ITransport
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
this.onNewConnection = onNewConnection
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line class-methods-use-this
|
|
37
|
+
async stop(): Promise<void> {
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3'
|
|
2
|
+
import { ConnectionEvents, IConnection } from '../../../src/connection/IConnection'
|
|
3
|
+
|
|
4
|
+
export class MockConnection extends EventEmitter<ConnectionEvents> implements IConnection {
|
|
5
|
+
|
|
6
|
+
public sentData: Uint8Array[] = []
|
|
7
|
+
|
|
8
|
+
send(data: Uint8Array): Promise<void> {
|
|
9
|
+
this.sentData.push(data)
|
|
10
|
+
return Promise.resolve()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
close(graceful: boolean): Promise<void> {
|
|
14
|
+
this.emit('disconnected', graceful)
|
|
15
|
+
return Promise.resolve()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
destroy(): void {
|
|
19
|
+
this.removeAllListeners()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
emitData(message: Uint8Array): void {
|
|
23
|
+
this.emit('data', message)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
package/test/utils/utils.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
IDhtNodeRpc,
|
|
18
18
|
IRouterRpc,
|
|
19
19
|
IStoreRpc,
|
|
20
|
-
|
|
20
|
+
IWebsocketClientConnectorRpc
|
|
21
21
|
} from '../../src/proto/packages/dht/protos/DhtRpc.server'
|
|
22
22
|
import { Simulator } from '../../src/connection/simulator/Simulator'
|
|
23
23
|
import { ConnectionManager } from '../../src/connection/ConnectionManager'
|
|
@@ -231,7 +231,7 @@ export const mockStoreRpc: IStoreRpcWithError = {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
export const
|
|
234
|
+
export const mockWebsocketClientConnectorRpc: IWebsocketClientConnectorRpc = {
|
|
235
235
|
async requestConnection(): Promise<Empty> {
|
|
236
236
|
return {}
|
|
237
237
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IConnectionSource.js","sourceRoot":"","sources":["../../../src/connection/IConnectionSource.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
|
-
import { ManagedConnection } from '../ManagedConnection';
|
|
3
|
-
import { NodeWebrtcConnection } from './NodeWebrtcConnection';
|
|
4
|
-
export declare class ManagedWebrtcConnection extends ManagedConnection {
|
|
5
|
-
constructor(localPeerDescriptor: PeerDescriptor, connectingConnection?: NodeWebrtcConnection, connectedConnection?: NodeWebrtcConnection);
|
|
6
|
-
getWebrtcConnection(): NodeWebrtcConnection;
|
|
7
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ManagedWebrtcConnection = void 0;
|
|
4
|
-
const IConnection_1 = require("../IConnection");
|
|
5
|
-
const ManagedConnection_1 = require("../ManagedConnection");
|
|
6
|
-
class ManagedWebrtcConnection extends ManagedConnection_1.ManagedConnection {
|
|
7
|
-
constructor(localPeerDescriptor, connectingConnection, connectedConnection) {
|
|
8
|
-
super(localPeerDescriptor, IConnection_1.ConnectionType.WEBRTC, connectingConnection, connectedConnection);
|
|
9
|
-
}
|
|
10
|
-
getWebrtcConnection() {
|
|
11
|
-
if (this.outgoingConnection) {
|
|
12
|
-
return this.outgoingConnection;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return this.incomingConnection;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.ManagedWebrtcConnection = ManagedWebrtcConnection;
|
|
20
|
-
//# sourceMappingURL=ManagedWebrtcConnection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ManagedWebrtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/ManagedWebrtcConnection.ts"],"names":[],"mappings":";;;AACA,gDAA+C;AAC/C,4DAAwD;AAGxD,MAAa,uBAAwB,SAAQ,qCAAiB;IAE1D,YAAY,mBAAmC,EAC3C,oBAA2C,EAC3C,mBAA0C;QAE1C,KAAK,CACD,mBAAmB,EACnB,4BAAc,CAAC,MAAM,EACrB,oBAAoB,EACpB,mBAAmB,CACtB,CAAA;IACL,CAAC;IAEM,mBAAmB;QACtB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,kBAAqD,CAAA;QACrE,CAAC;aAAM,CAAC;YACJ,OAAO,IAAI,CAAC,kBAAqD,CAAA;QACrE,CAAC;IACL,CAAC;CACJ;AArBD,0DAqBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnector.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mFAA2E;AAC3E,gDAA4D;AAE5D,uFAAmF;AACnF,6EAAyE;AACzE,+EAA2E;AAC3E,mEAM+C;AAC/C,iFAA2F;AAC3F,0CAA2D;AAC3D,4DAAwD;AACxD,uDAAmD;AACnD,gEAAgE;AAChE,4DAAyE;AAEzE,8CAA0C;AAC1C,8DAAqC;AACrC,mCAAgC;AAEhC,6DAAmE;AACnE,iDAAgE;AAChE,2EAAuE;AACvE,8EAA4G;AAC5G,0DAA2C;AAE3C,mDAAoG;AACpG,mDAAuF;AACvF,4DAAsD;AAEtD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAI1B,MAAM,gCAAgC,GAAG,CAAC,EAAsB,EAAE,MAAe,EAAU,EAAE;IAChG,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AACxH,CAAC,CAAA;AAFY,QAAA,gCAAgC,oCAE5C;AAkBD,MAAa,kBAAkB;IAEnB,MAAM,CAAU,8BAA8B,GAAG,4BAA4B,CAAA;IACpE,eAAe,CAA0B;IACzC,eAAe,CAAkB;IAC1C,YAAY,CAAe;IAClB,sBAAsB,GAAuC,I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YAC1E,CAAC;QACL,CAAC;IACL,CAAC;IAEM,sBAAsB,CAAC,mBAAmC;QAC7D,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;IAClD,CAAC;IAEM,KAAK,CAAC,OAAO;QAChB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;QAC5B,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;QAE9B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAA;QACjE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAEnE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC,CAAA;QAChE,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACnE,MAAM,IAAI,CAAC,eAAe,EAAE,IAAI,EAAE,CAAA;QAClC,MAAM,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,CAAA;IACnC,CAAC;;AA/SL,gDAgTC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
3
|
-
import { PeerDescriptor, WebsocketConnectionRequest } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
|
-
import { IWebsocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
5
|
-
import { ManagedConnection } from '../ManagedConnection';
|
|
6
|
-
import { Empty } from '../../proto/google/protobuf/empty';
|
|
7
|
-
import { DhtAddress } from '../../identifiers';
|
|
8
|
-
interface WebsocketConnectorRpcLocalConfig {
|
|
9
|
-
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
10
|
-
hasConnection: (nodeId: DhtAddress) => boolean;
|
|
11
|
-
onNewConnection: (connection: ManagedConnection) => boolean;
|
|
12
|
-
abortSignal: AbortSignal;
|
|
13
|
-
}
|
|
14
|
-
export declare class WebsocketConnectorRpcLocal implements IWebsocketConnectorRpc {
|
|
15
|
-
private readonly config;
|
|
16
|
-
constructor(config: WebsocketConnectorRpcLocalConfig);
|
|
17
|
-
requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<Empty>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebsocketConnectorRpcLocal = void 0;
|
|
4
|
-
const identifiers_1 = require("../../identifiers");
|
|
5
|
-
class WebsocketConnectorRpcLocal {
|
|
6
|
-
config;
|
|
7
|
-
constructor(config) {
|
|
8
|
-
this.config = config;
|
|
9
|
-
}
|
|
10
|
-
async requestConnection(_request, context) {
|
|
11
|
-
if (this.config.abortSignal.aborted) {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
15
|
-
if (!this.config.hasConnection((0, identifiers_1.getNodeIdFromPeerDescriptor)(senderPeerDescriptor))) {
|
|
16
|
-
const connection = this.config.connect(senderPeerDescriptor);
|
|
17
|
-
this.config.onNewConnection(connection);
|
|
18
|
-
}
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.WebsocketConnectorRpcLocal = WebsocketConnectorRpcLocal;
|
|
23
|
-
//# sourceMappingURL=WebsocketConnectorRpcLocal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcLocal.ts"],"names":[],"mappings":";;;AASA,mDAA+D;AAU/D,MAAa,0BAA0B;IAElB,MAAM,CAAkC;IAEzD,YAAY,MAAwC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,QAAoC,EAAE,OAA0B;QAC3F,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAClC,OAAO,EAAE,CAAA;QACb,CAAC;QACD,MAAM,oBAAoB,GAAI,OAA0B,CAAC,wBAAyB,CAAA;QAClF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAA,yCAA2B,EAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC;YAChF,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAA;YAC5D,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO,EAAE,CAAA;IACb,CAAC;CACJ;AAnBD,gEAmBC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RpcRemote } from '../../dht/contact/RpcRemote';
|
|
2
|
-
import { WebsocketConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
3
|
-
export declare class WebsocketConnectorRpcRemote extends RpcRemote<WebsocketConnectorRpcClient> {
|
|
4
|
-
requestConnection(): Promise<void>;
|
|
5
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebsocketConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/websocket/WebsocketConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAGA,0CAAuC;AACvC,2DAAuD;AAEvD,mDAA+D;AAE/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,2BAA4B,SAAQ,qBAAsC;IAEnF,KAAK,CAAC,iBAAiB;QACnB,MAAM,CAAC,KAAK,CAAC,wCAAwC,IAAA,yCAA2B,EAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,EAAE,CAAC,CAAA;QAClH,MAAM,OAAO,GAA+B,EAAE,CAAA;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAA;QACxC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;CACJ;AARD,kEAQC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
|
|
2
|
-
import { ConnectionType } from '../IConnection'
|
|
3
|
-
import { ManagedConnection } from '../ManagedConnection'
|
|
4
|
-
import { NodeWebrtcConnection } from './NodeWebrtcConnection'
|
|
5
|
-
|
|
6
|
-
export class ManagedWebrtcConnection extends ManagedConnection {
|
|
7
|
-
|
|
8
|
-
constructor(localPeerDescriptor: PeerDescriptor,
|
|
9
|
-
connectingConnection?: NodeWebrtcConnection,
|
|
10
|
-
connectedConnection?: NodeWebrtcConnection
|
|
11
|
-
) {
|
|
12
|
-
super(
|
|
13
|
-
localPeerDescriptor,
|
|
14
|
-
ConnectionType.WEBRTC,
|
|
15
|
-
connectingConnection,
|
|
16
|
-
connectedConnection
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
public getWebrtcConnection(): NodeWebrtcConnection {
|
|
21
|
-
if (this.outgoingConnection) {
|
|
22
|
-
return this.outgoingConnection as unknown as NodeWebrtcConnection
|
|
23
|
-
} else {
|
|
24
|
-
return this.incomingConnection as unknown as NodeWebrtcConnection
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
|
|
2
|
-
import {
|
|
3
|
-
PeerDescriptor,
|
|
4
|
-
WebsocketConnectionRequest
|
|
5
|
-
} from '../../proto/packages/dht/protos/DhtRpc'
|
|
6
|
-
import { IWebsocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server'
|
|
7
|
-
import { DhtCallContext } from '../../rpc-protocol/DhtCallContext'
|
|
8
|
-
import { ManagedConnection } from '../ManagedConnection'
|
|
9
|
-
import { Empty } from '../../proto/google/protobuf/empty'
|
|
10
|
-
import { getNodeIdFromPeerDescriptor } from '../../identifiers'
|
|
11
|
-
import { DhtAddress } from '../../identifiers'
|
|
12
|
-
|
|
13
|
-
interface WebsocketConnectorRpcLocalConfig {
|
|
14
|
-
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection
|
|
15
|
-
hasConnection: (nodeId: DhtAddress) => boolean
|
|
16
|
-
onNewConnection: (connection: ManagedConnection) => boolean
|
|
17
|
-
abortSignal: AbortSignal
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class WebsocketConnectorRpcLocal implements IWebsocketConnectorRpc {
|
|
21
|
-
|
|
22
|
-
private readonly config: WebsocketConnectorRpcLocalConfig
|
|
23
|
-
|
|
24
|
-
constructor(config: WebsocketConnectorRpcLocalConfig) {
|
|
25
|
-
this.config = config
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public async requestConnection(_request: WebsocketConnectionRequest, context: ServerCallContext): Promise<Empty> {
|
|
29
|
-
if (this.config.abortSignal.aborted) {
|
|
30
|
-
return {}
|
|
31
|
-
}
|
|
32
|
-
const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
|
|
33
|
-
if (!this.config.hasConnection(getNodeIdFromPeerDescriptor(senderPeerDescriptor))) {
|
|
34
|
-
const connection = this.config.connect(senderPeerDescriptor)
|
|
35
|
-
this.config.onNewConnection(connection)
|
|
36
|
-
}
|
|
37
|
-
return {}
|
|
38
|
-
}
|
|
39
|
-
}
|