diff --git a/CHANGELOG.md b/CHANGELOG.md index ff83a2013..c8dfc4772 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -716,7 +716,7 @@ Changes in 1.2.0: * Added method `searchInstalledStickerSets` to search by title and name for installed sticker sets. * Added methods for handling connected websites: `getConnectedWebsites`, `disconnectWebsite` and `disconnectAllWebsites`. -* Added method `getCountryCode`, which uses current user IP to identify their country. +* Added method `getCountryCode`, which uses current user IP address to identify their country. * Added option `t_me_url`. * Fixed `BlackBerry` spelling in `deviceTokenBlackBerryPush`. * Fixed return type of `getChatMessageByDate` method, which is `Message` and not `Messages`. diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index a86b9352b..59e26c318 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4383,7 +4383,7 @@ answerCustomQuery custom_query_id:int64 data:string = Ok; setAlarm seconds:double = Ok; -//@description Uses current user IP to found their country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization +//@description Uses current user IP address to found their country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization getCountryCode = Text; //@description Returns the default text for invitation messages to be used as a placeholder when the current user invites friends to Telegram diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 0d6307655..341181bf5 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -587,10 +587,10 @@ class TestProxyRequest : public RequestOnceActor { } auto dc_options = ConnectionCreator::get_default_dc_options(false); - IPAddress mtproto_ip; + IPAddress mtproto_ip_address; for (auto &dc_option : dc_options.dc_options) { if (dc_option.get_dc_id().get_raw_id() == dc_id_) { - mtproto_ip = dc_option.get_ip_address(); + mtproto_ip_address = dc_option.get_ip_address(); break; } } @@ -601,8 +601,8 @@ class TestProxyRequest : public RequestOnceActor { }); child_ = - ConnectionCreator::prepare_connection(r_socket_fd.move_as_ok(), proxy_, mtproto_ip, get_transport(), "Test", - "TestPingDC2", nullptr, {}, false, std::move(connection_promise)); + ConnectionCreator::prepare_connection(r_socket_fd.move_as_ok(), proxy_, mtproto_ip_address, get_transport(), + "Test", "TestPingDC2", nullptr, {}, false, std::move(connection_promise)); } void on_connection_data(Result r_data) { diff --git a/td/telegram/net/ConnectionCreator.cpp b/td/telegram/net/ConnectionCreator.cpp index 47e319967..dedf86016 100644 --- a/td/telegram/net/ConnectionCreator.cpp +++ b/td/telegram/net/ConnectionCreator.cpp @@ -379,8 +379,8 @@ 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.mtproto_ip, extra.transport_type, "Ping", extra.debug_str, - nullptr, create_reference(token), false, std::move(connection_promise)); + prepare_connection(std::move(socket_fd), proxy, extra.mtproto_ip_address, 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)}; } @@ -675,7 +675,7 @@ Result ConnectionCreator::get_transport_type(const Proxy Result ConnectionCreator::find_connection(const Proxy &proxy, const IPAddress &proxy_ip_address, DcId dc_id, bool allow_media_only, FindConnectionExtra &extra) { - extra.debug_str = PSTRING() << "Failed to find valid IP for " << dc_id; + extra.debug_str = PSTRING() << "Failed to find valid IP address for " << dc_id; bool prefer_ipv6 = G()->shared_config().get_option_boolean("prefer_ipv6") || (proxy.use_proxy() && proxy_ip_address.is_ipv6()); bool only_http = proxy.use_http_caching_proxy(); @@ -697,9 +697,9 @@ Result ConnectionCreator::find_connection(const Proxy &proxy, const IP extra.check_mode |= info.should_check; if (proxy.use_proxy()) { - extra.mtproto_ip = info.option->get_ip_address(); + extra.mtproto_ip_address = info.option->get_ip_address(); extra.debug_str = PSTRING() << (proxy.use_socks5_proxy() ? "Socks5" : (only_http ? "HTTP_ONLY" : "HTTP_TCP")) << ' ' - << proxy_ip_address << " --> " << extra.mtproto_ip << extra.debug_str; + << proxy_ip_address << " --> " << extra.mtproto_ip_address << extra.debug_str; VLOG(connections) << "Create: " << extra.debug_str; return SocketFd::open(proxy_ip_address); } else { @@ -709,12 +709,10 @@ Result ConnectionCreator::find_connection(const Proxy &proxy, const IP } } -ActorOwn<> ConnectionCreator::prepare_connection(SocketFd socket_fd, const Proxy &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) { +ActorOwn<> ConnectionCreator::prepare_connection( + SocketFd socket_fd, const Proxy &proxy, const IPAddress &mtproto_ip_address, mtproto::TransportType transport_type, + Slice actor_name_prefix, Slice debug_str, unique_ptr stats_callback, + ActorShared<> parent, bool use_connection_token, Promise promise) { if (proxy.use_socks5_proxy() || proxy.use_http_tcp_proxy() || transport_type.secret.emulate_tls()) { VLOG(connections) << "Create new transparent proxy connection " << debug_str; class Callback : public TransparentProxy::Callback { @@ -765,11 +763,11 @@ ActorOwn<> ConnectionCreator::prepare_connection(SocketFd socket_fd, const Proxy !proxy.use_socks5_proxy()); if (proxy.use_socks5_proxy()) { return ActorOwn<>(create_actor(PSLICE() << actor_name_prefix << "Socks5", std::move(socket_fd), - mtproto_ip, proxy.user().str(), proxy.password().str(), + mtproto_ip_address, proxy.user().str(), proxy.password().str(), std::move(callback), std::move(parent))); } else if (proxy.use_http_tcp_proxy()) { return ActorOwn<>(create_actor(PSLICE() << actor_name_prefix << "HttpProxy", std::move(socket_fd), - mtproto_ip, proxy.user().str(), proxy.password().str(), + mtproto_ip_address, proxy.user().str(), proxy.password().str(), std::move(callback), std::move(parent))); } else if (transport_type.secret.emulate_tls()) { return ActorOwn<>(create_actor( @@ -909,7 +907,7 @@ 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.mtproto_ip, extra.transport_type, Slice(), + auto ref = prepare_connection(std::move(socket_fd), proxy, extra.mtproto_ip_address, extra.transport_type, Slice(), extra.debug_str, std::move(stats_callback), create_reference(token), true, std::move(promise)); if (!ref.empty()) { diff --git a/td/telegram/net/ConnectionCreator.h b/td/telegram/net/ConnectionCreator.h index dc6146797..2a7ad5864 100644 --- a/td/telegram/net/ConnectionCreator.h +++ b/td/telegram/net/ConnectionCreator.h @@ -91,7 +91,7 @@ class ConnectionCreator : public NetQueryCallback { static DcOptions get_default_dc_options(bool is_test); - static ActorOwn<> prepare_connection(SocketFd socket_fd, const Proxy &proxy, const IPAddress &mtproto_ip, + static ActorOwn<> prepare_connection(SocketFd socket_fd, const Proxy &proxy, const IPAddress &mtproto_ip_address, mtproto::TransportType transport_type, Slice actor_name_prefix, Slice debug_str, unique_ptr stats_callback, ActorShared<> parent, bool use_connection_token, @@ -229,7 +229,7 @@ class ConnectionCreator : public NetQueryCallback { DcOptionsSet::Stat *stat{nullptr}; mtproto::TransportType transport_type; string debug_str; - IPAddress mtproto_ip; + IPAddress mtproto_ip_address; bool check_mode{false}; }; diff --git a/test/mtproto.cpp b/test/mtproto.cpp index db496270e..4289165b2 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -436,11 +436,11 @@ class Socks5TestActor : public Actor { IPAddress socks5_ip; socks5_ip.init_ipv4_port("131.191.89.104", 43077).ensure(); - IPAddress mtproto_ip = get_default_ip_address(); + IPAddress mtproto_ip_address = get_default_ip_address(); auto r_socket = SocketFd::open(socks5_ip); - create_actor("socks5", r_socket.move_as_ok(), mtproto_ip, "", "", make_unique(std::move(promise)), - actor_shared()) + create_actor("socks5", r_socket.move_as_ok(), mtproto_ip_address, "", "", + make_unique(std::move(promise)), actor_shared()) .release(); }