Minor improvements.

GitOrigin-RevId: 684fd2527c31f6fdbc816a2addd64e4740f8a15b
This commit is contained in:
levlam 2019-07-09 06:56:06 +03:00
parent c626bbefe6
commit b9e5ebd222
19 changed files with 30 additions and 13 deletions

View File

@ -25,6 +25,7 @@ class msg_container {
static const int32 ID = 0x73f1f8dc;
};
} // namespace mtproto_api
namespace mtproto {
template <class Object, class ObjectStorer>

View File

@ -17,7 +17,6 @@
#include "td/utils/UInt.h"
namespace td {
namespace mtproto {
class AuthKeyHandshakeContext {

View File

@ -14,6 +14,7 @@
namespace td {
namespace mtproto {
HandshakeActor::HandshakeActor(unique_ptr<AuthKeyHandshake> handshake, unique_ptr<RawConnection> raw_connection,
unique_ptr<AuthKeyHandshakeContext> context, double timeout,
Promise<unique_ptr<RawConnection>> raw_connection_promise,
@ -86,5 +87,6 @@ void HandshakeActor::return_handshake() {
}
handshake_promise_.set_value(std::move(handshake_));
}
} // namespace mtproto
} // namespace td

View File

@ -20,5 +20,5 @@ namespace mtproto {
ActorOwn<> create_ping_actor(string debug, unique_ptr<RawConnection> raw_connection, unique_ptr<AuthData> auth_data,
Promise<unique_ptr<RawConnection>> promise, ActorShared<> parent);
}
} // namespace mtproto
} // namespace td

View File

@ -16,6 +16,7 @@
namespace td {
namespace mtproto {
namespace tcp {
size_t IntermediateTransport::read_from_stream(ChainBufferReader *stream, BufferSlice *message, uint32 *quick_ack) {
CHECK(message);
size_t stream_size = stream->size();

View File

@ -16,6 +16,7 @@
#include <cstdlib>
namespace td {
namespace mtproto {
void Grease::init(MutableSlice res) {
Random::secure_bytes(res);
@ -400,4 +401,5 @@ Status TlsInit::loop_impl() {
return Status::OK();
}
} // namespace mtproto
} // namespace td

View File

@ -12,6 +12,7 @@
#include "td/utils/Status.h"
namespace td {
namespace mtproto {
class Grease {
public:
@ -41,4 +42,5 @@ class TlsInit : public TransparentProxy {
Status loop_impl() override;
};
} // namespace mtproto
} // namespace td

View File

@ -9,6 +9,7 @@
#include "td/utils/Status.h"
namespace td {
namespace mtproto {
void TlsReaderByteFlow::loop() {
while (true) {
@ -36,4 +37,5 @@ void TlsReaderByteFlow::loop() {
}
}
} // namespace mtproto
} // namespace td

View File

@ -9,10 +9,12 @@
#include "td/utils/ByteFlow.h"
namespace td {
namespace mtproto {
class TlsReaderByteFlow final : public ByteFlowBase {
public:
void loop() override;
};
} // namespace mtproto
} // namespace td

View File

@ -117,4 +117,5 @@ std::shared_ptr<AuthDataShared> AuthDataShared::create(DcId dc_id, std::shared_p
std::shared_ptr<Guard> guard) {
return std::make_shared<AuthDataSharedImpl>(dc_id, std::move(public_rsa_key), std::move(guard));
}
} // namespace td

View File

@ -20,6 +20,7 @@
#include <utility>
namespace td {
enum class AuthState : int32 { Empty, KeyNoAuth, OK };
inline StringBuilder &operator<<(StringBuilder &sb, AuthState state) {

View File

@ -475,9 +475,9 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address
proxy.proxy().user().str(), proxy.proxy().password().str(),
std::move(callback), create_reference(token))};
} else if (secret.emulate_tls()) {
children_[token] = {
false, create_actor<TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip, secret.get_domain(),
secret.get_proxy_secret().str(), std::move(callback), create_reference(token),
children_[token] = {false, create_actor<mtproto::TlsInit>("PingTlsInit", std::move(socket_fd), extra.mtproto_ip,
secret.get_domain(), secret.get_proxy_secret().str(),
std::move(callback), create_reference(token),
G()->get_dns_time_difference())};
} else {
UNREACHABLE();
@ -968,9 +968,9 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
std::move(callback), create_reference(token))};
} else if (secret.emulate_tls()) {
children_[token] = {
true, create_actor<TlsInit>("TlsInit", std::move(socket_fd), extra.mtproto_ip, secret.get_domain(),
secret.get_proxy_secret().str(), std::move(callback), create_reference(token),
G()->get_dns_time_difference())};
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), G()->get_dns_time_difference())};
} else {
UNREACHABLE();
}

View File

@ -245,4 +245,5 @@ void DcAuthManager::loop() {
dc_loop(dc);
}
}
} // namespace td

View File

@ -52,4 +52,5 @@ class NetQueryCounter {
private:
bool is_alive_;
};
} // namespace td

View File

@ -6,6 +6,7 @@
//
#include "td/telegram/net/NetQueryDispatcher.h"
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/DcAuthManager.h"
#include "td/telegram/net/NetQuery.h"
#include "td/telegram/net/NetQueryDelayer.h"

View File

@ -6,7 +6,6 @@
//
#pragma once
#include "td/telegram/net/AuthDataShared.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/NetQuery.h"

View File

@ -143,6 +143,7 @@ class NetStatsManager : public Actor {
void on_stats_updated(size_t id);
void on_net_type_updated(NetType net_type);
};
} // namespace td
/*

View File

@ -118,4 +118,5 @@ void PublicRsaKeyWatchdog::sync_key(std::shared_ptr<PublicRsaKeyShared> &key) {
}
}
}
} // namespace td

View File

@ -592,7 +592,7 @@ RegisterTest<Mtproto_FastPing> mtproto_fastping("Mtproto_FastPing");
TEST(Mtproto, Grease) {
std::string s(10000, '0');
Grease::init(s);
mtproto::Grease::init(s);
for (auto c : s) {
CHECK((c & 0xF) == 0xA);
}
@ -625,7 +625,7 @@ TEST(Mtproto, TlsTransport) {
IPAddress ip_address;
ip_address.init_host_port(domain, 443).ensure();
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())
.release();
}