2018-12-31 20:04:05 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/net/DcId.h"
|
|
|
|
|
2020-05-17 16:07:16 +02:00
|
|
|
#include "td/mtproto/RSA.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/port/RwMutex.h"
|
|
|
|
#include "td/utils/Status.h"
|
|
|
|
|
|
|
|
namespace td {
|
2018-02-03 13:58:18 +01:00
|
|
|
|
2024-01-22 00:15:26 +01:00
|
|
|
class PublicRsaKeySharedCdn final : public mtproto::PublicRsaKeyInterface {
|
2018-12-31 20:04:05 +01:00
|
|
|
public:
|
2024-01-22 00:15:26 +01:00
|
|
|
explicit PublicRsaKeySharedCdn(DcId dc_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
class Listener {
|
|
|
|
public:
|
|
|
|
Listener() = default;
|
|
|
|
Listener(const Listener &) = delete;
|
|
|
|
Listener &operator=(const Listener &) = delete;
|
|
|
|
Listener(Listener &&) = delete;
|
|
|
|
Listener &operator=(Listener &&) = delete;
|
|
|
|
virtual ~Listener() = default;
|
|
|
|
virtual bool notify() = 0;
|
|
|
|
};
|
|
|
|
|
2021-07-05 20:04:23 +02:00
|
|
|
void add_rsa(mtproto::RSA rsa);
|
2024-01-22 00:15:26 +01:00
|
|
|
|
2021-07-05 21:09:45 +02:00
|
|
|
Result<RsaKey> get_rsa_key(const vector<int64> &fingerprints) final;
|
2024-01-22 00:15:26 +01:00
|
|
|
|
2021-07-03 22:51:36 +02:00
|
|
|
void drop_keys() final;
|
2024-01-22 00:15:26 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool has_keys();
|
|
|
|
|
2018-09-27 03:19:03 +02:00
|
|
|
void add_listener(unique_ptr<Listener> listener);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
DcId dc_id() const {
|
|
|
|
return dc_id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DcId dc_id_;
|
2024-01-22 00:15:26 +01:00
|
|
|
vector<RsaKey> keys_;
|
|
|
|
vector<unique_ptr<Listener>> listeners_;
|
2018-12-31 20:04:05 +01:00
|
|
|
RwMutex rw_mutex_;
|
|
|
|
|
2021-07-05 21:19:59 +02:00
|
|
|
RsaKey *get_rsa_key_unsafe(int64 fingerprint);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void notify();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|