@streamr/dht 100.2.5-beta.0 → 101.0.0-beta.0
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 +7 -7
- 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 +7 -7
- 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
|
@@ -1,50 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ConnectionID, IConnection } from './IConnection';
|
|
2
|
+
import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
|
|
3
3
|
import EventEmitter from 'eventemitter3';
|
|
4
4
|
import { DhtAddress } from '../identifiers';
|
|
5
5
|
export interface ManagedConnectionEvents {
|
|
6
6
|
managedData: (bytes: Uint8Array, remotePeerDescriptor: PeerDescriptor) => void;
|
|
7
|
-
|
|
8
|
-
handshakeCompleted: (peerDescriptor: PeerDescriptor) => void;
|
|
9
|
-
handshakeFailed: () => void;
|
|
7
|
+
disconnected: (gracefulLeave: boolean) => void;
|
|
10
8
|
}
|
|
11
|
-
export type Events = ManagedConnectionEvents
|
|
12
|
-
export declare class ManagedConnection extends EventEmitter<
|
|
13
|
-
private
|
|
14
|
-
private outputBufferEmitter;
|
|
15
|
-
private outputBuffer;
|
|
16
|
-
private inputBuffer;
|
|
9
|
+
export type Events = ManagedConnectionEvents;
|
|
10
|
+
export declare class ManagedConnection extends EventEmitter<ManagedConnectionEvents> {
|
|
11
|
+
private connection;
|
|
17
12
|
connectionId: ConnectionID;
|
|
18
|
-
private remotePeerDescriptor
|
|
19
|
-
connectionType: ConnectionType;
|
|
20
|
-
private handshaker?;
|
|
21
|
-
private handshakeCompleted;
|
|
13
|
+
private remotePeerDescriptor;
|
|
22
14
|
private lastUsedTimestamp;
|
|
15
|
+
private replacedAsDuplicate;
|
|
23
16
|
private stopped;
|
|
24
|
-
|
|
25
|
-
private
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
protected incomingConnection?: IConnection;
|
|
30
|
-
private created;
|
|
31
|
-
constructor(localPeerDescriptor: PeerDescriptor, connectionType: ConnectionType, outgoingConnection?: IConnection, incomingConnection?: IConnection, targetPeerDescriptor?: PeerDescriptor);
|
|
32
|
-
on(event: keyof Events, fn: (...args: any) => void, context?: any): this;
|
|
33
|
-
once(event: keyof Events, fn: (...args: any) => void, context?: any): this;
|
|
17
|
+
constructor(peerDescriptor: PeerDescriptor, connection: IConnection);
|
|
18
|
+
private onDisconnected;
|
|
19
|
+
replaceAsDuplicate(): void;
|
|
20
|
+
send(data: Uint8Array): void;
|
|
21
|
+
close(gracefulLeave: boolean): Promise<void>;
|
|
34
22
|
getNodeId(): DhtAddress;
|
|
35
23
|
getLastUsedTimestamp(): number;
|
|
36
|
-
setRemotePeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
37
24
|
getPeerDescriptor(): PeerDescriptor | undefined;
|
|
38
|
-
private onHandshakeCompleted;
|
|
39
|
-
attachImplementation(impl: IConnection): void;
|
|
40
|
-
private onDisconnected;
|
|
41
|
-
send(data: Uint8Array, connect: boolean): Promise<void>;
|
|
42
|
-
sendNoWait(data: Uint8Array): void;
|
|
43
|
-
reportBufferSentByOtherConnection(): void;
|
|
44
|
-
acceptHandshake(): void;
|
|
45
|
-
rejectHandshake(error: HandshakeError): void;
|
|
46
|
-
close(gracefulLeave: boolean): Promise<void>;
|
|
47
|
-
destroy(): void;
|
|
48
|
-
isHandshakeCompleted(): boolean;
|
|
49
|
-
stealOutputBuffer(): Uint8Array[];
|
|
50
25
|
}
|
|
@@ -28,289 +28,68 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ManagedConnection = void 0;
|
|
30
30
|
const Err = __importStar(require("../helpers/errors"));
|
|
31
|
-
const Handshaker_1 = require("./Handshaker");
|
|
32
|
-
const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
|
|
33
31
|
const utils_1 = require("@streamr/utils");
|
|
34
32
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
35
33
|
const ConnectionManager_1 = require("./ConnectionManager");
|
|
36
34
|
const identifiers_1 = require("../identifiers");
|
|
37
35
|
const Connection_1 = require("./Connection");
|
|
38
36
|
const logger = new utils_1.Logger(module);
|
|
37
|
+
// ManagedConnection is a component used as a wrapper for IConnection after they have been successfully handshaked.
|
|
38
|
+
// Should only be used in the ConnectionManager.
|
|
39
39
|
class ManagedConnection extends eventemitter3_1.default {
|
|
40
|
-
|
|
41
|
-
outputBufferEmitter = new eventemitter3_1.default();
|
|
42
|
-
outputBuffer = [];
|
|
43
|
-
inputBuffer = [];
|
|
40
|
+
connection;
|
|
44
41
|
connectionId;
|
|
45
42
|
remotePeerDescriptor;
|
|
46
|
-
connectionType;
|
|
47
|
-
handshaker;
|
|
48
|
-
handshakeCompleted = false;
|
|
49
43
|
lastUsedTimestamp = Date.now();
|
|
44
|
+
replacedAsDuplicate = false;
|
|
50
45
|
stopped = false;
|
|
51
|
-
|
|
52
|
-
closing = false;
|
|
53
|
-
replacedByOtherConnection = false;
|
|
54
|
-
localPeerDescriptor;
|
|
55
|
-
outgoingConnection;
|
|
56
|
-
incomingConnection;
|
|
57
|
-
// TODO: Temporary debug variable, should be removed in the future.
|
|
58
|
-
created = Date.now();
|
|
59
|
-
constructor(localPeerDescriptor, connectionType, outgoingConnection, incomingConnection, targetPeerDescriptor) {
|
|
46
|
+
constructor(peerDescriptor, connection) {
|
|
60
47
|
super();
|
|
61
|
-
this.localPeerDescriptor = localPeerDescriptor;
|
|
62
|
-
this.outgoingConnection = outgoingConnection;
|
|
63
|
-
this.incomingConnection = incomingConnection;
|
|
64
|
-
this.connectionType = connectionType;
|
|
65
48
|
this.connectionId = (0, Connection_1.createRandomConnectionId)();
|
|
66
|
-
this.
|
|
67
|
-
|
|
68
|
-
logger.trace('creating ManagedConnection of type: ' + connectionType);
|
|
69
|
-
if (incomingConnection && outgoingConnection) {
|
|
70
|
-
throw new Err.IllegalArguments('Managed connection constructor only accepts either an incoming connection OR a outgoing connection');
|
|
71
|
-
}
|
|
72
|
-
if (outgoingConnection) {
|
|
73
|
-
this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, outgoingConnection);
|
|
74
|
-
this.handshaker.once('handshakeFailed', (error) => {
|
|
75
|
-
if (error === DhtRpc_1.HandshakeError.INVALID_TARGET_PEER_DESCRIPTOR || error === DhtRpc_1.HandshakeError.UNSUPPORTED_VERSION) {
|
|
76
|
-
// TODO should we have some handling for this floating promise?
|
|
77
|
-
this.close(false);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' handshakeFailed: ' + error);
|
|
81
|
-
this.emit('handshakeFailed');
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
this.handshaker.on('handshakeCompleted', (peerDescriptor) => {
|
|
85
|
-
logger.trace('handshake completed for outgoing connection '
|
|
86
|
-
+ ', ' + (0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor)
|
|
87
|
-
+ ' outputBuffer.length: ' + this.outputBuffer.length);
|
|
88
|
-
this.attachImplementation(outgoingConnection);
|
|
89
|
-
this.onHandshakeCompleted(peerDescriptor);
|
|
90
|
-
});
|
|
91
|
-
outgoingConnection.once('connected', () => {
|
|
92
|
-
this.handshaker.sendHandshakeRequest(targetPeerDescriptor);
|
|
93
|
-
this.emit('connected');
|
|
94
|
-
});
|
|
95
|
-
outgoingConnection.once('disconnected', this.onDisconnected);
|
|
96
|
-
}
|
|
97
|
-
else if (incomingConnection) {
|
|
98
|
-
this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, incomingConnection);
|
|
99
|
-
this.handshaker.on('handshakeRequest', (sourcePeerDescriptor, version, targetPeerDescriptor) => {
|
|
100
|
-
this.setRemotePeerDescriptor(sourcePeerDescriptor);
|
|
101
|
-
this.emit('handshakeRequest', sourcePeerDescriptor, version, targetPeerDescriptor);
|
|
102
|
-
});
|
|
103
|
-
incomingConnection.on('disconnected', this.onDisconnected);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// eventemitter3 does not implement the standard 'newListener' event, so we need to override
|
|
107
|
-
on(event, fn,
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
109
|
-
context) {
|
|
110
|
-
if (event === 'managedData' && this.listenerCount('managedData') === 0) {
|
|
111
|
-
while (this.inputBuffer.length > 0) {
|
|
112
|
-
logger.trace('emptying inputBuffer');
|
|
113
|
-
const data = this.inputBuffer.shift();
|
|
114
|
-
fn(data, this.getPeerDescriptor());
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
super.on(event, fn, context);
|
|
118
|
-
return this;
|
|
119
|
-
}
|
|
120
|
-
once(event, fn,
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
122
|
-
context) {
|
|
123
|
-
if (event === 'managedData' && this.listenerCount('managedData') === 0) {
|
|
124
|
-
if (this.inputBuffer.length > 0) {
|
|
125
|
-
while (this.inputBuffer.length > 0) {
|
|
126
|
-
logger.trace('emptying inputBuffer');
|
|
127
|
-
const data = this.inputBuffer.shift();
|
|
128
|
-
fn(data, this.getPeerDescriptor());
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
super.once(event, fn, context);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
super.once(event, fn, context);
|
|
137
|
-
}
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
getNodeId() {
|
|
141
|
-
return (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
142
|
-
}
|
|
143
|
-
getLastUsedTimestamp() {
|
|
144
|
-
return this.lastUsedTimestamp;
|
|
145
|
-
}
|
|
146
|
-
setRemotePeerDescriptor(peerDescriptor) {
|
|
147
|
-
this.remotePeerDescriptor = peerDescriptor;
|
|
148
|
-
}
|
|
149
|
-
getPeerDescriptor() {
|
|
150
|
-
return this.remotePeerDescriptor;
|
|
151
|
-
}
|
|
152
|
-
onHandshakeCompleted(peerDescriptor) {
|
|
153
|
-
this.lastUsedTimestamp = Date.now();
|
|
154
|
-
this.setRemotePeerDescriptor(peerDescriptor);
|
|
155
|
-
this.handshakeCompleted = true;
|
|
156
|
-
this.handshaker.stop();
|
|
157
|
-
while (this.outputBuffer.length > 0) {
|
|
158
|
-
logger.trace('emptying outputBuffer');
|
|
159
|
-
this.implementation.send(this.outputBuffer.shift());
|
|
160
|
-
}
|
|
161
|
-
this.outputBufferEmitter.emit('bufferSent');
|
|
162
|
-
logger.trace('emitting handshake_completed');
|
|
163
|
-
this.emit('handshakeCompleted', peerDescriptor);
|
|
164
|
-
}
|
|
165
|
-
attachImplementation(impl) {
|
|
166
|
-
logger.trace('attachImplementation()');
|
|
167
|
-
this.implementation = impl;
|
|
168
|
-
impl.on('data', (bytes) => {
|
|
49
|
+
this.connection = connection;
|
|
50
|
+
connection.on('data', (bytes) => {
|
|
169
51
|
this.lastUsedTimestamp = Date.now();
|
|
170
|
-
|
|
171
|
-
this.inputBuffer.push(bytes);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
this.emit('managedData', bytes, this.getPeerDescriptor());
|
|
175
|
-
}
|
|
52
|
+
this.emit('managedData', bytes, this.getPeerDescriptor());
|
|
176
53
|
});
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
impl.on('connected', () => {
|
|
181
|
-
this.lastUsedTimestamp = Date.now();
|
|
182
|
-
logger.trace('connected emitted');
|
|
183
|
-
this.emit('connected');
|
|
184
|
-
});
|
|
185
|
-
//ensure that we have subscribed to the event only once
|
|
186
|
-
impl.off('disconnected', this.onDisconnected);
|
|
187
|
-
impl.on('disconnected', this.onDisconnected);
|
|
54
|
+
connection.on('disconnected', (gracefulLeave) => this.onDisconnected(gracefulLeave));
|
|
55
|
+
this.lastUsedTimestamp = Date.now();
|
|
56
|
+
this.remotePeerDescriptor = peerDescriptor;
|
|
188
57
|
}
|
|
189
58
|
onDisconnected(gracefulLeave) {
|
|
190
59
|
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' onDisconnected() ' + gracefulLeave);
|
|
191
|
-
if (this.
|
|
192
|
-
|
|
60
|
+
if (!this.replacedAsDuplicate) {
|
|
61
|
+
this.emit('disconnected', gracefulLeave);
|
|
193
62
|
}
|
|
194
|
-
this.
|
|
195
|
-
this.emit('disconnected', gracefulLeave);
|
|
63
|
+
this.removeAllListeners();
|
|
196
64
|
}
|
|
197
|
-
|
|
65
|
+
// TODO: Can this be removed if ManagedConnections can never be duplicates?
|
|
66
|
+
// Handle duplicates in the ConncetorFacade and no longer have PendingConnections in ConnectionManager
|
|
67
|
+
replaceAsDuplicate() {
|
|
68
|
+
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' replaceAsDuplicate');
|
|
69
|
+
this.replacedAsDuplicate = true;
|
|
70
|
+
}
|
|
71
|
+
send(data) {
|
|
198
72
|
if (this.stopped) {
|
|
199
73
|
throw new Err.SendFailed('ManagedConnection is stopped');
|
|
200
74
|
}
|
|
201
|
-
if (this.closing) {
|
|
202
|
-
throw new Err.SendFailed('ManagedConnection is closing');
|
|
203
|
-
}
|
|
204
|
-
this.lastUsedTimestamp = Date.now();
|
|
205
|
-
if (!connect && !this.implementation) {
|
|
206
|
-
throw new Err.ConnectionNotOpen('Connection not open when calling send() with connect flag as false');
|
|
207
|
-
}
|
|
208
|
-
else if (this.implementation) {
|
|
209
|
-
this.implementation.send(data);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
logger.trace('adding data to outputBuffer');
|
|
213
|
-
let result;
|
|
214
|
-
try {
|
|
215
|
-
result = await (0, utils_1.runAndRaceEvents3)([() => { this.outputBuffer.push(data); }], this.outputBufferEmitter, ['bufferSent', 'bufferSendingFailed'], 15000); // TODO use config option or named constant?
|
|
216
|
-
}
|
|
217
|
-
catch (e) {
|
|
218
|
-
logger.debug(`Connection to ${(0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor)} timed out`, {
|
|
219
|
-
peerDescriptor: this.remotePeerDescriptor,
|
|
220
|
-
type: this.connectionType,
|
|
221
|
-
lifetime: Date.now() - this.created
|
|
222
|
-
});
|
|
223
|
-
await this.close(false);
|
|
224
|
-
throw new Err.SendFailed('Sending buffer timed out');
|
|
225
|
-
}
|
|
226
|
-
if (result.winnerName === 'bufferSendingFailed') {
|
|
227
|
-
throw new Err.SendFailed('Sending buffer failed');
|
|
228
|
-
}
|
|
229
|
-
// buffer was sent successfully, return normally
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
sendNoWait(data) {
|
|
233
75
|
this.lastUsedTimestamp = Date.now();
|
|
234
|
-
|
|
235
|
-
this.implementation.send(data);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
logger.trace('adding data to outputBuffer');
|
|
239
|
-
this.outputBuffer.push(data);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
reportBufferSentByOtherConnection() {
|
|
243
|
-
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' reportBufferSentByOtherConnection');
|
|
244
|
-
if (this.handshaker) {
|
|
245
|
-
this.handshaker.removeAllListeners();
|
|
246
|
-
}
|
|
247
|
-
logger.trace('bufferSentByOtherConnection reported');
|
|
248
|
-
this.bufferSentbyOtherConnection = true;
|
|
249
|
-
this.outputBufferEmitter.emit('bufferSent');
|
|
250
|
-
}
|
|
251
|
-
acceptHandshake() {
|
|
252
|
-
// This happens when connectionRequest has been made and answered
|
|
253
|
-
if (this.implementation) {
|
|
254
|
-
if (!this.handshaker) {
|
|
255
|
-
this.handshaker = new Handshaker_1.Handshaker(this.localPeerDescriptor, this.implementation);
|
|
256
|
-
}
|
|
257
|
-
this.handshaker.sendHandshakeResponse();
|
|
258
|
-
}
|
|
259
|
-
else { // This happens to when there is a regular incoming connection
|
|
260
|
-
this.handshaker.sendHandshakeResponse();
|
|
261
|
-
this.attachImplementation(this.incomingConnection);
|
|
262
|
-
}
|
|
263
|
-
this.onHandshakeCompleted(this.remotePeerDescriptor);
|
|
264
|
-
}
|
|
265
|
-
rejectHandshake(error) {
|
|
266
|
-
this.handshaker.sendHandshakeResponse(error);
|
|
267
|
-
this.destroy();
|
|
76
|
+
this.connection.send(data);
|
|
268
77
|
}
|
|
269
78
|
async close(gracefulLeave) {
|
|
270
|
-
if (this.
|
|
79
|
+
if (this.stopped) {
|
|
271
80
|
return;
|
|
272
81
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
this.closing = true;
|
|
277
|
-
this.outputBufferEmitter.emit('bufferSendingFailed');
|
|
278
|
-
if (this.implementation) {
|
|
279
|
-
await this.implementation?.close(gracefulLeave);
|
|
280
|
-
}
|
|
281
|
-
else if (this.outgoingConnection) {
|
|
282
|
-
await this.outgoingConnection?.close(gracefulLeave);
|
|
283
|
-
}
|
|
284
|
-
else if (this.incomingConnection) {
|
|
285
|
-
await this.incomingConnection?.close(gracefulLeave);
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
this.emit('disconnected', gracefulLeave);
|
|
289
|
-
}
|
|
82
|
+
await this.connection.close(gracefulLeave);
|
|
83
|
+
this.removeAllListeners();
|
|
290
84
|
}
|
|
291
|
-
|
|
292
|
-
this.
|
|
293
|
-
if (!this.stopped) {
|
|
294
|
-
this.stopped = true;
|
|
295
|
-
this.removeAllListeners();
|
|
296
|
-
if (this.implementation) {
|
|
297
|
-
this.implementation?.destroy();
|
|
298
|
-
}
|
|
299
|
-
else if (this.outgoingConnection) {
|
|
300
|
-
this.outgoingConnection?.destroy();
|
|
301
|
-
}
|
|
302
|
-
else if (this.incomingConnection) {
|
|
303
|
-
this.incomingConnection?.destroy();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
85
|
+
getNodeId() {
|
|
86
|
+
return (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.remotePeerDescriptor);
|
|
306
87
|
}
|
|
307
|
-
|
|
308
|
-
return this.
|
|
88
|
+
getLastUsedTimestamp() {
|
|
89
|
+
return this.lastUsedTimestamp;
|
|
309
90
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
this.outputBuffer = [];
|
|
313
|
-
return ret;
|
|
91
|
+
getPeerDescriptor() {
|
|
92
|
+
return this.remotePeerDescriptor;
|
|
314
93
|
}
|
|
315
94
|
}
|
|
316
95
|
exports.ManagedConnection = ManagedConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManagedConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAwC;
|
|
1
|
+
{"version":3,"file":"ManagedConnection.js","sourceRoot":"","sources":["../../../src/connection/ManagedConnection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAwC;AAExC,0CAAuC;AACvC,kEAAwC;AACxC,2DAA0E;AAC1E,gDAAwE;AACxE,6CAAuD;AAOvD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAIjC,mHAAmH;AACnH,gDAAgD;AAChD,MAAa,iBAAkB,SAAQ,uBAAqC;IAEhE,UAAU,CAAa;IACxB,YAAY,CAAc;IACzB,oBAAoB,CAAgB;IACpC,iBAAiB,GAAW,IAAI,CAAC,GAAG,EAAE,CA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;IAED,IAAI,CAAC,IAAgB;QACjB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAA;QAC5D,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,aAAsB;QAC9B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAM;QACV,CAAC;QACD,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC1C,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC7B,CAAC;IAED,SAAS;QACL,OAAO,IAAA,yCAA2B,EAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IACjE,CAAC;IAED,oBAAoB;QAChB,OAAO,IAAI,CAAC,iBAAiB,CAAA;IACjC,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,oBAAoB,CAAA;IACpC,CAAC;CAEJ;AAnED,8CAmEC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OutputBuffer = void 0;
|
|
4
|
+
const utils_1 = require("@streamr/utils");
|
|
5
|
+
const errors_1 = require("../helpers/errors");
|
|
6
|
+
class OutputBuffer {
|
|
7
|
+
buffer = [];
|
|
8
|
+
deferredPromise = new utils_1.Defer();
|
|
9
|
+
push(message) {
|
|
10
|
+
this.buffer.push(message);
|
|
11
|
+
return this.deferredPromise;
|
|
12
|
+
}
|
|
13
|
+
getBuffer() {
|
|
14
|
+
return this.buffer;
|
|
15
|
+
}
|
|
16
|
+
resolve() {
|
|
17
|
+
this.buffer.length = 0;
|
|
18
|
+
this.deferredPromise.resolve();
|
|
19
|
+
}
|
|
20
|
+
reject() {
|
|
21
|
+
this.buffer.length = 0;
|
|
22
|
+
this.deferredPromise.reject(new errors_1.SendFailed('Could not send buffered messages'));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.OutputBuffer = OutputBuffer;
|
|
26
|
+
//# sourceMappingURL=OutputBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutputBuffer.js","sourceRoot":"","sources":["../../../src/connection/OutputBuffer.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,8CAA8C;AAE9C,MAAa,YAAY;IAEJ,MAAM,GAAiB,EAAE,CAAA;IACzB,eAAe,GAAgB,IAAI,aAAK,EAAQ,CAAA;IAEjE,IAAI,CAAC,OAAmB;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzB,OAAO,IAAI,CAAC,eAAe,CAAA;IAC/B,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAA;IACtB,CAAC;IAED,OAAO;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;IAED,MAAM;QACF,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,mBAAU,CAAC,kCAAkC,CAAC,CAAC,CAAA;IACnF,CAAC;CAEJ;AAxBD,oCAwBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import EventEmitter from 'eventemitter3';
|
|
2
|
+
import { PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc';
|
|
3
|
+
import { IConnection } from './IConnection';
|
|
4
|
+
export interface PendingConnectionEvents {
|
|
5
|
+
connected: (peerDescriptor: PeerDescriptor, connection: IConnection) => void;
|
|
6
|
+
disconnected: (gracefulLeave: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare class PendingConnection extends EventEmitter<PendingConnectionEvents> {
|
|
9
|
+
private readonly connectingAbortController;
|
|
10
|
+
private remotePeerDescriptor;
|
|
11
|
+
private replacedAsDuplicate;
|
|
12
|
+
private stopped;
|
|
13
|
+
constructor(remotePeerDescriptor: PeerDescriptor, timeout?: number);
|
|
14
|
+
replaceAsDuplicate(): void;
|
|
15
|
+
onHandshakeCompleted(connection: IConnection): void;
|
|
16
|
+
close(graceful: boolean): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
getPeerDescriptor(): PeerDescriptor;
|
|
19
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PendingConnection = void 0;
|
|
7
|
+
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
8
|
+
const utils_1 = require("@streamr/utils");
|
|
9
|
+
const ConnectionManager_1 = require("./ConnectionManager");
|
|
10
|
+
const logger = new utils_1.Logger(module);
|
|
11
|
+
// PendingConnection is used as a reference to a connection that should be opened and handshaked to a given PeerDescriptor
|
|
12
|
+
// It does not hold a connection internally. The public method onHandshakedCompleted should be called once a connection for the
|
|
13
|
+
// remotePeerDescriptor is opened and handshaked successfully.
|
|
14
|
+
// PendingConnections are created by the Connectors.
|
|
15
|
+
class PendingConnection extends eventemitter3_1.default {
|
|
16
|
+
connectingAbortController = new AbortController();
|
|
17
|
+
remotePeerDescriptor;
|
|
18
|
+
replacedAsDuplicate = false;
|
|
19
|
+
stopped = false;
|
|
20
|
+
constructor(remotePeerDescriptor, timeout = 15 * 1000) {
|
|
21
|
+
super();
|
|
22
|
+
this.remotePeerDescriptor = remotePeerDescriptor;
|
|
23
|
+
(0, utils_1.setAbortableTimeout)(() => {
|
|
24
|
+
this.close(false);
|
|
25
|
+
}, timeout, this.connectingAbortController.signal);
|
|
26
|
+
}
|
|
27
|
+
replaceAsDuplicate() {
|
|
28
|
+
logger.trace((0, ConnectionManager_1.getNodeIdOrUnknownFromPeerDescriptor)(this.remotePeerDescriptor) + ' replaceAsDuplicate');
|
|
29
|
+
this.replacedAsDuplicate = true;
|
|
30
|
+
}
|
|
31
|
+
onHandshakeCompleted(connection) {
|
|
32
|
+
if (!this.replacedAsDuplicate) {
|
|
33
|
+
this.emit('connected', this.remotePeerDescriptor, connection);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
close(graceful) {
|
|
37
|
+
if (this.stopped) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.stopped = true;
|
|
41
|
+
this.connectingAbortController.abort();
|
|
42
|
+
if (!this.replacedAsDuplicate) {
|
|
43
|
+
this.emit('disconnected', graceful);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
if (this.stopped) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.stopped = true;
|
|
51
|
+
this.connectingAbortController.abort();
|
|
52
|
+
this.removeAllListeners();
|
|
53
|
+
}
|
|
54
|
+
getPeerDescriptor() {
|
|
55
|
+
return this.remotePeerDescriptor;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PendingConnection = PendingConnection;
|
|
59
|
+
//# sourceMappingURL=PendingConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PendingConnection.js","sourceRoot":"","sources":["../../../src/connection/PendingConnection.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAwC;AAExC,0CAA4D;AAC5D,2DAA0E;AAQ1E,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,0HAA0H;AAC1H,gIAAgI;AAChI,8DAA8D;AAC9D,oDAAoD;AACpD,MAAa,iBAAkB,SAAQ,uBAAqC;IAEvD,yBAAy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yB,CAAC,KAAK,EAAE,CAAA;QACtC,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC7B,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,oBAAoB,CAAA;IACpC,CAAC;CAEJ;AAlDD,8CAkDC"}
|
|
@@ -29,10 +29,10 @@ const uuid_1 = require("uuid");
|
|
|
29
29
|
const Err = __importStar(require("../helpers/errors"));
|
|
30
30
|
const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
|
|
31
31
|
const NodeWebsocketClientConnection_1 = require("./websocket/NodeWebsocketClientConnection");
|
|
32
|
-
const
|
|
32
|
+
const WebsocketClientConnector_1 = require("./websocket/WebsocketClientConnector");
|
|
33
33
|
const version_1 = require("../helpers/version");
|
|
34
34
|
const logger = new utils_1.Logger(module);
|
|
35
|
-
// TODO use
|
|
35
|
+
// TODO use options option or named constant?
|
|
36
36
|
const connectAsync = async ({ url, allowSelfSignedCertificate, timeoutMs = 1000 }) => {
|
|
37
37
|
const socket = new NodeWebsocketClientConnection_1.WebsocketClientConnection();
|
|
38
38
|
let result;
|
|
@@ -59,7 +59,7 @@ const sendConnectivityRequest = async (request, entryPoint) => {
|
|
|
59
59
|
port: entryPoint.websocket.port,
|
|
60
60
|
tls: entryPoint.websocket.tls,
|
|
61
61
|
};
|
|
62
|
-
const url = (0,
|
|
62
|
+
const url = (0, WebsocketClientConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityRequest');
|
|
63
63
|
logger.debug(`Attempting connectivity check with entrypoint ${url}`);
|
|
64
64
|
try {
|
|
65
65
|
outgoingConnection = await (0, exports.connectAsync)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectivityChecker.js","sourceRoot":"","sources":["../../../src/connection/connectivityChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAsF;AACtF,+BAAyB;AACzB,uDAAwC;AACxC,gEAG4C;AAE5C,6FAAqF;AACrF,
|
|
1
|
+
{"version":3,"file":"connectivityChecker.js","sourceRoot":"","sources":["../../../src/connection/connectivityChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAAsF;AACtF,+BAAyB;AACzB,uDAAwC;AACxC,gEAG4C;AAE5C,6FAAqF;AACrF,mFAAuF;AACvF,gDAA4D;AAE5D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC,6CAA6C;AACtC,MAAM,YAAY,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,0BAA0B,EAAE,SAAS,GAAG,IAAI,EACV,EACpD,EAAE;IACtB,MAAM,MAAM,GAAG,IAAI,yDAAyB,EAAE,CAAA;IAC9C,IAAI,MAAoD,CAAA;IACxD,IAAI,CAAC;QACD,MAAM,GAAG,MAAM,IAAA,yBAAiB,EAAmB;YAC/C,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,0BAA0B,CAAC,CAAA,CAAC,CAAC;SAAC,EAC9D,MAAM,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,EAC9B,SAAS,CAAC,CAAA;IACd,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC,gCAAgC,CAAC,CAAA;IACpE,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC,qCAAqC,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,MAAM,CAAA;AACjB,CAAC,CAAA;AAjBY,QAAA,YAAY,gBAiBxB;AAEY,QAAA,+BAA+B,GAAG,6BAA6B,CAAA;AAC5E,MAAM,4BAA4B,GAAG,IAAI,CAAA;AAElC,MAAM,uBAAuB,GAAG,KAAK,EACxC,OAA4B,EAC5B,UAA0B,EACG,EAAE;IAC/B,IAAI,kBAA+B,CAAA;IACnC,MAAM,YAAY,GAAG;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A;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAA;QAClD,MAAM,CAAC,CAAA;IACX,CAAC;AACL,CAAC,CAAA;AArEY,QAAA,uBAAuB,2BAqEnC"}
|
|
@@ -6,7 +6,7 @@ const uuid_1 = require("uuid");
|
|
|
6
6
|
const DhtRpc_1 = require("../proto/packages/dht/protos/DhtRpc");
|
|
7
7
|
const ConnectionManager_1 = require("./ConnectionManager");
|
|
8
8
|
const connectivityChecker_1 = require("./connectivityChecker");
|
|
9
|
-
const
|
|
9
|
+
const WebsocketClientConnector_1 = require("./websocket/WebsocketClientConnector");
|
|
10
10
|
const version_1 = require("../helpers/version");
|
|
11
11
|
exports.DISABLE_CONNECTIVITY_PROBE = 0;
|
|
12
12
|
const logger = new utils_1.Logger(module);
|
|
@@ -75,7 +75,7 @@ const connectivityProbe = async (connectivityRequest, ipAddress, host) => {
|
|
|
75
75
|
port: connectivityRequest.port,
|
|
76
76
|
tls: connectivityRequest.tls
|
|
77
77
|
};
|
|
78
|
-
const url = (0,
|
|
78
|
+
const url = (0, WebsocketClientConnector_1.connectivityMethodToWebsocketUrl)(wsServerInfo, 'connectivityProbe');
|
|
79
79
|
logger.trace(`Attempting Connectivity Check to ${url}`);
|
|
80
80
|
outgoingConnection = await (0, connectivityChecker_1.connectAsync)({
|
|
81
81
|
url,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectivityRequestHandler.js","sourceRoot":"","sources":["../../../src/connection/connectivityRequestHandler.ts"],"names":[],"mappings":";;;AAAA,0CAAqD;AACrD,+BAAyB;AACzB,gEAI4C;AAC5C,2DAA6C;AAC7C,+DAAqF;AAGrF,
|
|
1
|
+
{"version":3,"file":"connectivityRequestHandler.js","sourceRoot":"","sources":["../../../src/connection/connectivityRequestHandler.ts"],"names":[],"mappings":";;;AAAA,0CAAqD;AACrD,+BAAyB;AACzB,gEAI4C;AAC5C,2DA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AE,CAAC;QACrB,+DAA+D;QAC/D,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,OAAO,2BAA2B,CAAA;AACtC,CAAC,CAAA"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import EventEmitter from 'eventemitter3';
|
|
2
1
|
import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc';
|
|
3
|
-
import { ConnectionSourceEvents } from '../IConnectionSource';
|
|
4
2
|
import { SimulatorConnector } from './SimulatorConnector';
|
|
5
3
|
import { SimulatorConnection } from './SimulatorConnection';
|
|
6
4
|
export declare enum LatencyType {
|
|
@@ -9,7 +7,7 @@ export declare enum LatencyType {
|
|
|
9
7
|
REAL = "REAL",
|
|
10
8
|
FIXED = "FIXED"
|
|
11
9
|
}
|
|
12
|
-
export declare class Simulator
|
|
10
|
+
export declare class Simulator {
|
|
13
11
|
private stopped;
|
|
14
12
|
private connectors;
|
|
15
13
|
private latencyTable?;
|