@streamr/dht 100.0.0-rc.0 → 100.0.0-rc.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 +7 -7
- package/dist/src/connection/Handshaker.js +1 -1
- package/dist/src/connection/webrtc/WebrtcConnector.d.ts +1 -0
- package/dist/src/connection/webrtc/WebrtcConnector.js +13 -8
- package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -0
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +1 -2
- package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
- package/package.json +7 -7
- package/src/connection/Handshaker.ts +1 -1
- package/src/connection/webrtc/NodeWebrtcConnection.ts +1 -1
- package/src/connection/webrtc/WebrtcConnector.ts +14 -8
- package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +2 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/dht",
|
|
3
|
-
"version": "100.0.0-rc.
|
|
3
|
+
"version": "100.0.0-rc.1",
|
|
4
4
|
"description": "Streamr Network DHT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@js-sdsl/ordered-map": "^4.4.2",
|
|
32
32
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
33
33
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
34
|
-
"@streamr/autocertifier-client": "100.0.0-rc.
|
|
35
|
-
"@streamr/cdn-location": "100.0.0-rc.
|
|
36
|
-
"@streamr/proto-rpc": "100.0.0-rc.
|
|
37
|
-
"@streamr/utils": "100.0.0-rc.
|
|
34
|
+
"@streamr/autocertifier-client": "100.0.0-rc.1",
|
|
35
|
+
"@streamr/cdn-location": "100.0.0-rc.1",
|
|
36
|
+
"@streamr/proto-rpc": "100.0.0-rc.1",
|
|
37
|
+
"@streamr/utils": "100.0.0-rc.1",
|
|
38
38
|
"eventemitter3": "^5.0.0",
|
|
39
39
|
"heap": "^0.2.6",
|
|
40
40
|
"ipaddr.js": "^2.0.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
52
|
-
"@streamr/test-utils": "100.0.0-rc.
|
|
52
|
+
"@streamr/test-utils": "100.0.0-rc.1",
|
|
53
53
|
"@types/express": "^4.17.21",
|
|
54
54
|
"@types/heap": "^0.2.34",
|
|
55
55
|
"@types/k-bucket": "^5.0.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/uuid": "^9.0.8",
|
|
58
58
|
"@types/websocket": "^1.0.10",
|
|
59
59
|
"@types/ws": "^8.5.10",
|
|
60
|
-
"express": "^4.
|
|
60
|
+
"express": "^4.18.3",
|
|
61
61
|
"jest-leak-detector": "^27.3.1",
|
|
62
62
|
"patch-package": "^8.0.0",
|
|
63
63
|
"ts-essentials": "^9.4.1",
|
|
@@ -40,7 +40,7 @@ class Handshaker extends eventemitter3_1.EventEmitter {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
|
-
logger.
|
|
43
|
+
logger.debug('error while parsing handshake message', err);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
sendHandshakeRequest(remotePeerDescriptor) {
|
|
@@ -31,6 +31,7 @@ export declare class WebrtcConnector {
|
|
|
31
31
|
constructor(config: WebrtcConnectorConfig, onNewConnection: (connection: ManagedConnection) => boolean);
|
|
32
32
|
private registerLocalRpcMethods;
|
|
33
33
|
connect(targetPeerDescriptor: PeerDescriptor): ManagedConnection;
|
|
34
|
+
private createConnection;
|
|
34
35
|
setLocalPeerDescriptor(peerDescriptor: PeerDescriptor): void;
|
|
35
36
|
stop(): Promise<void>;
|
|
36
37
|
}
|
|
@@ -61,6 +61,7 @@ class WebrtcConnector {
|
|
|
61
61
|
}
|
|
62
62
|
registerLocalRpcMethods(config, onNewConnection) {
|
|
63
63
|
const localRpc = new WebrtcConnectorRpcLocal_1.WebrtcConnectorRpcLocal({
|
|
64
|
+
createConnection: (targetPeerDescriptor) => this.createConnection(targetPeerDescriptor),
|
|
64
65
|
connect: (targetPeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
65
66
|
onNewConnection,
|
|
66
67
|
ongoingConnectAttempts: this.ongoingConnectAttempts,
|
|
@@ -111,14 +112,7 @@ class WebrtcConnector {
|
|
|
111
112
|
if (existingConnection) {
|
|
112
113
|
return existingConnection;
|
|
113
114
|
}
|
|
114
|
-
const connection =
|
|
115
|
-
remotePeerDescriptor: targetPeerDescriptor,
|
|
116
|
-
iceServers: this.config.iceServers,
|
|
117
|
-
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
118
|
-
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
119
|
-
connectingTimeout: this.config.connectionTimeout,
|
|
120
|
-
portRange: this.config.portRange
|
|
121
|
-
});
|
|
115
|
+
const connection = this.createConnection(targetPeerDescriptor);
|
|
122
116
|
const localNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(this.localPeerDescriptor);
|
|
123
117
|
const targetNodeId = (0, identifiers_1.getNodeIdFromPeerDescriptor)(targetPeerDescriptor);
|
|
124
118
|
const offering = ((0, offering_1.getOfferer)(localNodeId, targetNodeId) === 'local');
|
|
@@ -162,6 +156,17 @@ class WebrtcConnector {
|
|
|
162
156
|
}
|
|
163
157
|
return managedConnection;
|
|
164
158
|
}
|
|
159
|
+
createConnection(targetPeerDescriptor) {
|
|
160
|
+
return new NodeWebrtcConnection_1.NodeWebrtcConnection({
|
|
161
|
+
remotePeerDescriptor: targetPeerDescriptor,
|
|
162
|
+
iceServers: this.config.iceServers,
|
|
163
|
+
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
164
|
+
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
165
|
+
connectingTimeout: this.config.connectionTimeout,
|
|
166
|
+
portRange: this.config.portRange
|
|
167
|
+
// TODO should we pass maxMessageSize?
|
|
168
|
+
});
|
|
169
|
+
}
|
|
165
170
|
setLocalPeerDescriptor(peerDescriptor) {
|
|
166
171
|
this.localPeerDescriptor = peerDescriptor;
|
|
167
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnector.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAK+C;AAE/C,uFAAmF;AACnF,iEAA6D;AAC7D,yEAAqE;AACrE,iFAAwF;AACxF,wEAAoE;AACpE,0CAAuC;AACvC,0DAA2C;AAI3C,uEAAmE;AACnE,mDAAoG;AACpG,qDAAmD;AAEnD,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,CAAC;QAClB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC,CAAA;AAPY,QAAA,+BAA+B,mCAO3C;AAsBD,MAAa,eAAe;IAEhB,MAAM,CAAU,2BAA2B,GAAG,yBAAyB,CAAA;IAC9D,eAAe,CAA0B;IACzC,sBAAsB,GAA6C,IAAI,GAAG,EAAE,CAAA;IACrF,mBAAmB,CAAiB;IACpC,OAAO,GAAG,KAAK,CAAA;IACf,MAAM,CAAuB;IAErC,YACI,MAA6B,EAC7B,eAA2D;QAE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,sBAAsB,CAAC,cAA8B;QACjD,IAAI,CAAC,mBAAmB,GAAG,cAAc,CAAA;IAC7C,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QAEnB,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,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;;AAvKL,0CAwKC"}
|
|
@@ -5,8 +5,10 @@ import { IWebrtcConnectorRpc } from '../../proto/packages/dht/protos/DhtRpc.serv
|
|
|
5
5
|
import { ListeningRpcCommunicator } from '../../transport/ListeningRpcCommunicator';
|
|
6
6
|
import { ManagedConnection } from '../ManagedConnection';
|
|
7
7
|
import { ManagedWebrtcConnection } from '../ManagedWebrtcConnection';
|
|
8
|
+
import { NodeWebrtcConnection } from './NodeWebrtcConnection';
|
|
8
9
|
import { DhtAddress } from '../../identifiers';
|
|
9
10
|
interface WebrtcConnectorRpcLocalConfig {
|
|
11
|
+
createConnection: (targetPeerDescriptor: PeerDescriptor) => NodeWebrtcConnection;
|
|
10
12
|
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection;
|
|
11
13
|
onNewConnection: (connection: ManagedConnection) => boolean;
|
|
12
14
|
ongoingConnectAttempts: Map<DhtAddress, ManagedWebrtcConnection>;
|
|
@@ -6,7 +6,6 @@ const AddressTools_1 = require("../../helpers/AddressTools");
|
|
|
6
6
|
const DhtRpc_1 = require("../../proto/packages/dht/protos/DhtRpc");
|
|
7
7
|
const DhtRpc_client_1 = require("../../proto/packages/dht/protos/DhtRpc.client");
|
|
8
8
|
const ManagedWebrtcConnection_1 = require("../ManagedWebrtcConnection");
|
|
9
|
-
const NodeWebrtcConnection_1 = require("./NodeWebrtcConnection");
|
|
10
9
|
const WebrtcConnectorRpcRemote_1 = require("./WebrtcConnectorRpcRemote");
|
|
11
10
|
const identifiers_1 = require("../../identifiers");
|
|
12
11
|
const version_1 = require("../../helpers/version");
|
|
@@ -32,7 +31,7 @@ class WebrtcConnectorRpcLocal {
|
|
|
32
31
|
let managedConnection = this.config.ongoingConnectAttempts.get(nodeId);
|
|
33
32
|
let connection = managedConnection?.getWebrtcConnection();
|
|
34
33
|
if (!managedConnection) {
|
|
35
|
-
connection =
|
|
34
|
+
connection = this.config.createConnection(remotePeer);
|
|
36
35
|
managedConnection = new ManagedWebrtcConnection_1.ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection);
|
|
37
36
|
managedConnection.setRemotePeerDescriptor(remotePeer);
|
|
38
37
|
this.config.ongoingConnectAttempts.set(nodeId, managedConnection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,6DAAsF;AAEtF,mEAM+C;AAC/C,iFAAwF;AAKxF,wEAAoE;
|
|
1
|
+
{"version":3,"file":"WebrtcConnectorRpcLocal.js","sourceRoot":"","sources":["../../../../src/connection/webrtc/WebrtcConnectorRpcLocal.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,6DAAsF;AAEtF,mEAM+C;AAC/C,iFAAwF;AAKxF,wEAAoE;AAEpE,yEAAqE;AACrE,mDAA2E;AAC3E,mDAA+D;AAG/D,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAajC,MAAa,uBAAuB;IAEf,MAAM,CAA+B;IAEtD,YAAY,MAAqC;QAC7C,IAAI,CAAC,MAA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,SAAS,CAAC,EAAE,CAAC;YACvD,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,EAAE,CAAA;IACb,CAAC;IAEO,qBAAqB,CAAC,SAAiB;QAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,IAAA,yCAA0B,EAAC,SAAS,CAAC,CAAA;YACrD,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,IAAI,IAAA,4BAAa,EAAC,OAAO,CAAC,EAAE,CAAC;gBACpD,OAAO,KAAK,CAAA;YAChB,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AArGD,0DAqGC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/dht",
|
|
3
|
-
"version": "100.0.0-rc.
|
|
3
|
+
"version": "100.0.0-rc.1",
|
|
4
4
|
"description": "Streamr Network DHT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"@js-sdsl/ordered-map": "^4.4.2",
|
|
32
32
|
"@protobuf-ts/runtime": "^2.8.2",
|
|
33
33
|
"@protobuf-ts/runtime-rpc": "^2.8.2",
|
|
34
|
-
"@streamr/autocertifier-client": "100.0.0-rc.
|
|
35
|
-
"@streamr/cdn-location": "100.0.0-rc.
|
|
36
|
-
"@streamr/proto-rpc": "100.0.0-rc.
|
|
37
|
-
"@streamr/utils": "100.0.0-rc.
|
|
34
|
+
"@streamr/autocertifier-client": "100.0.0-rc.1",
|
|
35
|
+
"@streamr/cdn-location": "100.0.0-rc.1",
|
|
36
|
+
"@streamr/proto-rpc": "100.0.0-rc.1",
|
|
37
|
+
"@streamr/utils": "100.0.0-rc.1",
|
|
38
38
|
"eventemitter3": "^5.0.0",
|
|
39
39
|
"heap": "^0.2.6",
|
|
40
40
|
"ipaddr.js": "^2.0.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@streamr/browser-test-runner": "^0.0.1",
|
|
52
|
-
"@streamr/test-utils": "100.0.0-rc.
|
|
52
|
+
"@streamr/test-utils": "100.0.0-rc.1",
|
|
53
53
|
"@types/express": "^4.17.21",
|
|
54
54
|
"@types/heap": "^0.2.34",
|
|
55
55
|
"@types/k-bucket": "^5.0.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@types/uuid": "^9.0.8",
|
|
58
58
|
"@types/websocket": "^1.0.10",
|
|
59
59
|
"@types/ws": "^8.5.10",
|
|
60
|
-
"express": "^4.
|
|
60
|
+
"express": "^4.18.3",
|
|
61
61
|
"jest-leak-detector": "^27.3.1",
|
|
62
62
|
"patch-package": "^8.0.0",
|
|
63
63
|
"ts-essentials": "^9.4.1",
|
|
@@ -26,7 +26,7 @@ export interface Params {
|
|
|
26
26
|
bufferThresholdLow?: number
|
|
27
27
|
connectingTimeout?: number
|
|
28
28
|
maxMessageSize?: number
|
|
29
|
-
iceServers?: IceServer[]
|
|
29
|
+
iceServers?: IceServer[] // TODO make this parameter required (empty array is a good fallback which can be set by the caller if needed)
|
|
30
30
|
portRange?: PortRange
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -75,6 +75,7 @@ export class WebrtcConnector {
|
|
|
75
75
|
onNewConnection: (connection: ManagedConnection) => boolean
|
|
76
76
|
) {
|
|
77
77
|
const localRpc = new WebrtcConnectorRpcLocal({
|
|
78
|
+
createConnection: (targetPeerDescriptor: PeerDescriptor) => this.createConnection(targetPeerDescriptor),
|
|
78
79
|
connect: (targetPeerDescriptor: PeerDescriptor) => this.connect(targetPeerDescriptor),
|
|
79
80
|
onNewConnection,
|
|
80
81
|
ongoingConnectAttempts: this.ongoingConnectAttempts,
|
|
@@ -133,14 +134,7 @@ export class WebrtcConnector {
|
|
|
133
134
|
return existingConnection
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
const connection =
|
|
137
|
-
remotePeerDescriptor: targetPeerDescriptor,
|
|
138
|
-
iceServers: this.config.iceServers,
|
|
139
|
-
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
140
|
-
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
141
|
-
connectingTimeout: this.config.connectionTimeout,
|
|
142
|
-
portRange: this.config.portRange
|
|
143
|
-
})
|
|
137
|
+
const connection = this.createConnection(targetPeerDescriptor)
|
|
144
138
|
|
|
145
139
|
const localNodeId = getNodeIdFromPeerDescriptor(this.localPeerDescriptor!)
|
|
146
140
|
const targetNodeId = getNodeIdFromPeerDescriptor(targetPeerDescriptor)
|
|
@@ -199,6 +193,18 @@ export class WebrtcConnector {
|
|
|
199
193
|
return managedConnection
|
|
200
194
|
}
|
|
201
195
|
|
|
196
|
+
private createConnection(targetPeerDescriptor: PeerDescriptor): NodeWebrtcConnection {
|
|
197
|
+
return new NodeWebrtcConnection({
|
|
198
|
+
remotePeerDescriptor: targetPeerDescriptor,
|
|
199
|
+
iceServers: this.config.iceServers,
|
|
200
|
+
bufferThresholdLow: this.config.bufferThresholdLow,
|
|
201
|
+
bufferThresholdHigh: this.config.bufferThresholdHigh,
|
|
202
|
+
connectingTimeout: this.config.connectionTimeout,
|
|
203
|
+
portRange: this.config.portRange
|
|
204
|
+
// TODO should we pass maxMessageSize?
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
202
208
|
setLocalPeerDescriptor(peerDescriptor: PeerDescriptor): void {
|
|
203
209
|
this.localPeerDescriptor = peerDescriptor
|
|
204
210
|
}
|
|
@@ -24,6 +24,7 @@ import { ConnectionID } from '../IConnection'
|
|
|
24
24
|
const logger = new Logger(module)
|
|
25
25
|
|
|
26
26
|
interface WebrtcConnectorRpcLocalConfig {
|
|
27
|
+
createConnection: (targetPeerDescriptor: PeerDescriptor) => NodeWebrtcConnection
|
|
27
28
|
connect: (targetPeerDescriptor: PeerDescriptor) => ManagedConnection
|
|
28
29
|
onNewConnection: (connection: ManagedConnection) => boolean
|
|
29
30
|
// TODO pass accessor methods instead of passing a mutable entity
|
|
@@ -59,7 +60,7 @@ export class WebrtcConnectorRpcLocal implements IWebrtcConnectorRpc {
|
|
|
59
60
|
let connection = managedConnection?.getWebrtcConnection()
|
|
60
61
|
|
|
61
62
|
if (!managedConnection) {
|
|
62
|
-
connection =
|
|
63
|
+
connection = this.config.createConnection(remotePeer)
|
|
63
64
|
managedConnection = new ManagedWebrtcConnection(this.config.getLocalPeerDescriptor(), undefined, connection)
|
|
64
65
|
managedConnection.setRemotePeerDescriptor(remotePeer)
|
|
65
66
|
this.config.ongoingConnectAttempts.set(nodeId, managedConnection)
|