Improve logging for auth key dropping.
This commit is contained in:
parent
6917d9c36f
commit
5cb02b8d01
|
@ -181,6 +181,7 @@ void CallManager::hangup() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallManager::hangup_shared() {
|
void CallManager::hangup_shared() {
|
||||||
auto token = narrow_cast<int32>(get_link_token());
|
auto token = narrow_cast<int32>(get_link_token());
|
||||||
auto it = id_to_actor_.find(CallId(token));
|
auto it = id_to_actor_.find(CallId(token));
|
||||||
|
@ -195,4 +196,5 @@ void CallManager::hangup_shared() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|
|
@ -383,26 +383,33 @@ void Session::on_bind_result(NetQueryPtr query) {
|
||||||
if (query->is_error()) {
|
if (query->is_error()) {
|
||||||
status = std::move(query->error());
|
status = std::move(query->error());
|
||||||
if (status.code() == 400 && status.message() == "ENCRYPTED_MESSAGE_INVALID") {
|
if (status.code() == 400 && status.message() == "ENCRYPTED_MESSAGE_INVALID") {
|
||||||
auto auth_key_age = G()->server_time() - auth_data_.get_main_auth_key().created_at();
|
auto server_time = G()->server_time();
|
||||||
bool has_immunity = !G()->is_server_time_reliable() || auth_key_age < 60 ||
|
auto auth_key_creation_date = auth_data_.get_main_auth_key().created_at();
|
||||||
(auth_key_age > 86400 &&
|
auto auth_key_age = server_time - auth_key_creation_date;
|
||||||
(use_pfs_ ? last_bind_success_timestamp_ : last_success_timestamp_) > Time::now() - 86400);
|
auto is_server_time_reliable = G()->is_server_time_reliable();
|
||||||
|
auto last_success_time = use_pfs_ ? last_bind_success_timestamp_ : last_success_timestamp_;
|
||||||
|
auto now = Time::now();
|
||||||
|
bool has_immunity =
|
||||||
|
!is_server_time_reliable || auth_key_age < 60 || (auth_key_age > 86400 && last_success_time > now - 86400);
|
||||||
|
auto debug = PSTRING() << ". Server time is " << server_time << ", auth key created at " << auth_key_creation_date
|
||||||
|
<< ", is_server_time_reliable = " << is_server_time_reliable
|
||||||
|
<< ", last_success_time = " << last_success_time << ", now = " << now;
|
||||||
if (!use_pfs_) {
|
if (!use_pfs_) {
|
||||||
if (has_immunity) {
|
if (has_immunity) {
|
||||||
LOG(WARNING) << "Do not drop main key, because it was created too recently";
|
LOG(WARNING) << "Do not drop main key, because it was created too recently" << debug;
|
||||||
} else {
|
} else {
|
||||||
LOG(WARNING) << "Drop main key because check with temporary key failed";
|
LOG(WARNING) << "Drop main key because check with temporary key failed" << debug;
|
||||||
auth_data_.drop_main_auth_key();
|
auth_data_.drop_main_auth_key();
|
||||||
on_auth_key_updated();
|
on_auth_key_updated();
|
||||||
G()->log_out("Main authorization key is invalid");
|
G()->log_out("Main authorization key is invalid");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (has_immunity) {
|
if (has_immunity) {
|
||||||
LOG(WARNING) << "Do not validate main key, because it was created too recently";
|
LOG(WARNING) << "Do not validate main key, because it was created too recently" << debug;
|
||||||
} else {
|
} else {
|
||||||
need_check_main_key_ = true;
|
need_check_main_key_ = true;
|
||||||
auth_data_.set_use_pfs(false);
|
auth_data_.set_use_pfs(false);
|
||||||
LOG(WARNING) << "Got ENCRYPTED_MESSAGE_INVALID error, validate main key";
|
LOG(WARNING) << "Got ENCRYPTED_MESSAGE_INVALID error, validate main key" << debug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue