TelepathyIM / telepathy-morse

Telegram connection manager for the Telepathy framework
GNU General Public License v2.0
61 stars 10 forks source link

Client does not request code #63

Closed luizluca closed 5 years ago

luizluca commented 5 years ago

I used an old morse version but today I installed git version b2de385. I'm behind an HTTP proxy (env vars are correct). It seems to be using my proxy settings nicely (no morse proxy parameters set). My GUI client is empathy but I mostly tested with mc-tool.

It looks like it goes from Connecting to Authenticated without actually being authenticated.

telepathy-morse[15534]: CTelegramConnection* CTelegramDispatcher::createConnection(const TLDcOption&) 1 "149.154.175.50" 443
telepathy-morse[15534]: void CTelegramDispatcher::setConnectionState(TelegramNamespace::ConnectionState) TelegramNamespace::ConnectionState(ConnectionStateConnecting)
telepathy-morse[15534]: void MorseConnection::whenConnectionStateChanged(TelegramNamespace::ConnectionState) TelegramNamespace::ConnectionState(ConnectionStateConnecting)
telepathy-morse[15534]: void CTelegramDispatcher::onConnectionStatusChanged(int, int, quint32) status CTelegramConnection::ConnectionStatus(ConnectionStatusConnecting) reason CTelegramConnection::ConnectionStatusReason(ConnectionStatusReasonLocal) dc 1
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnection::status =  1   MorseConnection(0x560618106140)
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnection::status =  1   MorseConnection(0x560618106140)
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnection::status =  1   MorseConnection(0x560618106140)
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnection::status =  1   MorseConnection(0x560618106140)
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnectionRequestsInterface::requestableChannelClasses
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnectionAliasingInterface::Adaptee::getAliasFlags
telepathy-morse[15534]: tp-qt 0.9.7 DEBUG: BaseConnectionAliasingInterface::Adaptee::getAliasFlags
telepathy-morse[15534]: void CTelegramConnection::startAuthTimer()
telepathy-morse[15534]: void CTelegramDispatcher::onConnectionAuthChanged(int, quint32) CTelegramConnection(0x56061810b780) auth CTelegramConnection::AuthState(AuthStateSignedIn) dc 1
telepathy-morse[15534]: void CTelegramDispatcher::onConnectionAuthChanged(int, quint32) Delayed packages: () 0
telepathy-morse[15534]: CTelegramDispatcher::continueInitialization( CTelegramDispatcher::InitializationStep(StepSignIn) ) on top of QFlags<CTelegramDispatcher::InitializationStep>(StepFirst)
telepathy-morse[15534]: CTelegramDispatcher::continueInitialization(): Request DC Configuration
telepathy-morse[15534]: CTelegramConnection(0x56061810b780) sendEncryptedPackage() "HelpGetConfig" message id: 6631640902674358740 dc:  1
telepathy-morse[15534]: void CTelegramConnection::stopAuthTimer()
telepathy-morse[15534]: void CTelegramDispatcher::onConnectionStatusChanged(int, int, quint32) status CTelegramConnection::ConnectionStatus(ConnectionStatusConnected) reason CTelegramConnection::ConnectionStatusReason(ConnectionStatusReasonRemote) dc 1
telepathy-morse[15534]: Read 88 bytes
telepathy-morse[15534]: void CTelegramConnection::onTransportPackageReceived(const QByteArray&) Received different server salt: 13993787721284212897 (remote) vs 3877751682911951213 (local)
telepathy-morse[15534]: "Bad message 6631640902674358740/1: Code 48 (Incorrect server salt)."
telepathy-morse[15534]: Local serverSalt fixed to 13993787721284212897
telepathy-morse[15534]: CTelegramConnection(0x56061810b780) sendEncryptedPackage() "HelpGetConfig" message id: 6631640903198344712 dc:  1
telepathy-morse[15534]: Read 152 bytes
telepathy-morse[15534]: void CTelegramConnection::processMessageAck(CTelegramStream&) Package 6631640903198344712 acked
telepathy-morse[15534]: Read 344 bytes
telepathy-morse[15534]: Core: Got DC Configuration.
telepathy-morse[15534]: 1 "149.154.175.50" 443
telepathy-morse[15534]: 1 "2001:0b28:f23d:f001:0000:0000:0000:000a" 443
telepathy-morse[15534]: 2 "149.154.167.51" 443
telepathy-morse[15534]: 2 "2001:067c:04e8:f002:0000:0000:0000:000a" 443
telepathy-morse[15534]: 3 "149.154.175.100" 443
telepathy-morse[15534]: 3 "2001:0b28:f23d:f003:0000:0000:0000:000a" 443
telepathy-morse[15534]: 4 "149.154.167.92" 443
telepathy-morse[15534]: 4 "2001:067c:04e8:f004:0000:0000:0000:000a" 443
telepathy-morse[15534]: 4 "149.154.165.120" 443
telepathy-morse[15534]: 4 "2001:067c:04e8:f004:0000:0000:0000:000b" 443
telepathy-morse[15534]: 5 "2001:0b28:f23f:f005:0000:0000:0000:000a" 443
telepathy-morse[15534]: 5 "91.108.56.171" 443
telepathy-morse[15534]: CTelegramDispatcher::continueInitialization( CTelegramDispatcher::InitializationStep(StepDcConfiguration) ) on top of QFlags<CTelegramDispatcher::InitializationStep>(StepSignIn|StepHasKey)
telepathy-morse[15534]: void CTelegramDispatcher::setConnectionState(TelegramNamespace::ConnectionState) TelegramNamespace::ConnectionState(ConnectionStateAuthenticated)
telepathy-morse[15534]: void MorseConnection::whenConnectionStateChanged(TelegramNamespace::ConnectionState) TelegramNamespace::ConnectionState(ConnectionStateAuthenticated)
telepathy-morse[15534]: void MorseConnection::whenAuthenticated()
telepathy-morse[15534]: CTelegramConnection(0x56061810b780) sendEncryptedPackage() "UsersGetUsers" message id: 6631640904538374712 dc:  1
telepathy-morse[15534]: void CTelegramDispatcher::ensureMainConnectToWantedDc() Nothing to do. Wanted DC is already connected.
telepathy-morse[15534]: Read 104 bytes
telepathy-morse[15534]: bool CTelegramConnection::processRpcError(CTelegramStream&, quint64, TLValue) "RPC Error 401: AUTH_KEY_UNREGISTERED for message 6631640904538374712 UsersGetUsers (dc 1|149.154.175.50:443)"

I got no authentication code on phone or client (I'm connected in a web client).

I don't know if it is trying to reuse an old expired activation key (from previous tests) or the state machine got confused and jumped directly into ConnectionStateAuthenticated without actually being authenticated.

luizluca commented 5 years ago

It might be related to #9 as it could be some leftovers from old telepathy account (although here I'm using the same phone number)

Kaffeine commented 5 years ago

The last line says that "AUTH_KEY_UNREGISTERED", so telepathy-morse indeed picked up the old key that is not assigned to any account on the server side. Right after the debug message, TelegramQt emits signal authorizationErrorReceived(), that is connected to onAuthErrorReceived in morse. The signal handler is expected to initiate connection without the previous session data.

I don't see how Morse can stuck in such state, but I can add a code to cleanup session data as we got the signal that the key is not valid. It would be better to drop only the auth key and keep the connection state data to avoid client from repeated download of the already received messages but it would be hard to do with the current session data structure.

At the meantime you can remove the old key manually. The file is located in cache directory: rm ~/.cache/telepathy-morse/secrets/<phone_number> If this is the only account, then you can safely remote the entire directory: rm -rf ~/.cache/telepathy-morse

luizluca commented 5 years ago

I removed the secrets and now it connects correctly. Thanks!