Fix some includes.
GitOrigin-RevId: 47d6bcd57e12314cc46c8f23ef10c10cea04fdcb
This commit is contained in:
parent
d4997705e5
commit
7542612098
@ -6,6 +6,10 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/HandshakeConnection.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
@ -14,11 +18,6 @@
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
class AuthKeyHandshake;
|
||||
class AuthKeyHandshakeContext;
|
||||
class RawConnection;
|
||||
class HandshakeConnection;
|
||||
|
||||
// Has Raw connection. Generates new auth key. And returns it and raw_connection. Or error...
|
||||
class HandshakeActor : public Actor {
|
||||
public:
|
||||
@ -59,5 +58,6 @@ class HandshakeActor : public Actor {
|
||||
void return_connection(Status status);
|
||||
void return_handshake();
|
||||
};
|
||||
|
||||
} // namespace mtproto
|
||||
} // namespace td
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/NoCryptoStorer.h"
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/Transport.h"
|
||||
#include "td/mtproto/utils.h"
|
||||
@ -22,6 +23,7 @@
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
class HandshakeConnection
|
||||
: private RawConnection::Callback
|
||||
, private AuthKeyHandshake::Callback {
|
||||
@ -78,5 +80,6 @@ class HandshakeConnection
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mtproto
|
||||
} // namespace td
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
struct TransportType {
|
||||
enum Type { Tcp, ObfuscatedTcp, Http } type;
|
||||
int16 dc_id;
|
||||
@ -22,6 +23,7 @@ struct TransportType {
|
||||
TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) {
|
||||
}
|
||||
};
|
||||
|
||||
class IStreamTransport {
|
||||
public:
|
||||
IStreamTransport() = default;
|
||||
@ -40,5 +42,6 @@ class IStreamTransport {
|
||||
};
|
||||
|
||||
unique_ptr<IStreamTransport> create_transport(TransportType type);
|
||||
|
||||
} // namespace mtproto
|
||||
} // namespace td
|
||||
|
@ -6,9 +6,8 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
|
||||
#include "td/utils/Random.h"
|
||||
#include "td/utils/StorerBase.h"
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
@ -23,6 +22,7 @@ class NoCryptoImpl {
|
||||
Random::secure_bytes(pad_);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void do_store(T &storer) const {
|
||||
storer.store_binary(message_id_);
|
||||
|
@ -8,9 +8,12 @@
|
||||
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/NoCryptoStorer.h"
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/utils.h"
|
||||
|
||||
#include "td/mtproto/mtproto_api.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/port/detail/PollableFd.h"
|
||||
#include "td/utils/Random.h"
|
||||
@ -18,8 +21,6 @@
|
||||
#include "td/utils/Time.h"
|
||||
#include "td/utils/UInt.h"
|
||||
|
||||
#include "td/mtproto/mtproto_api.h"
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/StorerBase.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -21,15 +22,15 @@ namespace mtproto {
|
||||
|
||||
void RawConnection::send_crypto(const Storer &storer, int64 session_id, int64 salt, const AuthKey &auth_key,
|
||||
uint64 quick_ack_token) {
|
||||
mtproto::PacketInfo info;
|
||||
PacketInfo info;
|
||||
info.version = 2;
|
||||
info.no_crypto_flag = false;
|
||||
info.salt = salt;
|
||||
info.session_id = session_id;
|
||||
|
||||
auto packet = BufferWriter{mtproto::Transport::write(storer, auth_key, &info), transport_->max_prepend_size(),
|
||||
auto packet = BufferWriter{Transport::write(storer, auth_key, &info), transport_->max_prepend_size(),
|
||||
transport_->max_append_size()};
|
||||
mtproto::Transport::write(storer, auth_key, &info, packet.as_slice());
|
||||
Transport::write(storer, auth_key, &info, packet.as_slice());
|
||||
|
||||
bool use_quick_ack = false;
|
||||
if (quick_ack_token != 0 && transport_->support_quick_ack()) {
|
||||
@ -45,12 +46,12 @@ void RawConnection::send_crypto(const Storer &storer, int64 session_id, int64 sa
|
||||
}
|
||||
|
||||
uint64 RawConnection::send_no_crypto(const Storer &storer) {
|
||||
mtproto::PacketInfo info;
|
||||
PacketInfo info;
|
||||
|
||||
info.no_crypto_flag = true;
|
||||
auto packet = BufferWriter{mtproto::Transport::write(storer, mtproto::AuthKey(), &info),
|
||||
transport_->max_prepend_size(), transport_->max_append_size()};
|
||||
mtproto::Transport::write(storer, mtproto::AuthKey(), &info, packet.as_slice());
|
||||
auto packet = BufferWriter{Transport::write(storer, AuthKey(), &info), transport_->max_prepend_size(),
|
||||
transport_->max_append_size()};
|
||||
Transport::write(storer, AuthKey(), &info, packet.as_slice());
|
||||
LOG(INFO) << "Send handshake packet: " << format::as_hex_dump<4>(packet.as_slice());
|
||||
transport_->write(std::move(packet), false);
|
||||
return info.message_id;
|
||||
@ -91,17 +92,17 @@ Status RawConnection::flush_read(const AuthKey &auth_key, Callback &callback) {
|
||||
PacketInfo info;
|
||||
info.version = 2;
|
||||
|
||||
TRY_RESULT(read_result, mtproto::Transport::read(packet.as_slice(), auth_key, &info));
|
||||
TRY_RESULT(read_result, Transport::read(packet.as_slice(), auth_key, &info));
|
||||
switch (read_result.type()) {
|
||||
case mtproto::Transport::ReadResult::Quickack: {
|
||||
case Transport::ReadResult::Quickack: {
|
||||
TRY_STATUS(on_quick_ack(read_result.quick_ack(), callback));
|
||||
break;
|
||||
}
|
||||
case mtproto::Transport::ReadResult::Error: {
|
||||
case Transport::ReadResult::Error: {
|
||||
TRY_STATUS(on_read_mtproto_error(read_result.error()));
|
||||
break;
|
||||
}
|
||||
case mtproto::Transport::ReadResult::Packet: {
|
||||
case Transport::ReadResult::Packet: {
|
||||
// If a packet was successfully decrypted, then it is ok to assume that the connection is alive
|
||||
if (!auth_key.empty()) {
|
||||
if (stats_callback_) {
|
||||
@ -112,7 +113,7 @@ Status RawConnection::flush_read(const AuthKey &auth_key, Callback &callback) {
|
||||
TRY_STATUS(callback.on_raw_packet(info, packet.from_slice(read_result.packet())));
|
||||
break;
|
||||
}
|
||||
case mtproto::Transport::ReadResult::Nop:
|
||||
case Transport::ReadResult::Nop:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -29,6 +29,7 @@ struct PacketInfo;
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
class RawConnection {
|
||||
public:
|
||||
class StatsCallback {
|
||||
|
@ -7,13 +7,8 @@
|
||||
#include "td/mtproto/SessionConnection.h"
|
||||
|
||||
#include "td/mtproto/AuthData.h"
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/CryptoStorer.h"
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/NoCryptoStorer.h"
|
||||
|
||||
#include "td/mtproto/HttpTransport.h"
|
||||
#include "td/mtproto/TcpTransport.h"
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
#include "td/mtproto/Transport.h"
|
||||
|
||||
#include "td/utils/as.h"
|
||||
@ -650,7 +645,7 @@ Status SessionConnection::before_write() {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
Status SessionConnection::on_raw_packet(const td::mtproto::PacketInfo &info, BufferSlice packet) {
|
||||
Status SessionConnection::on_raw_packet(const PacketInfo &info, BufferSlice packet) {
|
||||
auto old_main_message_id = main_message_id_;
|
||||
main_message_id_ = info.message_id;
|
||||
SCOPE_EXIT {
|
||||
@ -799,14 +794,14 @@ std::pair<uint64, BufferSlice> SessionConnection::encrypted_bind(int64 perm_key,
|
||||
Query query{auth_data_->next_message_id(Time::now_cached()), 0, object_packet.as_buffer_slice(), false, 0, false};
|
||||
PacketStorer<QueryImpl> query_storer(query, Slice());
|
||||
|
||||
mtproto::PacketInfo info;
|
||||
PacketInfo info;
|
||||
info.version = 1;
|
||||
info.no_crypto_flag = false;
|
||||
info.salt = Random::secure_int64();
|
||||
info.session_id = Random::secure_int64();
|
||||
|
||||
auto packet = BufferWriter{mtproto::Transport::write(query_storer, auth_data_->get_main_auth_key(), &info), 0, 0};
|
||||
mtproto::Transport::write(query_storer, auth_data_->get_main_auth_key(), &info, packet.as_slice());
|
||||
auto packet = BufferWriter{Transport::write(query_storer, auth_data_->get_main_auth_key(), &info), 0, 0};
|
||||
Transport::write(query_storer, auth_data_->get_main_auth_key(), &info, packet.as_slice());
|
||||
return std::make_pair(query.message_id, packet.as_buffer_slice());
|
||||
}
|
||||
|
||||
@ -1028,5 +1023,6 @@ void SessionConnection::force_close(SessionConnection::Callback *callback) {
|
||||
callback_ = callback;
|
||||
do_close(Status::OK());
|
||||
}
|
||||
|
||||
} // namespace mtproto
|
||||
} // namespace td
|
||||
|
@ -6,7 +6,6 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/mtproto/crypto.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/utils.h"
|
||||
|
||||
@ -258,7 +257,7 @@ class SessionConnection
|
||||
Status do_flush() TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Status before_write() override TD_WARN_UNUSED_RESULT;
|
||||
Status on_raw_packet(const td::mtproto::PacketInfo &info, BufferSlice packet) override;
|
||||
Status on_raw_packet(const PacketInfo &info, BufferSlice packet) override;
|
||||
Status on_quick_ack(uint64 quick_ack_token) override;
|
||||
void on_read(size_t size) override;
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
namespace td {
|
||||
namespace mtproto {
|
||||
|
||||
class AuthKey;
|
||||
|
||||
#pragma pack(push, 4)
|
||||
|
@ -19,6 +19,12 @@
|
||||
#include "td/telegram/net/Session.h"
|
||||
#include "td/telegram/StateManager.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/mtproto/AuthData.h"
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/crypto.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
|
||||
#if !TD_EMSCRIPTEN //FIXME
|
||||
#include "td/net/HttpQuery.h"
|
||||
@ -28,8 +34,6 @@
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
|
@ -49,7 +49,6 @@
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
@ -17,10 +17,8 @@
|
||||
|
||||
#include "td/mtproto/crypto.h"
|
||||
|
||||
#include "td/utils/as.h"
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/crypto.h"
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/JsonBuilder.h"
|
||||
#include "td/utils/logging.h"
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "td/utils/Heap.h"
|
||||
#include "td/utils/Hints.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Slice.h"
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/tl_storers.h"
|
||||
|
@ -6,8 +6,6 @@
|
||||
//
|
||||
#include "td/telegram/SecretChatActor.h"
|
||||
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
|
||||
#include "td/telegram/net/NetQueryCreator.h"
|
||||
#include "td/telegram/SecretChatId.h"
|
||||
#include "td/telegram/UniqueId.h"
|
||||
@ -15,6 +13,10 @@
|
||||
#include "td/telegram/secret_api.hpp"
|
||||
#include "td/telegram/telegram_api.hpp"
|
||||
|
||||
#include "td/mtproto/PacketStorer.h"
|
||||
#include "td/mtproto/Transport.h"
|
||||
#include "td/mtproto/utils.h"
|
||||
|
||||
#include "td/db/binlog/BinlogHelper.h"
|
||||
#include "td/db/binlog/BinlogInterface.h"
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/crypto.h"
|
||||
#include "td/mtproto/Transport.h"
|
||||
|
||||
#include "td/telegram/DhConfig.h"
|
||||
#include "td/telegram/logevent/SecretChatEvent.h"
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "td/telegram/secret_api.h"
|
||||
#include "td/telegram/telegram_api.hpp"
|
||||
|
||||
#include "td/mtproto/crypto.h"
|
||||
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/db/binlog/BinlogEvent.h"
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "td/telegram/files/FileGcParameters.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/files/FileManager.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/files/FileType.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/HashtagHints.h"
|
||||
|
@ -7,16 +7,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/FileReferenceManager.h"
|
||||
#include "td/telegram/FileReferenceManager.hpp"
|
||||
#include "td/telegram/files/FileEncryptionKey.h"
|
||||
#include "td/telegram/files/FileLocation.h"
|
||||
#include "td/telegram/files/FileSourceId.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/Td.h"
|
||||
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/format.h"
|
||||
#include "td/utils/misc.h"
|
||||
#include "td/utils/StringBuilder.h"
|
||||
#include "td/utils/tl_helpers.h"
|
||||
|
||||
|
@ -41,11 +41,11 @@ class FileReferenceView {
|
||||
LOG(ERROR) << "File reference is too big " << base64_encode(second);
|
||||
second = invalid_file_reference();
|
||||
}
|
||||
char second_length = static_cast<char>(narrow_cast<unsigned char>(second.size()));
|
||||
char second_length = static_cast<char>(static_cast<unsigned char>(second.size()));
|
||||
return PSTRING() << second_length << first << second;
|
||||
}
|
||||
|
||||
FileReferenceView(Slice data) {
|
||||
explicit FileReferenceView(Slice data) {
|
||||
if (data.empty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/telegram/ConfigShared.h"
|
||||
#include "td/telegram/FileReferenceManager.h"
|
||||
#include "td/telegram/files/FileData.h"
|
||||
#include "td/telegram/files/FileDb.h"
|
||||
#include "td/telegram/files/FileLoaderUtils.h"
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "td/telegram/telegram_api.h"
|
||||
|
||||
#include "td/mtproto/crypto.h"
|
||||
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Time.h"
|
||||
|
||||
|
@ -17,8 +17,10 @@
|
||||
#include "td/telegram/StateManager.h"
|
||||
#include "td/telegram/UniqueId.h"
|
||||
|
||||
#include "td/mtproto/crypto.h"
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/HandshakeActor.h"
|
||||
#include "td/mtproto/IStreamTransport.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/SessionConnection.h"
|
||||
|
||||
|
@ -6,18 +6,19 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/net/AuthDataShared.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/net/TempAuthKeyWatchdog.h"
|
||||
#include "td/telegram/StateManager.h"
|
||||
|
||||
#include "td/mtproto/AuthData.h"
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/SessionConnection.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
#include "td/actor/PromiseFuture.h"
|
||||
|
||||
#include "td/telegram/net/AuthDataShared.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/net/TempAuthKeyWatchdog.h"
|
||||
#include "td/telegram/StateManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/List.h"
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include "td/telegram/net/AuthDataShared.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
|
||||
#include "td/mtproto/AuthData.h"
|
||||
#include "td/mtproto/AuthKey.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "td/mtproto/crypto.h"
|
||||
#include "td/mtproto/Handshake.h"
|
||||
#include "td/mtproto/HandshakeActor.h"
|
||||
#include "td/mtproto/HandshakeConnection.h"
|
||||
#include "td/mtproto/IStreamTransport.h"
|
||||
#include "td/mtproto/PingConnection.h"
|
||||
#include "td/mtproto/RawConnection.h"
|
||||
#include "td/mtproto/Transport.h"
|
||||
@ -26,7 +26,6 @@
|
||||
#include "td/telegram/net/PublicRsaKeyShared.h"
|
||||
#include "td/telegram/NotificationManager.h"
|
||||
|
||||
#include "td/utils/as.h"
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/port/IPAddress.h"
|
||||
|
Reference in New Issue
Block a user