diff --git a/src/lib/mtproto/apiManager.ts b/src/lib/mtproto/apiManager.ts index d69d9130..66fd949a 100644 --- a/src/lib/mtproto/apiManager.ts +++ b/src/lib/mtproto/apiManager.ts @@ -157,15 +157,15 @@ export class ApiManager { // mtpLogOut public async logOut() { - const storageKeys: Array = []; + const storageKeys: Array<`dc${TrueDcId}_auth_key`> = []; const prefix = 'dc'; for(let dcId = 1; dcId <= 5; dcId++) { - storageKeys.push(prefix + dcId + '_auth_key'); + storageKeys.push(prefix + dcId + '_auth_key' as any); } // WebPushApiManager.forceUnsubscribe(); // WARNING // moved to worker's master - const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key as any))); + const storageResult = await Promise.all(storageKeys.map(key => sessionStorage.get(key))); const logoutPromises: Promise[] = []; for(let i = 0; i < storageResult.length; i++) { diff --git a/src/lib/mtproto/dcConfigurator.ts b/src/lib/mtproto/dcConfigurator.ts index 5732e47e..c072e45f 100644 --- a/src/lib/mtproto/dcConfigurator.ts +++ b/src/lib/mtproto/dcConfigurator.ts @@ -22,6 +22,7 @@ import TcpObfuscated from './transports/tcpObfuscated'; import { isSafari } from '../../helpers/userAgent'; import { isWebWorker } from '../../helpers/context'; import SocketProxied from './transports/socketProxied'; +import App from '../../config/app'; /// #endif export type TransportType = 'websocket' | 'https' | 'http'; @@ -56,10 +57,9 @@ export class DcConfigurator { public chosenServers: Servers = {} as any; /// #if !MTPROTO_HTTP - private transportSocket = (dcId: number, connectionType: ConnectionType) => { - const subdomain = this.sslSubdomains[dcId - 1]; + private transportSocket = (dcId: number, connectionType: ConnectionType, suffix: string) => { const path = 'apiws' + TEST_SUFFIX; - const chosenServer = 'wss://' + subdomain + '.web.telegram.org/' + path; + const chosenServer = `wss://${App.suffix.toLowerCase()}ws${dcId}${suffix}.web.telegram.org/${path}`; const logSuffix = connectionType === 'upload' ? '-U' : connectionType === 'download' ? '-D' : ''; const retryTimeout = connectionType === 'client' ? 10000 : 10000; @@ -71,7 +71,7 @@ export class DcConfigurator { /// #endif /// #if MTPROTO_HTTP_UPLOAD || MTPROTO_HTTP - private transportHTTP = (dcId: number, connectionType: ConnectionType) => { + private transportHTTP = (dcId: number, connectionType: ConnectionType, suffix: string) => { if(Modes.ssl || !Modes.http) { const subdomain = this.sslSubdomains[dcId - 1] + (connectionType !== 'client' ? '-1' : ''); const path = Modes.test ? 'apiw_test1' : 'apiw1'; @@ -112,12 +112,14 @@ export class DcConfigurator { if(!transports.length || !reuse/* || (upload && transports.length < 1) */) { let transport: MTTransport; + const suffix = connectionType === 'client' ? '' : '-1'; + /// #if MTPROTO_HTTP_UPLOAD - transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType); + transport = (transportType === 'websocket' ? this.transportSocket : this.transportHTTP)(dcId, connectionType, suffix); /// #elif !MTPROTO_HTTP - transport = this.transportSocket(dcId, connectionType); + transport = this.transportSocket(dcId, connectionType, suffix); /// #else - transport = this.transportHTTP(dcId, connectionType); + transport = this.transportHTTP(dcId, connectionType, suffix); /// #endif if(!transport) {