Improve logging on log out.

This commit is contained in:
levlam 2021-06-27 05:52:43 +03:00
parent 9664181d48
commit 2b7b6b7759
7 changed files with 15 additions and 16 deletions

View File

@ -59,6 +59,7 @@ AuthManager::AuthManager(int32 api_id, const string &api_hash, ActorShared<> par
td, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); })); td, PromiseCreator::lambda([this](Result<Unit> result) { update_state(State::Ok); }));
} }
} else if (auth_str == "logout") { } else if (auth_str == "logout") {
LOG(WARNING) << "Continue to log out";
update_state(State::LoggingOut); update_state(State::LoggingOut);
} else if (auth_str == "destroy") { } else if (auth_str == "destroy") {
update_state(State::DestroyingKeys); update_state(State::DestroyingKeys);
@ -345,10 +346,11 @@ void AuthManager::log_out(uint64 query_id) {
if (state_ != State::Ok) { if (state_ != State::Ok) {
// TODO: could skip full logout if still no authorization // TODO: could skip full logout if still no authorization
// TODO: send auth.cancelCode if state_ == State::WaitCode // TODO: send auth.cancelCode if state_ == State::WaitCode
LOG(WARNING) << "Destroying auth keys by user request";
destroy_auth_keys(); destroy_auth_keys();
on_query_ok(); on_query_ok();
} else { } else {
LOG(INFO) << "Logging out"; LOG(WARNING) << "Logging out by user request";
G()->td_db()->get_binlog_pmc()->set("auth", "logout"); G()->td_db()->get_binlog_pmc()->set("auth", "logout");
update_state(State::LoggingOut); update_state(State::LoggingOut);
send_log_out_query(); send_log_out_query();
@ -628,12 +630,13 @@ void AuthManager::on_log_out_result(NetQueryPtr &result) {
on_query_ok(); on_query_ok();
} }
} }
void AuthManager::on_authorization_lost() { void AuthManager::on_authorization_lost(const string &source) {
LOG(WARNING) << "Lost authorization because of " << source;
destroy_auth_keys(); destroy_auth_keys();
} }
void AuthManager::destroy_auth_keys() { void AuthManager::destroy_auth_keys() {
if (state_ == State::Closing) { if (state_ == State::Closing || state_ == State::DestroyingKeys) {
return; return;
} }
update_state(State::DestroyingKeys); update_state(State::DestroyingKeys);

View File

@ -48,7 +48,7 @@ class AuthManager : public NetActor {
void on_update_login_token(); void on_update_login_token();
void on_authorization_lost(); void on_authorization_lost(const string &source);
void on_closing(bool destroy_flag); void on_closing(bool destroy_flag);
// can return nullptr if state isn't initialized yet // can return nullptr if state isn't initialized yet

View File

@ -3027,7 +3027,7 @@ Status NotificationManager::process_push_notification_payload(string payload, bo
if (loc_key == "SESSION_REVOKE") { if (loc_key == "SESSION_REVOKE") {
if (was_encrypted) { if (was_encrypted) {
send_closure(td_->auth_manager_actor_, &AuthManager::on_authorization_lost); send_closure(td_->auth_manager_actor_, &AuthManager::on_authorization_lost, "SESSION_REVOKE");
} else { } else {
LOG(ERROR) << "Receive unencrypted SESSION_REVOKE push notification"; LOG(ERROR) << "Receive unencrypted SESSION_REVOKE push notification";
} }

View File

@ -3607,7 +3607,9 @@ void Td::on_config_option_updated(const string &name) {
return; return;
} }
if (name == "auth") { if (name == "auth") {
return on_authorization_lost(); send_closure(auth_manager_actor_, &AuthManager::on_authorization_lost,
G()->shared_config().get_option_string(name));
return;
} else if (name == "saved_animations_limit") { } else if (name == "saved_animations_limit") {
return animations_manager_->on_update_saved_animations_limit( return animations_manager_->on_update_saved_animations_limit(
narrow_cast<int32>(G()->shared_config().get_option_integer(name))); narrow_cast<int32>(G()->shared_config().get_option_integer(name)));
@ -3715,11 +3717,6 @@ void Td::on_connection_state_changed(StateManager::State new_state) {
make_tl_object<td_api::updateConnectionState>(get_connection_state_object(connection_state_))); make_tl_object<td_api::updateConnectionState>(get_connection_state_object(connection_state_)));
} }
void Td::on_authorization_lost() {
LOG(WARNING) << "Lost authorization";
send_closure(auth_manager_actor_, &AuthManager::on_authorization_lost);
}
void Td::start_up() { void Td::start_up() {
always_wait_for_mailbox(); always_wait_for_mailbox();

View File

@ -116,8 +116,6 @@ class Td final : public NetQueryCallback {
void on_update_server_time_difference(); void on_update_server_time_difference();
void on_authorization_lost();
void on_online_updated(bool force, bool send_update); void on_online_updated(bool force, bool send_update);
void on_update_status_success(bool is_online); void on_update_status_success(bool is_online);

View File

@ -909,6 +909,9 @@ void UpdatesManager::on_failed_get_difference(Status &&error) {
} }
void UpdatesManager::schedule_get_difference(const char *source) { void UpdatesManager::schedule_get_difference(const char *source) {
if (G()->close_flag()) {
return;
}
if (!retry_timeout_.has_timeout()) { if (!retry_timeout_.has_timeout()) {
LOG(WARNING) << "Schedule getDifference in " << retry_time_ << " seconds with pts = " << get_pts() LOG(WARNING) << "Schedule getDifference in " << retry_time_ << " seconds with pts = " << get_pts()
<< ", qts = " << get_qts() << ", date = " << get_date() << " from " << source; << ", qts = " << get_qts() << ", date = " << get_date() << " from " << source;

View File

@ -780,11 +780,9 @@ void Session::on_message_result_error(uint64 id, int error_code, BufferSlice mes
if (message.as_slice() == CSlice("USER_DEACTIVATED_BAN")) { if (message.as_slice() == CSlice("USER_DEACTIVATED_BAN")) {
LOG(PLAIN) << "Your account was suspended for suspicious activity. If you think that this is a mistake, please " LOG(PLAIN) << "Your account was suspended for suspicious activity. If you think that this is a mistake, please "
"write to recover@telegram.org your phone number and other details to recover the account."; "write to recover@telegram.org your phone number and other details to recover the account.";
} else {
LOG(WARNING) << "Lost authorization due to " << tag("msg", message.as_slice());
} }
auth_data_.set_auth_flag(false); auth_data_.set_auth_flag(false);
G()->shared_config().set_option_boolean("auth", false); G()->shared_config().set_option_string("auth", message.as_slice().str());
shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key()); shared_auth_data_->set_auth_key(auth_data_.get_main_auth_key());
on_session_failed(Status::OK()); on_session_failed(Status::OK());
} }