Forcely disable multiple sessions and PFS while destroying auth key.

This commit is contained in:
levlam 2023-10-23 14:58:12 +03:00
parent 9fdc48ac2d
commit 4786d1a931
5 changed files with 18 additions and 19 deletions

View File

@ -226,7 +226,8 @@ void NetQueryDispatcher::update_session_count() {
bool use_pfs = get_use_pfs();
for (size_t i = 1; i < MAX_DC_COUNT; i++) {
if (is_dc_inited(narrow_cast<int32>(i))) {
send_closure_later(dcs_[i - 1].main_session_, &SessionMultiProxy::update_options, session_count, use_pfs);
send_closure_later(dcs_[i - 1].main_session_, &SessionMultiProxy::update_options, session_count, use_pfs,
need_destroy_auth_key_);
send_closure_later(dcs_[i - 1].upload_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
send_closure_later(dcs_[i - 1].download_session_, &SessionMultiProxy::update_use_pfs, use_pfs);
send_closure_later(dcs_[i - 1].download_small_session_, &SessionMultiProxy::update_use_pfs, use_pfs);

View File

@ -61,19 +61,23 @@ void SessionMultiProxy::update_main_flag(bool is_main) {
}
void SessionMultiProxy::destroy_auth_key() {
need_destroy_auth_key_ = true;
send_closure(sessions_[0].proxy, &SessionProxy::destroy_auth_key);
update_options(1, false, true);
}
void SessionMultiProxy::update_session_count(int32 session_count) {
update_options(session_count, use_pfs_);
update_options(session_count, use_pfs_, need_destroy_auth_key_);
}
void SessionMultiProxy::update_use_pfs(bool use_pfs) {
update_options(session_count_, use_pfs);
update_options(session_count_, use_pfs, need_destroy_auth_key_);
}
void SessionMultiProxy::update_options(int32 session_count, bool use_pfs) {
void SessionMultiProxy::update_options(int32 session_count, bool use_pfs, bool need_destroy_auth_key) {
if (need_destroy_auth_key_) {
LOG(INFO) << "Ignore session option changes while destroying auth key";
return;
}
bool changed = false;
if (session_count != session_count_) {
@ -96,6 +100,12 @@ void SessionMultiProxy::update_options(int32 session_count, bool use_pfs) {
changed = true;
}
}
if (need_destroy_auth_key) {
need_destroy_auth_key_ = need_destroy_auth_key;
LOG(WARNING) << "Destroy auth key in " << get_name();
}
if (changed) {
init();
}

View File

@ -30,7 +30,7 @@ class SessionMultiProxy final : public Actor {
void update_session_count(int32 session_count);
void update_use_pfs(bool use_pfs);
void update_options(int32 session_count, bool use_pfs);
void update_options(int32 session_count, bool use_pfs, bool need_destroy_auth_key);
void update_mtproto_header();
void destroy_auth_key();

View File

@ -172,16 +172,6 @@ void SessionProxy::update_main_flag(bool is_main) {
open_session();
}
void SessionProxy::destroy_auth_key() {
if (need_destroy_auth_key_) {
LOG(INFO) << "Ignore reduntant destroy_auth_key";
return;
}
need_destroy_auth_key_ = true;
close_session();
open_session();
}
void SessionProxy::on_failed() {
if (session_generation_ != get_link_token()) {
return;

View File

@ -42,8 +42,6 @@ class SessionProxy final : public Actor {
void update_mtproto_header();
void destroy_auth_key();
private:
unique_ptr<Callback> callback_;
std::shared_ptr<AuthDataShared> auth_data_;