fix(core): better handling for additional connections
This commit is contained in:
parent
77022e29c9
commit
5849ce0e1b
1 changed files with 16 additions and 2 deletions
|
@ -450,13 +450,14 @@ export class BaseTelegramClient {
|
||||||
if (this._useIpv6) {
|
if (this._useIpv6) {
|
||||||
// first try to find ipv6 dc
|
// first try to find ipv6 dc
|
||||||
const found = this._config.dcOptions.find(
|
const found = this._config.dcOptions.find(
|
||||||
(it) => it.id === id && it.cdn === cdn && it.ipv6
|
(it) =>
|
||||||
|
it.id === id && it.cdn === cdn && it.ipv6 && !it.tcpoOnly
|
||||||
)
|
)
|
||||||
if (found) return found
|
if (found) return found
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = this._config.dcOptions.find(
|
const found = this._config.dcOptions.find(
|
||||||
(it) => it.id === id && it.cdn === cdn
|
(it) => it.id === id && it.cdn === cdn && !it.tcpoOnly
|
||||||
)
|
)
|
||||||
if (found) return found
|
if (found) return found
|
||||||
|
|
||||||
|
@ -671,6 +672,19 @@ export class BaseTelegramClient {
|
||||||
// connection.authKey was already generated at this point
|
// connection.authKey was already generated at this point
|
||||||
this.storage.setAuthKeyFor(dc.id, connection.authKey)
|
this.storage.setAuthKeyFor(dc.id, connection.authKey)
|
||||||
await this._saveStorage()
|
await this._saveStorage()
|
||||||
|
} else {
|
||||||
|
// in case the auth key is invalid
|
||||||
|
const dcId = dc.id
|
||||||
|
connection.on('key-change', async (key) => {
|
||||||
|
// we don't need to export, it will be done by `.call()`
|
||||||
|
// in case this error is returned
|
||||||
|
//
|
||||||
|
// even worse, exporting here will lead to a race condition,
|
||||||
|
// and may result in redundant re-exports.
|
||||||
|
|
||||||
|
this.storage.setAuthKeyFor(dcId, key)
|
||||||
|
await this._saveStorage()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this._additionalConnections.push(connection)
|
this._additionalConnections.push(connection)
|
||||||
|
|
Loading…
Reference in a new issue