Use PublicRsaKeyInterface in AuthDataShared.

This commit is contained in:
levlam 2024-01-22 01:55:16 +03:00
parent d5c3456085
commit e52d08da74
3 changed files with 12 additions and 9 deletions

View File

@ -447,7 +447,7 @@ static ActorOwn<> get_full_config(DcOption option, Promise<tl_object_ptr<telegra
DcId dc_id() const final { DcId dc_id() const final {
return dc_id_; return dc_id_;
} }
const std::shared_ptr<PublicRsaKeyShared> &public_rsa_key() final { const std::shared_ptr<mtproto::PublicRsaKeyInterface> &public_rsa_key() final {
return public_rsa_key_; return public_rsa_key_;
} }
mtproto::AuthKey get_auth_key() final { mtproto::AuthKey get_auth_key() final {
@ -492,7 +492,7 @@ static ActorOwn<> get_full_config(DcOption option, Promise<tl_object_ptr<telegra
private: private:
DcId dc_id_; DcId dc_id_;
std::shared_ptr<PublicRsaKeyShared> public_rsa_key_ = std::shared_ptr<mtproto::PublicRsaKeyInterface> public_rsa_key_ =
std::make_shared<PublicRsaKeyShared>(DcId::empty(), G()->is_test_dc()); std::make_shared<PublicRsaKeyShared>(DcId::empty(), G()->is_test_dc());
std::vector<unique_ptr<Listener>> auth_key_listeners_; std::vector<unique_ptr<Listener>> auth_key_listeners_;

View File

@ -21,7 +21,8 @@ namespace td {
class AuthDataSharedImpl final : public AuthDataShared { class AuthDataSharedImpl final : public AuthDataShared {
public: public:
AuthDataSharedImpl(DcId dc_id, std::shared_ptr<PublicRsaKeyShared> public_rsa_key, std::shared_ptr<Guard> guard) AuthDataSharedImpl(DcId dc_id, std::shared_ptr<mtproto::PublicRsaKeyInterface> public_rsa_key,
std::shared_ptr<Guard> guard)
: dc_id_(dc_id), public_rsa_key_(std::move(public_rsa_key)), guard_(std::move(guard)) { : dc_id_(dc_id), public_rsa_key_(std::move(public_rsa_key)), guard_(std::move(guard)) {
log_auth_key(get_auth_key()); log_auth_key(get_auth_key());
} }
@ -30,7 +31,7 @@ class AuthDataSharedImpl final : public AuthDataShared {
return dc_id_; return dc_id_;
} }
const std::shared_ptr<PublicRsaKeyShared> &public_rsa_key() final { const std::shared_ptr<mtproto::PublicRsaKeyInterface> &public_rsa_key() final {
return public_rsa_key_; return public_rsa_key_;
} }
@ -88,7 +89,7 @@ class AuthDataSharedImpl final : public AuthDataShared {
private: private:
DcId dc_id_; DcId dc_id_;
std::vector<unique_ptr<Listener>> auth_key_listeners_; std::vector<unique_ptr<Listener>> auth_key_listeners_;
std::shared_ptr<PublicRsaKeyShared> public_rsa_key_; std::shared_ptr<mtproto::PublicRsaKeyInterface> public_rsa_key_;
std::shared_ptr<Guard> guard_; std::shared_ptr<Guard> guard_;
RwMutex rw_mutex_; RwMutex rw_mutex_;
@ -123,7 +124,8 @@ mtproto::AuthKey AuthDataShared::get_auth_key_for_dc(DcId dc_id) {
return AuthDataSharedImpl::get_auth_key_for_dc(dc_id); return AuthDataSharedImpl::get_auth_key_for_dc(dc_id);
} }
std::shared_ptr<AuthDataShared> AuthDataShared::create(DcId dc_id, std::shared_ptr<PublicRsaKeyShared> public_rsa_key, std::shared_ptr<AuthDataShared> AuthDataShared::create(DcId dc_id,
std::shared_ptr<mtproto::PublicRsaKeyInterface> public_rsa_key,
std::shared_ptr<Guard> guard) { std::shared_ptr<Guard> guard) {
return std::make_shared<AuthDataSharedImpl>(dc_id, std::move(public_rsa_key), std::move(guard)); return std::make_shared<AuthDataSharedImpl>(dc_id, std::move(public_rsa_key), std::move(guard));
} }

View File

@ -7,10 +7,10 @@
#pragma once #pragma once
#include "td/telegram/net/DcId.h" #include "td/telegram/net/DcId.h"
#include "td/telegram/net/PublicRsaKeyShared.h"
#include "td/mtproto/AuthData.h" #include "td/mtproto/AuthData.h"
#include "td/mtproto/AuthKey.h" #include "td/mtproto/AuthKey.h"
#include "td/mtproto/RSA.h"
#include "td/utils/common.h" #include "td/utils/common.h"
#include "td/utils/ScopeGuard.h" #include "td/utils/ScopeGuard.h"
@ -33,7 +33,7 @@ class AuthDataShared {
}; };
virtual DcId dc_id() const = 0; virtual DcId dc_id() const = 0;
virtual const std::shared_ptr<PublicRsaKeyShared> &public_rsa_key() = 0; virtual const std::shared_ptr<mtproto::PublicRsaKeyInterface> &public_rsa_key() = 0;
virtual mtproto::AuthKey get_auth_key() = 0; virtual mtproto::AuthKey get_auth_key() = 0;
virtual void set_auth_key(const mtproto::AuthKey &auth_key) = 0; virtual void set_auth_key(const mtproto::AuthKey &auth_key) = 0;
virtual void update_server_time_difference(double diff, bool force) = 0; virtual void update_server_time_difference(double diff, bool force) = 0;
@ -45,7 +45,8 @@ class AuthDataShared {
static mtproto::AuthKey get_auth_key_for_dc(DcId dc_id); static mtproto::AuthKey get_auth_key_for_dc(DcId dc_id);
static std::shared_ptr<AuthDataShared> create(DcId dc_id, std::shared_ptr<PublicRsaKeyShared> public_rsa_key, static std::shared_ptr<AuthDataShared> create(DcId dc_id,
std::shared_ptr<mtproto::PublicRsaKeyInterface> public_rsa_key,
std::shared_ptr<Guard> guard); std::shared_ptr<Guard> guard);
}; };