@streamr/dht 0.0.1-tatum.6 → 0.0.1-tatum.8
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 +1 -1
- package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
- package/dist/src/connection/ConnectionLockRpcRemote.d.ts +10 -0
- package/dist/src/connection/{RemoteConnectionLocker.js → ConnectionLockRpcRemote.js} +21 -35
- package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -0
- package/dist/src/connection/ConnectionManager.d.ts +17 -41
- package/dist/src/connection/ConnectionManager.js +148 -212
- package/dist/src/connection/ConnectionManager.js.map +1 -1
- package/dist/src/connection/ConnectivityChecker.js +16 -13
- package/dist/src/connection/ConnectivityChecker.js.map +1 -1
- package/dist/src/connection/ConnectorFacade.d.ts +49 -0
- package/dist/src/connection/ConnectorFacade.js +83 -0
- package/dist/src/connection/ConnectorFacade.js.map +1 -0
- package/dist/src/connection/Handshaker.d.ts +1 -2
- package/dist/src/connection/Handshaker.js +1 -4
- package/dist/src/connection/Handshaker.js.map +1 -1
- package/dist/src/connection/ManagedConnection.d.ts +2 -6
- package/dist/src/connection/ManagedConnection.js +27 -36
- package/dist/src/connection/ManagedConnection.js.map +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.d.ts +1 -1
- package/dist/src/connection/ManagedWebRtcConnection.js +2 -2
- package/dist/src/connection/ManagedWebRtcConnection.js.map +1 -1
- package/dist/src/connection/Simulator/Simulator.d.ts +0 -2
- package/dist/src/connection/Simulator/Simulator.js +0 -5
- package/dist/src/connection/Simulator/Simulator.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnection.js +16 -13
- package/dist/src/connection/Simulator/SimulatorConnection.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorConnector.d.ts +2 -3
- package/dist/src/connection/Simulator/SimulatorConnector.js +12 -14
- package/dist/src/connection/Simulator/SimulatorConnector.js.map +1 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js +6 -1
- package/dist/src/connection/Simulator/SimulatorTransport.js.map +1 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.d.ts +3 -1
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js +12 -12
- package/dist/src/connection/WebRTC/NodeWebRtcConnection.js.map +1 -1
- package/dist/src/connection/WebRTC/{WebRtcConnector.d.ts → WebRtcConnectorRpcLocal.d.ts} +13 -13
- package/dist/src/connection/WebRTC/{WebRtcConnector.js → WebRtcConnectorRpcLocal.js} +46 -38
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.d.ts +11 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js +55 -0
- package/dist/src/connection/WebRTC/WebRtcConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebRTC/iceServerAsString.d.ts +1 -1
- package/dist/src/connection/WebSocket/{WebSocketConnector.d.ts → WebSocketConnectorRpcLocal.d.ts} +21 -11
- package/dist/src/connection/WebSocket/{WebSocketConnector.js → WebSocketConnectorRpcLocal.js} +80 -59
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcLocal.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.d.ts +8 -0
- package/dist/src/connection/WebSocket/{RemoteWebSocketConnector.js → WebSocketConnectorRpcRemote.js} +12 -16
- package/dist/src/connection/WebSocket/WebSocketConnectorRpcRemote.js.map +1 -0
- package/dist/src/connection/WebSocket/WebSocketServer.d.ts +11 -1
- package/dist/src/connection/WebSocket/WebSocketServer.js +15 -10
- package/dist/src/connection/WebSocket/WebSocketServer.js.map +1 -1
- package/dist/src/dht/DhtNode.d.ts +18 -55
- package/dist/src/dht/DhtNode.js +122 -145
- package/dist/src/dht/DhtNode.js.map +1 -1
- package/dist/src/dht/{RemoteExternalApi.d.ts → ExternalApiRpcRemote.d.ts} +2 -2
- package/dist/src/dht/{RemoteExternalApi.js → ExternalApiRpcRemote.js} +5 -6
- package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -0
- package/dist/src/dht/{DhtPeer.d.ts → RemoteDhtNode.d.ts} +2 -3
- package/dist/src/dht/{DhtPeer.js → RemoteDhtNode.js} +21 -19
- package/dist/src/dht/RemoteDhtNode.js.map +1 -0
- package/dist/src/dht/contact/ContactList.d.ts +0 -1
- package/dist/src/dht/contact/ContactList.js +0 -3
- package/dist/src/dht/contact/ContactList.js.map +1 -1
- package/dist/src/dht/contact/RandomContactList.d.ts +0 -1
- package/dist/src/dht/contact/RandomContactList.js +0 -3
- package/dist/src/dht/contact/RandomContactList.js.map +1 -1
- package/dist/src/dht/contact/SortedContactList.d.ts +0 -3
- package/dist/src/dht/contact/SortedContactList.js +0 -9
- package/dist/src/dht/contact/SortedContactList.js.map +1 -1
- package/dist/src/dht/discovery/DiscoverySession.d.ts +5 -7
- package/dist/src/dht/discovery/DiscoverySession.js +9 -10
- package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
- package/dist/src/dht/discovery/PeerDiscovery.d.ts +12 -11
- package/dist/src/dht/discovery/PeerDiscovery.js +33 -37
- package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
- package/dist/src/dht/find/RecursiveFindSession.d.ts +9 -10
- package/dist/src/dht/find/RecursiveFindSession.js +13 -13
- package/dist/src/dht/find/RecursiveFindSession.js.map +1 -1
- package/dist/src/dht/find/RecursiveFinder.d.ts +9 -11
- package/dist/src/dht/find/RecursiveFinder.js +35 -36
- package/dist/src/dht/find/RecursiveFinder.js.map +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.d.ts +1 -1
- package/dist/src/dht/find/RemoteRecursiveFindSession.js +4 -4
- package/dist/src/dht/find/RemoteRecursiveFindSession.js.map +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.d.ts +1 -1
- package/dist/src/dht/registerExternalApiRpcMethods.js +4 -3
- package/dist/src/dht/registerExternalApiRpcMethods.js.map +1 -1
- package/dist/src/dht/routing/DuplicateDetector.d.ts +1 -2
- package/dist/src/dht/routing/DuplicateDetector.js +2 -7
- package/dist/src/dht/routing/DuplicateDetector.js.map +1 -1
- package/dist/src/dht/routing/Router.d.ts +12 -15
- package/dist/src/dht/routing/Router.js +30 -33
- package/dist/src/dht/routing/Router.js.map +1 -1
- package/dist/src/dht/routing/{RemoteRouter.d.ts → RouterRpcRemote.d.ts} +2 -2
- package/dist/src/dht/routing/{RemoteRouter.js → RouterRpcRemote.js} +5 -5
- package/dist/src/dht/routing/RouterRpcRemote.js.map +1 -0
- package/dist/src/dht/routing/RoutingSession.d.ts +3 -4
- package/dist/src/dht/routing/RoutingSession.js +6 -5
- package/dist/src/dht/routing/RoutingSession.js.map +1 -1
- package/dist/src/dht/store/{DataStore.d.ts → StoreRpcLocal.d.ts} +6 -6
- package/dist/src/dht/store/{DataStore.js → StoreRpcLocal.js} +34 -34
- package/dist/src/dht/store/StoreRpcLocal.js.map +1 -0
- package/dist/src/dht/store/{RemoteStore.d.ts → StoreRpcRemote.d.ts} +2 -2
- package/dist/src/dht/store/{RemoteStore.js → StoreRpcRemote.js} +4 -4
- package/dist/src/dht/store/StoreRpcRemote.js.map +1 -0
- package/dist/src/exports.d.ts +2 -8
- package/dist/src/exports.js +2 -14
- package/dist/src/exports.js.map +1 -1
- package/dist/src/helpers/PeerID.d.ts +0 -1
- package/dist/src/helpers/PeerID.js +0 -6
- package/dist/src/helpers/PeerID.js.map +1 -1
- package/dist/src/helpers/browser/isBrowserEnvironment.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js +6 -0
- package/dist/src/helpers/browser/isBrowserEnvironment.js.map +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.d.ts +1 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js +7 -0
- package/dist/src/helpers/browser/isBrowserEnvironment_override.js.map +1 -0
- package/dist/src/helpers/kademliaId.d.ts +1 -0
- package/dist/src/helpers/kademliaId.js +14 -0
- package/dist/src/helpers/kademliaId.js.map +1 -0
- package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +1 -1
- package/dist/src/helpers/peerIdFromPeerDescriptor.js +3 -3
- package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
- package/dist/src/helpers/protoClasses.js +2 -2
- package/dist/src/helpers/protoClasses.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +29 -29
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +39 -39
- package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +49 -162
- package/dist/src/proto/packages/dht/protos/DhtRpc.js +47 -88
- package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
- package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +15 -15
- package/dist/src/transport/RoutingRpcCommunicator.js +1 -0
- package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
- package/package.json +10 -9
- package/protos/DhtRpc.proto +30 -60
- package/src/connection/ConnectionLockHandler.ts +1 -1
- package/src/connection/ConnectionLockRpcRemote.ts +62 -0
- package/src/connection/ConnectionManager.ts +178 -274
- package/src/connection/ConnectivityChecker.ts +15 -12
- package/src/connection/ConnectorFacade.ts +140 -0
- package/src/connection/Handshaker.ts +0 -5
- package/src/connection/ManagedConnection.ts +26 -40
- package/src/connection/ManagedWebRtcConnection.ts +0 -2
- package/src/connection/Simulator/Simulator.ts +0 -7
- package/src/connection/Simulator/SimulatorConnection.ts +16 -13
- package/src/connection/Simulator/SimulatorConnector.ts +13 -19
- package/src/connection/Simulator/SimulatorTransport.ts +6 -1
- package/src/connection/WebRTC/NodeWebRtcConnection.ts +15 -14
- package/src/connection/WebRTC/{WebRtcConnector.ts → WebRtcConnectorRpcLocal.ts} +68 -56
- package/src/connection/WebRTC/WebRtcConnectorRpcRemote.ts +71 -0
- package/src/connection/WebRTC/iceServerAsString.ts +1 -1
- package/src/connection/WebSocket/{WebSocketConnector.ts → WebSocketConnectorRpcLocal.ts} +102 -79
- package/src/connection/WebSocket/WebSocketConnectorRpcRemote.ts +45 -0
- package/src/connection/WebSocket/WebSocketServer.ts +26 -8
- package/src/dht/DhtNode.ts +176 -203
- package/src/dht/{RemoteExternalApi.ts → ExternalApiRpcRemote.ts} +3 -4
- package/src/dht/{DhtPeer.ts → RemoteDhtNode.ts} +11 -9
- package/src/dht/contact/ContactList.ts +0 -4
- package/src/dht/contact/RandomContactList.ts +0 -4
- package/src/dht/contact/SortedContactList.ts +0 -12
- package/src/dht/discovery/DiscoverySession.ts +20 -23
- package/src/dht/discovery/PeerDiscovery.ts +47 -45
- package/src/dht/find/RecursiveFindSession.ts +21 -22
- package/src/dht/find/RecursiveFinder.ts +45 -49
- package/src/dht/find/RemoteRecursiveFindSession.ts +6 -6
- package/src/dht/registerExternalApiRpcMethods.ts +8 -5
- package/src/dht/routing/DuplicateDetector.ts +3 -10
- package/src/dht/routing/Router.ts +39 -45
- package/src/dht/routing/{RemoteRouter.ts → RouterRpcRemote.ts} +4 -4
- package/src/dht/routing/RoutingSession.ts +15 -15
- package/src/dht/store/{DataStore.ts → StoreRpcLocal.ts} +42 -42
- package/src/dht/store/{RemoteStore.ts → StoreRpcRemote.ts} +2 -2
- package/src/exports.ts +2 -8
- package/src/helpers/PeerID.ts +0 -7
- package/src/helpers/browser/isBrowserEnvironment.ts +1 -0
- package/src/helpers/browser/isBrowserEnvironment_override.ts +3 -0
- package/src/helpers/kademliaId.ts +8 -0
- package/src/helpers/peerIdFromPeerDescriptor.ts +1 -1
- package/src/helpers/protoClasses.ts +4 -4
- package/src/proto/packages/dht/protos/DhtRpc.client.ts +54 -54
- package/src/proto/packages/dht/protos/DhtRpc.server.ts +15 -15
- package/src/proto/packages/dht/protos/DhtRpc.ts +77 -216
- package/src/transport/RoutingRpcCommunicator.ts +1 -0
- package/test/benchmark/KademliaCorrectness.test.ts +4 -2
- package/test/benchmark/RecursiveFind.test.ts +6 -6
- package/test/end-to-end/Layer0-Layer1.test.ts +9 -9
- package/test/end-to-end/Layer0WebRTC-Layer1.test.ts +5 -5
- package/test/end-to-end/Layer0WebRTC.test.ts +5 -6
- package/test/end-to-end/Layer1-Scale-WebRTC.test.ts +13 -8
- package/test/end-to-end/Layer1-Scale-WebSocket.test.ts +15 -10
- package/test/end-to-end/WebSocketConnectionRequest.test.ts +5 -5
- package/test/integration/ConnectionLocking.test.ts +32 -26
- package/test/integration/ConnectionManager.test.ts +90 -93
- package/test/integration/DhtJoinPeerDiscovery.test.ts +53 -0
- package/test/integration/DhtRpc.test.ts +4 -6
- package/test/integration/Layer1-scale.test.ts +8 -8
- package/test/integration/MigrateData.test.ts +9 -9
- package/test/integration/Mock-Layer1-Layer0.test.ts +1 -2
- package/test/integration/RecursiveFind.test.ts +5 -5
- package/test/integration/{DhtPeer.test.ts → RemoteDhtNode.test.ts} +11 -12
- package/test/integration/RouteMessage.test.ts +7 -9
- package/test/integration/{RemoteRouter.test.ts → RouterRpcRemote.test.ts} +13 -14
- package/test/integration/RpcErrors.test.ts +25 -10
- package/test/integration/ScaleDownDht.test.ts +8 -8
- package/test/integration/SimultaneousConnections.test.ts +35 -36
- package/test/integration/Store.test.ts +8 -9
- package/test/integration/StoreAndDelete.test.ts +11 -11
- package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -7
- package/test/integration/{RemoteStore.test.ts → StoreRpcRemote.test.ts} +17 -18
- package/test/integration/WebRtcConnectionManagement.test.ts +26 -19
- package/test/integration/WebRtcConnectorRpc.test.ts +17 -32
- package/test/integration/WebSocket.test.ts +4 -2
- package/test/integration/WebSocketConnectionManagement.test.ts +30 -17
- package/test/integration/WebSocketConnectorRpc.test.ts +10 -15
- package/test/unit/DuplicateDetector.test.ts +3 -4
- package/test/unit/LocalDataStore.test.ts +6 -8
- package/test/unit/RandomContactList.test.ts +1 -1
- package/test/unit/RecursiveFinder.test.ts +13 -18
- package/test/unit/Router.test.ts +18 -21
- package/test/unit/WebSocketConnectorRpcLocal.test.ts +64 -0
- package/test/unit/WebSocketServer.test.ts +24 -12
- package/test/unit/{webrtcReplaceInternalIpWithExternalIp.ts → webrtcReplaceInternalIpWithExternalIp.test.ts} +1 -1
- package/test/utils/mock/RecursiveFinder.ts +2 -2
- package/test/utils/mock/Router.ts +9 -11
- package/test/utils/mock/Transport.ts +2 -2
- package/test/utils/utils.ts +55 -74
- package/dist/src/connection/RemoteConnectionLocker.d.ts +0 -13
- package/dist/src/connection/RemoteConnectionLocker.js.map +0 -1
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.d.ts +0 -12
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js +0 -74
- package/dist/src/connection/WebRTC/RemoteWebrtcConnector.js.map +0 -1
- package/dist/src/connection/WebRTC/WebRtcConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.d.ts +0 -9
- package/dist/src/connection/WebSocket/RemoteWebSocketConnector.js.map +0 -1
- package/dist/src/connection/WebSocket/WebSocketConnector.js.map +0 -1
- package/dist/src/dht/DhtPeer.js.map +0 -1
- package/dist/src/dht/RemoteExternalApi.js.map +0 -1
- package/dist/src/dht/routing/RemoteRouter.js.map +0 -1
- package/dist/src/dht/store/DataStore.js.map +0 -1
- package/dist/src/dht/store/RemoteStore.js.map +0 -1
- package/dist/src/helpers/browser/isBrowser.d.ts +0 -1
- package/dist/src/helpers/browser/isBrowser.js +0 -6
- package/dist/src/helpers/browser/isBrowser.js.map +0 -1
- package/dist/src/helpers/browser/isNodeJS.d.ts +0 -1
- package/dist/src/helpers/browser/isNodeJS.js +0 -6
- package/dist/src/helpers/browser/isNodeJS.js.map +0 -1
- package/src/connection/RemoteConnectionLocker.ts +0 -84
- package/src/connection/WebRTC/RemoteWebrtcConnector.ts +0 -93
- package/src/connection/WebSocket/RemoteWebSocketConnector.ts +0 -49
- package/src/helpers/browser/isBrowser.ts +0 -1
- package/src/helpers/browser/isNodeJS.ts +0 -1
- package/test/integration/DhtWithMockConnectionLatencies.test.ts +0 -46
- package/test/integration/DhtWithMockConnections.test.ts +0 -46
- package/test/integration/DhtWithRealConnectionLatencies.test.ts +0 -47
|
@@ -3,7 +3,7 @@ import { ConnectionType, IConnection, ConnectionID, ConnectionEvents } from '../
|
|
|
3
3
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
4
4
|
import EventEmitter from 'eventemitter3';
|
|
5
5
|
import { DisconnectionType } from '../../transport/ITransport';
|
|
6
|
-
import { IceServer } from './
|
|
6
|
+
import { IceServer } from './WebRtcConnectorRpcLocal';
|
|
7
7
|
import { PortRange } from '../ConnectionManager';
|
|
8
8
|
export declare const WEB_RTC_CLEANUP: {
|
|
9
9
|
cleanUp(): void;
|
|
@@ -13,6 +13,7 @@ export interface Params {
|
|
|
13
13
|
bufferThresholdHigh?: number;
|
|
14
14
|
bufferThresholdLow?: number;
|
|
15
15
|
connectingTimeout?: number;
|
|
16
|
+
maxMessageSize?: number;
|
|
16
17
|
iceServers?: IceServer[];
|
|
17
18
|
portRange?: PortRange;
|
|
18
19
|
}
|
|
@@ -31,6 +32,7 @@ export declare class NodeWebRtcConnection extends EventEmitter<Events> implement
|
|
|
31
32
|
private readonly connectingTimeout;
|
|
32
33
|
private readonly remotePeerDescriptor;
|
|
33
34
|
private readonly portRange?;
|
|
35
|
+
private readonly maxMessageSize?;
|
|
34
36
|
private closed;
|
|
35
37
|
constructor(params: Params);
|
|
36
38
|
start(isOffering: boolean): void;
|
|
@@ -35,7 +35,6 @@ 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
|
-
const MAX_MESSAGE_SIZE = 1048576;
|
|
39
38
|
exports.WEB_RTC_CLEANUP = new class {
|
|
40
39
|
// eslint-disable-next-line class-methods-use-this
|
|
41
40
|
cleanUp() {
|
|
@@ -62,21 +61,22 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
62
61
|
this.connectionType = IConnection_1.ConnectionType.WEBRTC;
|
|
63
62
|
this.closed = false;
|
|
64
63
|
this.connectionId = new IConnection_1.ConnectionID();
|
|
65
|
-
this.iceServers = params.iceServers
|
|
64
|
+
this.iceServers = params.iceServers ?? [];
|
|
66
65
|
// eslint-disable-next-line no-underscore-dangle
|
|
67
|
-
this._bufferThresholdHigh = params.bufferThresholdHigh
|
|
68
|
-
this.bufferThresholdLow = params.bufferThresholdLow
|
|
69
|
-
this.connectingTimeout = params.connectingTimeout
|
|
66
|
+
this._bufferThresholdHigh = params.bufferThresholdHigh ?? 2 ** 17;
|
|
67
|
+
this.bufferThresholdLow = params.bufferThresholdLow ?? 2 ** 15;
|
|
68
|
+
this.connectingTimeout = params.connectingTimeout ?? 20000;
|
|
70
69
|
this.remotePeerDescriptor = params.remotePeerDescriptor;
|
|
70
|
+
this.maxMessageSize = params.maxMessageSize ?? 1048576;
|
|
71
71
|
this.portRange = params.portRange;
|
|
72
72
|
}
|
|
73
73
|
start(isOffering) {
|
|
74
|
-
logger.trace(`Staring new connection for peer: ${this.remotePeerDescriptor
|
|
75
|
-
const
|
|
76
|
-
logger.trace(`Staring new connection for peer: ${
|
|
77
|
-
this.connection = new node_datachannel_1.PeerConnection(
|
|
74
|
+
logger.trace(`Staring new connection for peer: ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
75
|
+
const peerIdKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
76
|
+
logger.trace(`Staring new connection for peer: ${peerIdKey} offering: ${isOffering}`);
|
|
77
|
+
this.connection = new node_datachannel_1.PeerConnection(peerIdKey, {
|
|
78
78
|
iceServers: this.iceServers.map(iceServerAsString_1.iceServerAsString),
|
|
79
|
-
maxMessageSize:
|
|
79
|
+
maxMessageSize: this.maxMessageSize,
|
|
80
80
|
portRangeBegin: this.portRange?.min,
|
|
81
81
|
portRangeEnd: this.portRange?.max,
|
|
82
82
|
});
|
|
@@ -85,7 +85,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
85
85
|
this.doClose('OTHER');
|
|
86
86
|
}, this.connectingTimeout);
|
|
87
87
|
this.connection.onStateChange((state) => this.onStateChange(state));
|
|
88
|
-
this.connection.onGatheringStateChange((
|
|
88
|
+
this.connection.onGatheringStateChange(() => { });
|
|
89
89
|
this.connection.onLocalDescription((description, type) => {
|
|
90
90
|
this.emit('localDescription', description, type.toString());
|
|
91
91
|
});
|
|
@@ -209,7 +209,7 @@ class NodeWebRtcConnection extends eventemitter3_1.default {
|
|
|
209
209
|
clearTimeout(this.connectingTimeoutRef);
|
|
210
210
|
}
|
|
211
211
|
this.dataChannel = dataChannel;
|
|
212
|
-
logger.trace(`DataChannel opened for peer ${this.remotePeerDescriptor
|
|
212
|
+
logger.trace(`DataChannel opened for peer ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(this.remotePeerDescriptor)}`);
|
|
213
213
|
this.emit('connected');
|
|
214
214
|
}
|
|
215
215
|
onStateChange(state) {
|
|
@@ -1 +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,qFAA8E;AAE9E,2DAAuD;AAIvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"NodeWebRtcConnection.js","sourceRoot":"","sources":["../../../../src/connection/WebRTC/NodeWebRtcConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,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,OAAO,CAAC,CAAA;SACxB;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;AArND,oDAqNC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { IceCandidate, PeerDescriptor, RtcAnswer, RtcOffer, WebRtcConnectionRequest } from '../../proto/packages/dht/protos/DhtRpc';
|
|
2
2
|
import { Empty } from '../../proto/google/protobuf/empty';
|
|
3
3
|
import { ITransport } from '../../transport/ITransport';
|
|
4
|
-
import {
|
|
5
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
4
|
+
import { IWebRtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
6
5
|
import { ManagedConnection } from '../ManagedConnection';
|
|
7
6
|
import { PortRange } from '../ConnectionManager';
|
|
7
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
8
8
|
export declare const replaceInternalIpWithExternalIp: (candidate: string, ip: string) => string;
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
protocolVersion: string;
|
|
9
|
+
export interface WebRtcConnectorRpcLocalConfig {
|
|
10
|
+
transport: ITransport;
|
|
12
11
|
iceServers?: IceServer[];
|
|
13
12
|
allowPrivateAddresses?: boolean;
|
|
14
13
|
bufferThresholdLow?: number;
|
|
15
14
|
bufferThresholdHigh?: number;
|
|
15
|
+
maxMessageSize?: number;
|
|
16
16
|
connectionTimeout?: number;
|
|
17
17
|
externalIp?: string;
|
|
18
18
|
portRange?: PortRange;
|
|
@@ -24,7 +24,7 @@ export interface IceServer {
|
|
|
24
24
|
password?: string;
|
|
25
25
|
tcp?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export declare class
|
|
27
|
+
export declare class WebRtcConnectorRpcLocal implements IWebRtcConnectorRpc {
|
|
28
28
|
private static readonly WEBRTC_CONNECTOR_SERVICE_ID;
|
|
29
29
|
private readonly rpcCommunicator;
|
|
30
30
|
private readonly ongoingConnectAttempts;
|
|
@@ -33,19 +33,19 @@ export declare class WebRtcConnector implements IWebRtcConnectorService {
|
|
|
33
33
|
private iceServers;
|
|
34
34
|
private allowPrivateAddresses;
|
|
35
35
|
private config;
|
|
36
|
-
private
|
|
37
|
-
constructor(config:
|
|
36
|
+
private onIncomingConnection;
|
|
37
|
+
constructor(config: WebRtcConnectorRpcLocalConfig, onIncomingConnection: (connection: ManagedConnection) => boolean);
|
|
38
38
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
39
39
|
setOwnPeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
40
|
-
isIceCandidateAllowed
|
|
40
|
+
private isIceCandidateAllowed;
|
|
41
41
|
private onRtcOffer;
|
|
42
42
|
private onRtcAnswer;
|
|
43
43
|
private onConnectionRequest;
|
|
44
44
|
private onRemoteCandidate;
|
|
45
45
|
stop(): Promise<void>;
|
|
46
46
|
isOffering(targetPeerDescriptor: PeerDescriptor): boolean;
|
|
47
|
-
requestConnection(
|
|
48
|
-
rtcOffer(request: RtcOffer,
|
|
49
|
-
rtcAnswer(request: RtcAnswer,
|
|
50
|
-
iceCandidate(request: IceCandidate,
|
|
47
|
+
requestConnection(_request: WebRtcConnectionRequest, context: ServerCallContext): Promise<Empty>;
|
|
48
|
+
rtcOffer(request: RtcOffer, context: ServerCallContext): Promise<Empty>;
|
|
49
|
+
rtcAnswer(request: RtcAnswer, context: ServerCallContext): Promise<Empty>;
|
|
50
|
+
iceCandidate(request: IceCandidate, context: ServerCallContext): Promise<Empty>;
|
|
51
51
|
}
|
|
@@ -23,11 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.WebRtcConnectorRpcLocal = exports.replaceInternalIpWithExternalIp = void 0;
|
|
27
27
|
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
28
28
|
const ListeningRpcCommunicator_1 = require("../../transport/ListeningRpcCommunicator");
|
|
29
29
|
const NodeWebRtcConnection_1 = require("./NodeWebRtcConnection");
|
|
30
|
-
const
|
|
30
|
+
const WebRtcConnectorRpcRemote_1 = require("./WebRtcConnectorRpcRemote");
|
|
31
31
|
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
32
32
|
const ManagedWebRtcConnection_1 = require("../ManagedWebRtcConnection");
|
|
33
33
|
const utils_1 = require("@streamr/utils");
|
|
@@ -45,15 +45,15 @@ const replaceInternalIpWithExternalIp = (candidate, ip) => {
|
|
|
45
45
|
return parsed.join(' ');
|
|
46
46
|
};
|
|
47
47
|
exports.replaceInternalIpWithExternalIp = replaceInternalIpWithExternalIp;
|
|
48
|
-
class
|
|
49
|
-
constructor(config,
|
|
48
|
+
class WebRtcConnectorRpcLocal {
|
|
49
|
+
constructor(config, onIncomingConnection) {
|
|
50
50
|
this.ongoingConnectAttempts = new Map();
|
|
51
51
|
this.stopped = false;
|
|
52
52
|
this.config = config;
|
|
53
53
|
this.iceServers = config.iceServers || [];
|
|
54
54
|
this.allowPrivateAddresses = config.allowPrivateAddresses || true;
|
|
55
|
-
this.
|
|
56
|
-
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(
|
|
55
|
+
this.onIncomingConnection = onIncomingConnection;
|
|
56
|
+
this.rpcCommunicator = new ListeningRpcCommunicator_1.ListeningRpcCommunicator(WebRtcConnectorRpcLocal.WEBRTC_CONNECTOR_SERVICE_ID, config.transport, {
|
|
57
57
|
rpcRequestTimeout: 15000
|
|
58
58
|
});
|
|
59
59
|
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.RtcOffer, 'rtcOffer', (req, context) => this.rtcOffer(req, context));
|
|
@@ -62,10 +62,10 @@ class WebRtcConnector {
|
|
|
62
62
|
this.rpcCommunicator.registerRpcNotification(DhtRpc_1.WebRtcConnectionRequest, 'requestConnection', (req, context) => this.requestConnection(req, context));
|
|
63
63
|
}
|
|
64
64
|
connect(targetPeerDescriptor) {
|
|
65
|
-
if ((0, peerIdFromPeerDescriptor_1.
|
|
65
|
+
if ((0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.ownPeerDescriptor)) {
|
|
66
66
|
throw new Err.CannotConnectToSelf('Cannot open WebRTC Connection to self');
|
|
67
67
|
}
|
|
68
|
-
logger.trace(`Opening WebRTC connection to ${
|
|
68
|
+
logger.trace(`Opening WebRTC connection to ${(0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor)}`);
|
|
69
69
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor);
|
|
70
70
|
const existingConnection = this.ongoingConnectAttempts.get(peerKey);
|
|
71
71
|
if (existingConnection) {
|
|
@@ -82,10 +82,10 @@ class WebRtcConnector {
|
|
|
82
82
|
const offering = this.isOffering(targetPeerDescriptor);
|
|
83
83
|
let managedConnection;
|
|
84
84
|
if (offering) {
|
|
85
|
-
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor,
|
|
85
|
+
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor, connection);
|
|
86
86
|
}
|
|
87
87
|
else {
|
|
88
|
-
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor,
|
|
88
|
+
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor, undefined, connection);
|
|
89
89
|
}
|
|
90
90
|
managedConnection.setPeerDescriptor(targetPeerDescriptor);
|
|
91
91
|
this.ongoingConnectAttempts.set((0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(targetPeerDescriptor), managedConnection);
|
|
@@ -98,27 +98,27 @@ class WebRtcConnector {
|
|
|
98
98
|
};
|
|
99
99
|
connection.on('disconnected', delFunc);
|
|
100
100
|
managedConnection.on('handshakeCompleted', delFunc);
|
|
101
|
-
const remoteConnector = new
|
|
101
|
+
const remoteConnector = new WebRtcConnectorRpcRemote_1.WebRtcConnectorRpcRemote(this.ownPeerDescriptor, targetPeerDescriptor, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebRtcConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
|
|
102
102
|
connection.on('localCandidate', (candidate, mid) => {
|
|
103
103
|
if (this.config.externalIp) {
|
|
104
104
|
candidate = (0, exports.replaceInternalIpWithExternalIp)(candidate, this.config.externalIp);
|
|
105
105
|
logger.debug(`onLocalCandidate injected external ip ${candidate} ${mid}`);
|
|
106
106
|
}
|
|
107
|
-
remoteConnector.sendIceCandidate(
|
|
107
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString());
|
|
108
108
|
});
|
|
109
109
|
if (offering) {
|
|
110
|
-
connection.once('localDescription', (description
|
|
111
|
-
remoteConnector.sendRtcOffer(
|
|
110
|
+
connection.once('localDescription', (description) => {
|
|
111
|
+
remoteConnector.sendRtcOffer(description, connection.connectionId.toString());
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
connection.once('localDescription', (description
|
|
116
|
-
remoteConnector.sendRtcAnswer(
|
|
115
|
+
connection.once('localDescription', (description) => {
|
|
116
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId.toString());
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
connection.start(offering);
|
|
120
120
|
if (!offering) {
|
|
121
|
-
remoteConnector.requestConnection(
|
|
121
|
+
remoteConnector.requestConnection(connection.connectionId.toString());
|
|
122
122
|
}
|
|
123
123
|
return managedConnection;
|
|
124
124
|
}
|
|
@@ -135,7 +135,7 @@ class WebRtcConnector {
|
|
|
135
135
|
return true;
|
|
136
136
|
}
|
|
137
137
|
onRtcOffer(remotePeer, targetPeer, description, connectionId) {
|
|
138
|
-
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.
|
|
138
|
+
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(targetPeer, this.ownPeerDescriptor)) {
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
141
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeer);
|
|
@@ -143,16 +143,16 @@ class WebRtcConnector {
|
|
|
143
143
|
let connection = managedConnection?.getWebRtcConnection();
|
|
144
144
|
if (!managedConnection) {
|
|
145
145
|
connection = new NodeWebRtcConnection_1.NodeWebRtcConnection({ remotePeerDescriptor: remotePeer });
|
|
146
|
-
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor,
|
|
146
|
+
managedConnection = new ManagedWebRtcConnection_1.ManagedWebRtcConnection(this.ownPeerDescriptor, undefined, connection);
|
|
147
147
|
managedConnection.setPeerDescriptor(remotePeer);
|
|
148
148
|
this.ongoingConnectAttempts.set(peerKey, managedConnection);
|
|
149
|
-
this.
|
|
150
|
-
const remoteConnector = new
|
|
149
|
+
this.onIncomingConnection(managedConnection);
|
|
150
|
+
const remoteConnector = new WebRtcConnectorRpcRemote_1.WebRtcConnectorRpcRemote(this.ownPeerDescriptor, remotePeer, (0, proto_rpc_1.toProtoRpcClient)(new DhtRpc_client_1.WebRtcConnectorRpcClient(this.rpcCommunicator.getRpcClientTransport())));
|
|
151
151
|
connection.on('localCandidate', (candidate, mid) => {
|
|
152
|
-
remoteConnector.sendIceCandidate(
|
|
152
|
+
remoteConnector.sendIceCandidate(candidate, mid, connection.connectionId.toString());
|
|
153
153
|
});
|
|
154
|
-
connection.once('localDescription', (description
|
|
155
|
-
remoteConnector.sendRtcAnswer(
|
|
154
|
+
connection.once('localDescription', (description) => {
|
|
155
|
+
remoteConnector.sendRtcAnswer(description, connection.connectionId.toString());
|
|
156
156
|
});
|
|
157
157
|
connection.start(false);
|
|
158
158
|
}
|
|
@@ -167,7 +167,7 @@ class WebRtcConnector {
|
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
169
|
onRtcAnswer(remotePeerDescriptor, targetPeerDescriptor, description, connectionId) {
|
|
170
|
-
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.
|
|
170
|
+
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.ownPeerDescriptor)) {
|
|
171
171
|
return;
|
|
172
172
|
}
|
|
173
173
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeerDescriptor);
|
|
@@ -187,10 +187,10 @@ class WebRtcConnector {
|
|
|
187
187
|
}
|
|
188
188
|
const managedConnection = this.connect(targetPeerDescriptor);
|
|
189
189
|
managedConnection.setPeerDescriptor(targetPeerDescriptor);
|
|
190
|
-
this.
|
|
190
|
+
this.onIncomingConnection(managedConnection);
|
|
191
191
|
}
|
|
192
192
|
onRemoteCandidate(remotePeerDescriptor, targetPeerDescriptor, candidate, mid, connectionId) {
|
|
193
|
-
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.
|
|
193
|
+
if (this.stopped || !(0, peerIdFromPeerDescriptor_1.areEqualPeerDescriptors)(targetPeerDescriptor, this.ownPeerDescriptor)) {
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
const peerKey = (0, peerIdFromPeerDescriptor_1.keyFromPeerDescriptor)(remotePeerDescriptor);
|
|
@@ -219,23 +219,31 @@ class WebRtcConnector {
|
|
|
219
219
|
return myId.hasSmallerHashThan(theirId);
|
|
220
220
|
}
|
|
221
221
|
// IWebRTCConnector implementation
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
// TODO should we read connectionId from WebRtcConnectionRequest (or remove the field)?
|
|
223
|
+
async requestConnection(_request, context) {
|
|
224
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
225
|
+
this.onConnectionRequest(senderPeerDescriptor);
|
|
224
226
|
return {};
|
|
225
227
|
}
|
|
226
|
-
async rtcOffer(request,
|
|
227
|
-
|
|
228
|
+
async rtcOffer(request, context) {
|
|
229
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
230
|
+
const receiverPeerDescriptor = context.incomingTargetDescriptor;
|
|
231
|
+
this.onRtcOffer(senderPeerDescriptor, receiverPeerDescriptor, request.description, request.connectionId);
|
|
228
232
|
return {};
|
|
229
233
|
}
|
|
230
|
-
async rtcAnswer(request,
|
|
231
|
-
|
|
234
|
+
async rtcAnswer(request, context) {
|
|
235
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
236
|
+
const receiverPeerDescriptor = context.incomingTargetDescriptor;
|
|
237
|
+
this.onRtcAnswer(senderPeerDescriptor, receiverPeerDescriptor, request.description, request.connectionId);
|
|
232
238
|
return {};
|
|
233
239
|
}
|
|
234
|
-
async iceCandidate(request,
|
|
235
|
-
|
|
240
|
+
async iceCandidate(request, context) {
|
|
241
|
+
const senderPeerDescriptor = context.incomingSourceDescriptor;
|
|
242
|
+
const receiverPeerDescriptor = context.incomingTargetDescriptor;
|
|
243
|
+
this.onRemoteCandidate(senderPeerDescriptor, receiverPeerDescriptor, request.candidate, request.mid, request.connectionId);
|
|
236
244
|
return {};
|
|
237
245
|
}
|
|
238
246
|
}
|
|
239
|
-
exports.
|
|
240
|
-
|
|
241
|
-
//# sourceMappingURL=
|
|
247
|
+
exports.WebRtcConnectorRpcLocal = WebRtcConnectorRpcLocal;
|
|
248
|
+
WebRtcConnectorRpcLocal.WEBRTC_CONNECTOR_SERVICE_ID = 'system/webrtc-connector';
|
|
249
|
+
//# sourceMappingURL=WebRtcConnectorRpcLocal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebRtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/WebRTC/WebRtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAK+C;AAG/C,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,iFAAwF;AAExF,wEAAoE;AACpE,0CAAuC;AACvC,0DAA2C;AAG3C,kDAAqD;AACrD,qFAI+C;AAC/C,6DAAsF;AAKtF,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,+BAA+B,GAAG,CAAC,SAAiB,EAAE,EAAU,EAAU,EAAE;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IACtB,IAAI,IAAI,KAAK,MAAM,EAAE;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;KACjB;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC,CAAA;AAPY,QAAA,+BAA+B,mCAO3C;AAsBD,MAAa,uBAAuB;IAYhC,YACI,MAAqC,EACrC,oBAAgE;QAVnD,2BAAsB,GAA4C,IAAI,GAAG,EAAE,CAAA;QAEpF,YAAO,GAAG,KAAK,CAAA;QAUnB,IAAI,CAAC,MAAM,GAAG,MAAM,C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dht/contact/Remote';
|
|
2
|
+
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
+
import { IWebRtcConnectorRpcClient } from '../../proto/packages/dht/protos/DhtRpc.client';
|
|
4
|
+
import { ProtoRpcClient } from '@streamr/proto-rpc';
|
|
5
|
+
export declare class WebRtcConnectorRpcRemote extends Remote<IWebRtcConnectorRpcClient> {
|
|
6
|
+
constructor(localPeerDescriptor: PeerDescriptor, remotePeerDescriptor: PeerDescriptor, client: ProtoRpcClient<IWebRtcConnectorRpcClient>);
|
|
7
|
+
requestConnection(connectionId: string): void;
|
|
8
|
+
sendRtcOffer(description: string, connectionId: string): void;
|
|
9
|
+
sendRtcAnswer(description: string, connectionId: string): void;
|
|
10
|
+
sendIceCandidate(candidate: string, mid: string, connectionId: string): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebRtcConnectorRpcRemote = void 0;
|
|
4
|
+
const Remote_1 = require("../../dht/contact/Remote");
|
|
5
|
+
const utils_1 = require("@streamr/utils");
|
|
6
|
+
const logger = new utils_1.Logger(module);
|
|
7
|
+
class WebRtcConnectorRpcRemote extends Remote_1.Remote {
|
|
8
|
+
constructor(localPeerDescriptor, remotePeerDescriptor, client) {
|
|
9
|
+
super(localPeerDescriptor, remotePeerDescriptor, 'DUMMY', client);
|
|
10
|
+
}
|
|
11
|
+
requestConnection(connectionId) {
|
|
12
|
+
const request = {
|
|
13
|
+
connectionId
|
|
14
|
+
};
|
|
15
|
+
const options = this.formDhtRpcOptions({
|
|
16
|
+
notification: true
|
|
17
|
+
});
|
|
18
|
+
this.getClient().requestConnection(request, options).catch((_e) => {
|
|
19
|
+
logger.trace('Failed to send requestConnection');
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
sendRtcOffer(description, connectionId) {
|
|
23
|
+
const request = {
|
|
24
|
+
connectionId,
|
|
25
|
+
description
|
|
26
|
+
};
|
|
27
|
+
const options = this.formDhtRpcOptions();
|
|
28
|
+
this.getClient().rtcOffer(request, options).catch((_e) => {
|
|
29
|
+
logger.trace('Failed to send rtcOffer');
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
sendRtcAnswer(description, connectionId) {
|
|
33
|
+
const request = {
|
|
34
|
+
connectionId,
|
|
35
|
+
description
|
|
36
|
+
};
|
|
37
|
+
const options = this.formDhtRpcOptions();
|
|
38
|
+
this.getClient().rtcAnswer(request, options).catch((_e) => {
|
|
39
|
+
logger.trace('Failed to send rtcAnswer');
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
sendIceCandidate(candidate, mid, connectionId) {
|
|
43
|
+
const request = {
|
|
44
|
+
connectionId,
|
|
45
|
+
mid,
|
|
46
|
+
candidate
|
|
47
|
+
};
|
|
48
|
+
const options = this.formDhtRpcOptions();
|
|
49
|
+
this.getClient().iceCandidate(request, options).catch((_e) => {
|
|
50
|
+
logger.trace('Failed to send iceCandidate');
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.WebRtcConnectorRpcRemote = WebRtcConnectorRpcRemote;
|
|
55
|
+
//# sourceMappingURL=WebRtcConnectorRpcRemote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebRtcConnectorRpcRemote.js","sourceRoot":"","sources":["../../../../src/connection/WebRTC/WebRtcConnectorRpcRemote.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAUjD,0CAAuC;AAEvC,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,MAAa,wBAAyB,SAAQ,eAAiC;IAE3E,YACI,mBAAmC,EACnC,oBAAoC,EACpC,MAAiD;QAEjD,KAAK,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACrE,CAAC;IAED,iBAAiB,CAAC,YAAoB;QAClC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AI,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE;YACzD,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAvDD,4DAuDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IceServer } from './
|
|
1
|
+
import { IceServer } from './WebRtcConnectorRpcLocal';
|
|
2
2
|
export declare function iceServerAsString({ url, port, username, password, tcp }: IceServer): string;
|
package/dist/src/connection/WebSocket/{WebSocketConnector.d.ts → WebSocketConnectorRpcLocal.d.ts}
RENAMED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
import { ITransport } from '../../transport/ITransport';
|
|
2
2
|
import { ConnectivityMethod, ConnectivityResponse, PeerDescriptor, WebSocketConnectionRequest, WebSocketConnectionResponse } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
-
import {
|
|
4
|
-
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
3
|
+
import { IWebSocketConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.server';
|
|
5
4
|
import { ManagedConnection } from '../ManagedConnection';
|
|
6
5
|
import { PortRange, TlsCertificate } from '../ConnectionManager';
|
|
6
|
+
import { ServerCallContext } from '@protobuf-ts/runtime-rpc';
|
|
7
7
|
export declare const connectivityMethodToWebSocketUrl: (ws: ConnectivityMethod) => string;
|
|
8
|
-
|
|
8
|
+
interface WebSocketConnectorRpcLocalConfig {
|
|
9
|
+
transport: ITransport;
|
|
10
|
+
canConnect: (peerDescriptor: PeerDescriptor, _ip: string, port: number) => boolean;
|
|
11
|
+
onIncomingConnection: (connection: ManagedConnection) => boolean;
|
|
12
|
+
portRange?: PortRange;
|
|
13
|
+
maxMessageSize?: number;
|
|
14
|
+
host?: string;
|
|
15
|
+
entrypoints?: PeerDescriptor[];
|
|
16
|
+
tlsCertificate?: TlsCertificate;
|
|
17
|
+
}
|
|
18
|
+
export declare class WebSocketConnectorRpcLocal implements IWebSocketConnectorRpc {
|
|
9
19
|
private static readonly WEBSOCKET_CONNECTOR_SERVICE_ID;
|
|
10
20
|
private readonly rpcCommunicator;
|
|
11
21
|
private readonly canConnectFunction;
|
|
12
22
|
private readonly webSocketServer?;
|
|
13
23
|
private connectivityChecker?;
|
|
14
24
|
private readonly ongoingConnectRequests;
|
|
15
|
-
private
|
|
16
|
-
private portRange?;
|
|
25
|
+
private onIncomingConnection;
|
|
17
26
|
private host?;
|
|
18
|
-
private entrypoints?;
|
|
27
|
+
private readonly entrypoints?;
|
|
19
28
|
private readonly tlsCertificate?;
|
|
20
29
|
private selectedPort?;
|
|
21
|
-
private readonly protocolVersion;
|
|
22
30
|
private ownPeerDescriptor?;
|
|
23
31
|
private connectingConnections;
|
|
24
32
|
private destroyed;
|
|
25
|
-
constructor(
|
|
33
|
+
constructor(config: WebSocketConnectorRpcLocalConfig);
|
|
26
34
|
private attachHandshaker;
|
|
27
35
|
start(): Promise<void>;
|
|
28
|
-
checkConnectivity(
|
|
36
|
+
checkConnectivity(): Promise<ConnectivityResponse>;
|
|
37
|
+
isPossibleToFormConnection(targetPeerDescriptor: PeerDescriptor): boolean;
|
|
29
38
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
30
|
-
requestConnectionFromPeer
|
|
39
|
+
private requestConnectionFromPeer;
|
|
31
40
|
private onServerSocketHandshakeRequest;
|
|
32
41
|
setOwnPeerDescriptor(ownPeerDescriptor: PeerDescriptor): void;
|
|
33
42
|
destroy(): Promise<void>;
|
|
34
|
-
requestConnection(request: WebSocketConnectionRequest,
|
|
43
|
+
requestConnection(request: WebSocketConnectionRequest, context: ServerCallContext): Promise<WebSocketConnectionResponse>;
|
|
35
44
|
}
|
|
45
|
+
export {};
|