Minor improvements.
GitOrigin-RevId: 684fd2527c31f6fdbc816a2addd64e4740f8a15b
This commit is contained in:
parent
c626bbefe6
commit
b9e5ebd222
@ -25,6 +25,7 @@ class msg_container {
|
|||||||
static const int32 ID = 0x73f1f8dc;
|
static const int32 ID = 0x73f1f8dc;
|
||||||
};
|
};
|
||||||
} // namespace mtproto_api
|
} // namespace mtproto_api
|
||||||
|
|
||||||
namespace mtproto {
|
namespace mtproto {
|
||||||
|
|
||||||
template <class Object, class ObjectStorer>
|
template <class Object, class ObjectStorer>
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include "td/utils/UInt.h"
|
#include "td/utils/UInt.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
namespace mtproto {
|
namespace mtproto {
|
||||||
|
|
||||||
class AuthKeyHandshakeContext {
|
class AuthKeyHandshakeContext {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace mtproto {
|
namespace mtproto {
|
||||||
|
|
||||||
HandshakeActor::HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
|
HandshakeActor::HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
|
||||||
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
|
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
|
||||||
Promise<unique_ptr<RawConnection>> raw_connection_promise,
|
Promise<unique_ptr<RawConnection>> raw_connection_promise,
|
||||||
@ -86,5 +87,6 @@ void HandshakeActor::return_handshake() {
|
|||||||
}
|
}
|
||||||
handshake_promise_.set_value(std::move(handshake_));
|
handshake_promise_.set_value(std::move(handshake_));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mtproto
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -20,5 +20,5 @@ namespace mtproto {
|
|||||||
ActorOwn<> create_ping_actor(string debug, unique_ptr<RawConnection> raw_connection, unique_ptr<AuthData> auth_data,
|
ActorOwn<> create_ping_actor(string debug, unique_ptr<RawConnection> raw_connection, unique_ptr<AuthData> auth_data,
|
||||||
Promise<unique_ptr<RawConnection>> promise, ActorShared<> parent);
|
Promise<unique_ptr<RawConnection>> promise, ActorShared<> parent);
|
||||||
|
|
||||||
}
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
namespace td {
|
namespace td {
|
||||||
namespace mtproto {
|
namespace mtproto {
|
||||||
namespace tcp {
|
namespace tcp {
|
||||||
|
|
||||||
size_t IntermediateTransport::read_from_stream(ChainBufferReader *stream, BufferSlice *message, uint32 *quick_ack) {
|
size_t IntermediateTransport::read_from_stream(ChainBufferReader *stream, BufferSlice *message, uint32 *quick_ack) {
|
||||||
CHECK(message);
|
CHECK(message);
|
||||||
size_t stream_size = stream->size();
|
size_t stream_size = stream->size();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
namespace mtproto {
|
||||||
|
|
||||||
void Grease::init(MutableSlice res) {
|
void Grease::init(MutableSlice res) {
|
||||||
Random::secure_bytes(res);
|
Random::secure_bytes(res);
|
||||||
@ -400,4 +401,5 @@ Status TlsInit::loop_impl() {
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
namespace mtproto {
|
||||||
|
|
||||||
class Grease {
|
class Grease {
|
||||||
public:
|
public:
|
||||||
@ -41,4 +42,5 @@ class TlsInit : public TransparentProxy {
|
|||||||
Status loop_impl() override;
|
Status loop_impl() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "td/utils/Status.h"
|
#include "td/utils/Status.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
namespace mtproto {
|
||||||
|
|
||||||
void TlsReaderByteFlow::loop() {
|
void TlsReaderByteFlow::loop() {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -36,4 +37,5 @@ void TlsReaderByteFlow::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -9,10 +9,12 @@
|
|||||||
#include "td/utils/ByteFlow.h"
|
#include "td/utils/ByteFlow.h"
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
namespace mtproto {
|
||||||
|
|
||||||
class TlsReaderByteFlow final : public ByteFlowBase {
|
class TlsReaderByteFlow final : public ByteFlowBase {
|
||||||
public:
|
public:
|
||||||
void loop() override;
|
void loop() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace mtproto
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -117,4 +117,5 @@ std::shared_ptr<AuthDataShared> AuthDataShared::create(DcId dc_id, std::shared_p
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
enum class AuthState : int32 { Empty, KeyNoAuth, OK };
|
enum class AuthState : int32 { Empty, KeyNoAuth, OK };
|
||||||
|
|
||||||
inline StringBuilder &operator<<(StringBuilder &sb, AuthState state) {
|
inline StringBuilder &operator<<(StringBuilder &sb, AuthState state) {
|
||||||
|
@ -475,10 +475,10 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
|
|||||||
proxy.proxy().user().str(), proxy.proxy().password().str(),
|
proxy.proxy().user().str(), proxy.proxy().password().str(),
|
||||||
std::move(callback), create_reference(token))};
|
std::move(callback), create_reference(token))};
|
||||||
} else if (secret.emulate_tls()) {
|
} else if (secret.emulate_tls()) {
|
||||||
children_[token] = {
|
children_[token] = {false, create_actor<mtproto::TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip,
|
||||||
false, create_actor<TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip, secret.get_domain(),
|
secret.get_domain(), secret.get_proxy_secret().str(),
|
||||||
secret.get_proxy_secret().str(), std::move(callback), create_reference(token),
|
std::move(callback), create_reference(token),
|
||||||
G()->get_dns_time_difference())};
|
G()->get_dns_time_difference())};
|
||||||
} else {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
@ -968,9 +968,9 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
|
|||||||
std::move(callback), create_reference(token))};
|
std::move(callback), create_reference(token))};
|
||||||
} else if (secret.emulate_tls()) {
|
} else if (secret.emulate_tls()) {
|
||||||
children_[token] = {
|
children_[token] = {
|
||||||
true, create_actor<TlsInit>("TlsInit", std::move(socket_fd), extra.mtproto_ip, secret.get_domain(),
|
true, create_actor<mtproto::TlsInit>("TlsInit", std::move(socket_fd), extra.mtproto_ip, secret.get_domain(),
|
||||||
secret.get_proxy_secret().str(), std::move(callback), create_reference(token),
|
secret.get_proxy_secret().str(), std::move(callback),
|
||||||
G()->get_dns_time_difference())};
|
create_reference(token), G()->get_dns_time_difference())};
|
||||||
} else {
|
} else {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
@ -245,4 +245,5 @@ void DcAuthManager::loop() {
|
|||||||
dc_loop(dc);
|
dc_loop(dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -52,4 +52,5 @@ class NetQueryCounter {
|
|||||||
private:
|
private:
|
||||||
bool is_alive_;
|
bool is_alive_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#include "td/telegram/net/NetQueryDispatcher.h"
|
#include "td/telegram/net/NetQueryDispatcher.h"
|
||||||
|
|
||||||
|
#include "td/telegram/net/AuthDataShared.h"
|
||||||
#include "td/telegram/net/DcAuthManager.h"
|
#include "td/telegram/net/DcAuthManager.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
#include "td/telegram/net/NetQueryDelayer.h"
|
#include "td/telegram/net/NetQueryDelayer.h"
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "td/telegram/net/AuthDataShared.h"
|
|
||||||
#include "td/telegram/net/DcId.h"
|
#include "td/telegram/net/DcId.h"
|
||||||
#include "td/telegram/net/NetQuery.h"
|
#include "td/telegram/net/NetQuery.h"
|
||||||
|
|
||||||
|
@ -143,6 +143,7 @@ class NetStatsManager : public Actor {
|
|||||||
void on_stats_updated(size_t id);
|
void on_stats_updated(size_t id);
|
||||||
void on_net_type_updated(NetType net_type);
|
void on_net_type_updated(NetType net_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,4 +118,5 @@ void PublicRsaKeyWatchdog::sync_key(std::shared_ptr<PublicRsaKeyShared> &key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -592,7 +592,7 @@ RegisterTest<Mtproto_FastPing> mtproto_fastping("Mtproto_FastPing");
|
|||||||
|
|
||||||
TEST(Mtproto, Grease) {
|
TEST(Mtproto, Grease) {
|
||||||
std::string s(10000, '0');
|
std::string s(10000, '0');
|
||||||
Grease::init(s);
|
mtproto::Grease::init(s);
|
||||||
for (auto c : s) {
|
for (auto c : s) {
|
||||||
CHECK((c & 0xF) == 0xA);
|
CHECK((c & 0xF) == 0xA);
|
||||||
}
|
}
|
||||||
@ -625,8 +625,8 @@ TEST(Mtproto, TlsTransport) {
|
|||||||
IPAddress ip_address;
|
IPAddress ip_address;
|
||||||
ip_address.init_host_port(domain, 443).ensure();
|
ip_address.init_host_port(domain, 443).ensure();
|
||||||
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
|
SocketFd fd = SocketFd::open(ip_address).move_as_ok();
|
||||||
create_actor<TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret",
|
create_actor<mtproto::TlsInit>("TlsInit", std::move(fd), IPAddress(), domain, "0123456789secret",
|
||||||
make_unique<Callback>(), ActorShared<>(), Clocks::system() - Time::now())
|
make_unique<Callback>(), ActorShared<>(), Clocks::system() - Time::now())
|
||||||
.release();
|
.release();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user