@mtcute/core 0.25.0 → 0.25.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.
|
@@ -97,12 +97,14 @@ class UpdatesManager {
|
|
|
97
97
|
this._onCatchingUp = handler;
|
|
98
98
|
}
|
|
99
99
|
destroy() {
|
|
100
|
+
this.log.debug("destroyed, stopping updates loop");
|
|
100
101
|
this.stopLoop();
|
|
101
102
|
}
|
|
102
103
|
notifyLoggedIn() {
|
|
103
104
|
this.startLoop().catch((err) => this.client.onError.emit(utils.unknownToError(err)));
|
|
104
105
|
}
|
|
105
106
|
notifyLoggedOut() {
|
|
107
|
+
this.log.debug("notifyLoggedOut, stopping updates loop");
|
|
106
108
|
this.stopLoop();
|
|
107
109
|
this.cpts.clear();
|
|
108
110
|
this.cptsMod.clear();
|
|
@@ -316,6 +318,7 @@ class UpdatesManager {
|
|
|
316
318
|
} catch (e) {
|
|
317
319
|
if (tl.tl.RpcError.is(e, "AUTH_KEY_UNREGISTERED")) {
|
|
318
320
|
lock.release();
|
|
321
|
+
this.log.debug("received AUTH_KEY_UNREGISTERED, stopping updates loop");
|
|
319
322
|
this.stopLoop();
|
|
320
323
|
return;
|
|
321
324
|
}
|
|
@@ -812,6 +815,7 @@ class UpdatesManager {
|
|
|
812
815
|
0,
|
|
813
816
|
this._fetchDifference(requestedDiff).catch((err) => {
|
|
814
817
|
if (tl.tl.RpcError.is(err, "AUTH_KEY_UNREGISTERED")) {
|
|
818
|
+
this.log.debug("received AUTH_KEY_UNREGISTERED, stopping updates loop");
|
|
815
819
|
this.stopLoop();
|
|
816
820
|
return;
|
|
817
821
|
}
|
|
@@ -90,12 +90,14 @@ class UpdatesManager {
|
|
|
90
90
|
this._onCatchingUp = handler;
|
|
91
91
|
}
|
|
92
92
|
destroy() {
|
|
93
|
+
this.log.debug("destroyed, stopping updates loop");
|
|
93
94
|
this.stopLoop();
|
|
94
95
|
}
|
|
95
96
|
notifyLoggedIn() {
|
|
96
97
|
this.startLoop().catch((err) => this.client.onError.emit(unknownToError(err)));
|
|
97
98
|
}
|
|
98
99
|
notifyLoggedOut() {
|
|
100
|
+
this.log.debug("notifyLoggedOut, stopping updates loop");
|
|
99
101
|
this.stopLoop();
|
|
100
102
|
this.cpts.clear();
|
|
101
103
|
this.cptsMod.clear();
|
|
@@ -309,6 +311,7 @@ class UpdatesManager {
|
|
|
309
311
|
} catch (e) {
|
|
310
312
|
if (tl.RpcError.is(e, "AUTH_KEY_UNREGISTERED")) {
|
|
311
313
|
lock.release();
|
|
314
|
+
this.log.debug("received AUTH_KEY_UNREGISTERED, stopping updates loop");
|
|
312
315
|
this.stopLoop();
|
|
313
316
|
return;
|
|
314
317
|
}
|
|
@@ -805,6 +808,7 @@ class UpdatesManager {
|
|
|
805
808
|
0,
|
|
806
809
|
this._fetchDifference(requestedDiff).catch((err) => {
|
|
807
810
|
if (tl.RpcError.is(err, "AUTH_KEY_UNREGISTERED")) {
|
|
811
|
+
this.log.debug("received AUTH_KEY_UNREGISTERED, stopping updates loop");
|
|
808
812
|
this.stopLoop();
|
|
809
813
|
return;
|
|
810
814
|
}
|
|
@@ -32,25 +32,27 @@ class DcConnectionManager {
|
|
|
32
32
|
this.isPrimary = isPrimary;
|
|
33
33
|
this._log = this.manager._log.create("dc-manager");
|
|
34
34
|
this._log.prefix = `[DC ${dcId}] `;
|
|
35
|
+
const managerParams = this.manager.params;
|
|
35
36
|
const baseConnectionParams = () => ({
|
|
36
|
-
crypto:
|
|
37
|
+
crypto: managerParams.crypto,
|
|
37
38
|
initConnection: this.manager._initConnectionParams,
|
|
38
39
|
transport: this.manager._transport,
|
|
39
40
|
dc: this._dcs.media,
|
|
40
|
-
testMode:
|
|
41
|
+
testMode: managerParams.testMode,
|
|
41
42
|
reconnectionStrategy: this.manager._reconnectionStrategy,
|
|
42
|
-
layer:
|
|
43
|
-
disableUpdates:
|
|
44
|
-
readerMap:
|
|
45
|
-
writerMap:
|
|
46
|
-
usePfs:
|
|
43
|
+
layer: managerParams.layer,
|
|
44
|
+
disableUpdates: managerParams.disableUpdates,
|
|
45
|
+
readerMap: managerParams.readerMap,
|
|
46
|
+
writerMap: managerParams.writerMap,
|
|
47
|
+
usePfs: managerParams.usePfs,
|
|
47
48
|
isMainConnection: false,
|
|
48
49
|
isMainDcConnection: this.isPrimary,
|
|
49
|
-
inactivityTimeout:
|
|
50
|
-
enableErrorReporting:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
inactivityTimeout: managerParams.inactivityTimeout ?? 6e4,
|
|
51
|
+
enableErrorReporting: managerParams.enableErrorReporting,
|
|
52
|
+
// NB: we need a separate salts manager for each pfs connection, because server salts are auth_key-bound
|
|
53
|
+
salts: managerParams.usePfs ? new serverSalt.ServerSaltManager() : this._salts,
|
|
54
|
+
platform: managerParams.platform,
|
|
55
|
+
pingInterval: managerParams.pingInterval ?? 6e4
|
|
54
56
|
});
|
|
55
57
|
const mainParams = baseConnectionParams();
|
|
56
58
|
mainParams.isMainConnection = true;
|
|
@@ -70,19 +72,19 @@ class DcConnectionManager {
|
|
|
70
72
|
this.main = new multiSessionConnection.MultiSessionConnection(mainParams, mainCount, this._log, "MAIN");
|
|
71
73
|
this.upload = new multiSessionConnection.MultiSessionConnection(
|
|
72
74
|
baseConnectionParams(),
|
|
73
|
-
this.manager._connectionCount("upload", this.dcId,
|
|
75
|
+
this.manager._connectionCount("upload", this.dcId, managerParams.isPremium),
|
|
74
76
|
this._log,
|
|
75
77
|
"UPLOAD"
|
|
76
78
|
);
|
|
77
79
|
this.download = new multiSessionConnection.MultiSessionConnection(
|
|
78
80
|
baseConnectionParams(),
|
|
79
|
-
this.manager._connectionCount("download", this.dcId,
|
|
81
|
+
this.manager._connectionCount("download", this.dcId, managerParams.isPremium),
|
|
80
82
|
this._log,
|
|
81
83
|
"DOWNLOAD"
|
|
82
84
|
);
|
|
83
85
|
this.downloadSmall = new multiSessionConnection.MultiSessionConnection(
|
|
84
86
|
baseConnectionParams(),
|
|
85
|
-
this.manager._connectionCount("downloadSmall", this.dcId,
|
|
87
|
+
this.manager._connectionCount("downloadSmall", this.dcId, managerParams.isPremium),
|
|
86
88
|
this._log,
|
|
87
89
|
"DOWNLOAD_SMALL"
|
|
88
90
|
);
|
|
@@ -135,6 +137,9 @@ class DcConnectionManager {
|
|
|
135
137
|
});
|
|
136
138
|
});
|
|
137
139
|
connection.onFutureSalts.add((salts) => {
|
|
140
|
+
if (this.manager.params.usePfs && kind !== "main") {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
138
143
|
Promise.resolve(this.manager._storage.salts.store(this.dcId, salts)).catch(
|
|
139
144
|
(e) => this.manager.params.emitError(e)
|
|
140
145
|
);
|
|
@@ -220,7 +225,7 @@ class NetworkManager {
|
|
|
220
225
|
_: "initConnection",
|
|
221
226
|
deviceModel,
|
|
222
227
|
systemVersion: "1.0",
|
|
223
|
-
appVersion: "0.25.
|
|
228
|
+
appVersion: "0.25.1",
|
|
224
229
|
systemLangCode: "en",
|
|
225
230
|
langPack: "",
|
|
226
231
|
// "langPacks are for official apps only"
|
|
@@ -296,9 +301,7 @@ class NetworkManager {
|
|
|
296
301
|
async _getOtherDc(dcId) {
|
|
297
302
|
if (!this._dcConnections.has(dcId)) {
|
|
298
303
|
if (this._dcCreationPromise.has(dcId)) {
|
|
299
|
-
this._log.debug("waiting for dc %d to be created", dcId);
|
|
300
304
|
await this._dcCreationPromise.get(dcId);
|
|
301
|
-
this._log.debug("dc %d was created", dcId);
|
|
302
305
|
return utils.asNonNull(this._dcConnections.get(dcId));
|
|
303
306
|
}
|
|
304
307
|
const promise = new utils.Deferred();
|
|
@@ -313,7 +316,9 @@ class NetworkManager {
|
|
|
313
316
|
this._dcConnections.set(dcId, dc);
|
|
314
317
|
promise.resolve();
|
|
315
318
|
this._dcCreationPromise.delete(dcId);
|
|
319
|
+
this._log.debug("dc %d was created", dcId);
|
|
316
320
|
} catch (e) {
|
|
321
|
+
this._log.debug("dc %d was not created: %e", dcId, e);
|
|
317
322
|
promise.reject(e);
|
|
318
323
|
this._dcCreationPromise.delete(dcId);
|
|
319
324
|
return this._getOtherDc(dcId);
|
|
@@ -25,25 +25,27 @@ class DcConnectionManager {
|
|
|
25
25
|
this.isPrimary = isPrimary;
|
|
26
26
|
this._log = this.manager._log.create("dc-manager");
|
|
27
27
|
this._log.prefix = `[DC ${dcId}] `;
|
|
28
|
+
const managerParams = this.manager.params;
|
|
28
29
|
const baseConnectionParams = () => ({
|
|
29
|
-
crypto:
|
|
30
|
+
crypto: managerParams.crypto,
|
|
30
31
|
initConnection: this.manager._initConnectionParams,
|
|
31
32
|
transport: this.manager._transport,
|
|
32
33
|
dc: this._dcs.media,
|
|
33
|
-
testMode:
|
|
34
|
+
testMode: managerParams.testMode,
|
|
34
35
|
reconnectionStrategy: this.manager._reconnectionStrategy,
|
|
35
|
-
layer:
|
|
36
|
-
disableUpdates:
|
|
37
|
-
readerMap:
|
|
38
|
-
writerMap:
|
|
39
|
-
usePfs:
|
|
36
|
+
layer: managerParams.layer,
|
|
37
|
+
disableUpdates: managerParams.disableUpdates,
|
|
38
|
+
readerMap: managerParams.readerMap,
|
|
39
|
+
writerMap: managerParams.writerMap,
|
|
40
|
+
usePfs: managerParams.usePfs,
|
|
40
41
|
isMainConnection: false,
|
|
41
42
|
isMainDcConnection: this.isPrimary,
|
|
42
|
-
inactivityTimeout:
|
|
43
|
-
enableErrorReporting:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
inactivityTimeout: managerParams.inactivityTimeout ?? 6e4,
|
|
44
|
+
enableErrorReporting: managerParams.enableErrorReporting,
|
|
45
|
+
// NB: we need a separate salts manager for each pfs connection, because server salts are auth_key-bound
|
|
46
|
+
salts: managerParams.usePfs ? new ServerSaltManager() : this._salts,
|
|
47
|
+
platform: managerParams.platform,
|
|
48
|
+
pingInterval: managerParams.pingInterval ?? 6e4
|
|
47
49
|
});
|
|
48
50
|
const mainParams = baseConnectionParams();
|
|
49
51
|
mainParams.isMainConnection = true;
|
|
@@ -63,19 +65,19 @@ class DcConnectionManager {
|
|
|
63
65
|
this.main = new MultiSessionConnection(mainParams, mainCount, this._log, "MAIN");
|
|
64
66
|
this.upload = new MultiSessionConnection(
|
|
65
67
|
baseConnectionParams(),
|
|
66
|
-
this.manager._connectionCount("upload", this.dcId,
|
|
68
|
+
this.manager._connectionCount("upload", this.dcId, managerParams.isPremium),
|
|
67
69
|
this._log,
|
|
68
70
|
"UPLOAD"
|
|
69
71
|
);
|
|
70
72
|
this.download = new MultiSessionConnection(
|
|
71
73
|
baseConnectionParams(),
|
|
72
|
-
this.manager._connectionCount("download", this.dcId,
|
|
74
|
+
this.manager._connectionCount("download", this.dcId, managerParams.isPremium),
|
|
73
75
|
this._log,
|
|
74
76
|
"DOWNLOAD"
|
|
75
77
|
);
|
|
76
78
|
this.downloadSmall = new MultiSessionConnection(
|
|
77
79
|
baseConnectionParams(),
|
|
78
|
-
this.manager._connectionCount("downloadSmall", this.dcId,
|
|
80
|
+
this.manager._connectionCount("downloadSmall", this.dcId, managerParams.isPremium),
|
|
79
81
|
this._log,
|
|
80
82
|
"DOWNLOAD_SMALL"
|
|
81
83
|
);
|
|
@@ -128,6 +130,9 @@ class DcConnectionManager {
|
|
|
128
130
|
});
|
|
129
131
|
});
|
|
130
132
|
connection.onFutureSalts.add((salts) => {
|
|
133
|
+
if (this.manager.params.usePfs && kind !== "main") {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
131
136
|
Promise.resolve(this.manager._storage.salts.store(this.dcId, salts)).catch(
|
|
132
137
|
(e) => this.manager.params.emitError(e)
|
|
133
138
|
);
|
|
@@ -213,7 +218,7 @@ class NetworkManager {
|
|
|
213
218
|
_: "initConnection",
|
|
214
219
|
deviceModel,
|
|
215
220
|
systemVersion: "1.0",
|
|
216
|
-
appVersion: "0.25.
|
|
221
|
+
appVersion: "0.25.1",
|
|
217
222
|
systemLangCode: "en",
|
|
218
223
|
langPack: "",
|
|
219
224
|
// "langPacks are for official apps only"
|
|
@@ -289,9 +294,7 @@ class NetworkManager {
|
|
|
289
294
|
async _getOtherDc(dcId) {
|
|
290
295
|
if (!this._dcConnections.has(dcId)) {
|
|
291
296
|
if (this._dcCreationPromise.has(dcId)) {
|
|
292
|
-
this._log.debug("waiting for dc %d to be created", dcId);
|
|
293
297
|
await this._dcCreationPromise.get(dcId);
|
|
294
|
-
this._log.debug("dc %d was created", dcId);
|
|
295
298
|
return asNonNull(this._dcConnections.get(dcId));
|
|
296
299
|
}
|
|
297
300
|
const promise = new Deferred();
|
|
@@ -306,7 +309,9 @@ class NetworkManager {
|
|
|
306
309
|
this._dcConnections.set(dcId, dc);
|
|
307
310
|
promise.resolve();
|
|
308
311
|
this._dcCreationPromise.delete(dcId);
|
|
312
|
+
this._log.debug("dc %d was created", dcId);
|
|
309
313
|
} catch (e) {
|
|
314
|
+
this._log.debug("dc %d was not created: %e", dcId, e);
|
|
310
315
|
promise.reject(e);
|
|
311
316
|
this._dcCreationPromise.delete(dcId);
|
|
312
317
|
return this._getOtherDc(dcId);
|