From 79a38df82450820ef177b20c3320e110422192b7 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 22 Jul 2019 05:55:01 +0300 Subject: [PATCH] Add actor_name_prefix to prepare_connection parameters. GitOrigin-RevId: fbfb40411a16c0609a8bd926f2b4f3428e43cd25 --- td/telegram/Td.cpp | 2 +- td/telegram/net/ConnectionCreator.cpp | 37 +++++++++++++++------------ td/telegram/net/ConnectionCreator.h | 4 +-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index f7c5a4c8..7b070220 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -580,7 +580,7 @@ class TestProxyRequest : public RequestOnceActor { }); child_ = ConnectionCreator::prepare_connection(r_socket_fd.move_as_ok(), ConnectionCreator::ProxyInfo{&proxy_}, - get_transport(), "TestPingDC2", std::move(mtproto_ip), nullptr, {}, + mtproto_ip, get_transport(), "Test", "TestPingDC2", nullptr, {}, false, std::move(connection_promise)); } diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index 38cedb02..1486c3e3 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -379,8 +379,9 @@ void ConnectionCreator::ping_proxy_resolved(int32 proxy_id, IPAddress ip_address }); CHECK(proxy.use_proxy()); auto token = next_token(); - auto ref = prepare_connection(std::move(socket_fd), proxy, extra.transport_type, extra.debug_str, extra.mtproto_ip, - nullptr, create_reference(token), false, std::move(connection_promise)); + auto ref = + prepare_connection(std::move(socket_fd), proxy, extra.mtproto_ip, extra.transport_type, "Ping", extra.debug_str, + nullptr, create_reference(token), false, std::move(connection_promise)); if (!ref.empty()) { children_[token] = {false, std::move(ref)}; } @@ -638,9 +639,9 @@ void ConnectionCreator::request_raw_connection_by_ip(IPAddress ip_address, mtpro }); auto token = next_token(); - auto ref = prepare_connection(std::move(socket_fd), ProxyInfo{nullptr}, transport_type, - PSTRING() << "to IP address " << ip_address, IPAddress(), nullptr, - create_reference(token), false, std::move(connection_promise)); + auto ref = prepare_connection(std::move(socket_fd), ProxyInfo{nullptr}, IPAddress(), transport_type, "Raw", + PSTRING() << "to IP address " << ip_address, nullptr, create_reference(token), false, + std::move(connection_promise)); if (!ref.empty()) { children_[token] = {false, std::move(ref)}; } @@ -714,8 +715,8 @@ Result ConnectionCreator::find_connection(const ProxyInfo &proxy, cons } ActorOwn<> ConnectionCreator::prepare_connection(SocketFd socket_fd, const ProxyInfo &proxy, - mtproto::TransportType transport_type, string debug_str, - IPAddress mtproto_ip, + const IPAddress &mtproto_ip, mtproto::TransportType transport_type, + Slice actor_name_prefix, Slice debug_str, unique_ptr stats_callback, ActorShared<> parent, bool use_connection_token, Promise promise) { @@ -764,17 +765,18 @@ ActorOwn<> ConnectionCreator::prepare_connection(SocketFd socket_fd, const Proxy << ": " << debug_str; auto callback = make_unique(std::move(promise), std::move(stats_callback), use_connection_token); if (proxy.use_socks5_proxy()) { - return ActorOwn<>(create_actor("Socks5", std::move(socket_fd), mtproto_ip, proxy.proxy().user().str(), - proxy.proxy().password().str(), std::move(callback), std::move(parent))); + return ActorOwn<>(create_actor(PSLICE() << actor_name_prefix << "Socks5", std::move(socket_fd), + mtproto_ip, proxy.proxy().user().str(), proxy.proxy().password().str(), + std::move(callback), std::move(parent))); } else if (proxy.use_http_tcp_proxy()) { - return ActorOwn<>(create_actor("HttpProxy", std::move(socket_fd), mtproto_ip, - proxy.proxy().user().str(), proxy.proxy().password().str(), + return ActorOwn<>(create_actor(PSLICE() << actor_name_prefix << "HttpProxy", std::move(socket_fd), + mtproto_ip, proxy.proxy().user().str(), proxy.proxy().password().str(), std::move(callback), std::move(parent))); } else if (transport_type.secret.emulate_tls()) { - return ActorOwn<>( - create_actor("TlsInit", std::move(socket_fd), transport_type.secret.get_domain(), - transport_type.secret.get_proxy_secret().str(), std::move(callback), - std::move(parent), G()->get_dns_time_difference())); + return ActorOwn<>(create_actor( + PSLICE() << actor_name_prefix << "TlsInit", std::move(socket_fd), transport_type.secret.get_domain(), + transport_type.secret.get_proxy_secret().str(), std::move(callback), std::move(parent), + G()->get_dns_time_difference())); } else { UNREACHABLE(); } @@ -909,8 +911,9 @@ void ConnectionCreator::client_loop(ClientInfo &client) { td::make_unique(client.is_media ? media_net_stats_callback_ : common_net_stats_callback_, actor_id(this), client.hash, extra.stat); auto token = next_token(); - auto ref = prepare_connection(std::move(socket_fd), proxy, extra.transport_type, extra.debug_str, extra.mtproto_ip, - std::move(stats_callback), create_reference(token), true, std::move(promise)); + auto ref = prepare_connection(std::move(socket_fd), proxy, extra.mtproto_ip, extra.transport_type, Slice(), + extra.debug_str, std::move(stats_callback), create_reference(token), true, + std::move(promise)); if (!ref.empty()) { children_[token] = {true, std::move(ref)}; } diff --git a/td/telegram/net/ConnectionCreator.h b/td/telegram/net/ConnectionCreator.h index 876477b4..84c0b0d0 100644 --- a/td/telegram/net/ConnectionCreator.h +++ b/td/telegram/net/ConnectionCreator.h @@ -122,8 +122,8 @@ class ConnectionCreator : public NetQueryCallback { static DcOptions get_default_dc_options(bool is_test); - static ActorOwn<> prepare_connection(SocketFd socket_fd, const ProxyInfo &proxy, - mtproto::TransportType transport_type, string debug_str, IPAddress mtproto_ip, + static ActorOwn<> prepare_connection(SocketFd socket_fd, const ProxyInfo &proxy, const IPAddress &mtproto_ip, + mtproto::TransportType transport_type, Slice actor_name_prefix, Slice debug_str, unique_ptr stats_callback, ActorShared<> parent, bool use_connection_token, Promise promise);