diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index e92802de88..67a859e482 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -339,6 +339,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_proxy_invalid" = "The proxy link is invalid."; "lng_proxy_unsupported" = "Your Telegram Desktop version doesn't support this proxy type or the proxy link is invalid. Please update Telegram Desktop to the latest version."; "lng_proxy_incorrect_secret" = "This proxy link uses invalid **secret** parameter. Please contact the proxy provider and ask him to update MTProxy source code and configure it with a correct **secret** value. Then let him provide a new link."; +"lng_proxy_check_ip_warning_title" = "Warning"; +"lng_proxy_check_ip_warning" = "This will expose your IP address to the admin of the proxy server."; +"lng_proxy_check_ip_proceed" = "Proceed"; "lng_edit_deleted" = "This message was deleted"; "lng_edit_limit_reached#one" = "You've reached the message text limit. Please make the text shorter by {count} character."; diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 1bdb77d824..0a172d31d4 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -1647,7 +1647,22 @@ void ProxiesBoxController::ShowApplyConfirmation( } }; statusLabel->setClickHandlerFilter([=](const auto &...) { - runCheck(); + auto &proxy = Core::App().settings().proxy(); + if (proxy.checkIpWarningShown()) { + runCheck(); + } else { + box->uiShow()->showBox(Ui::MakeConfirmBox({ + .text = tr::lng_proxy_check_ip_warning(), + .confirmed = [=] { + auto &proxy = Core::App().settings().proxy(); + proxy.setCheckIpWarningShown(true); + Local::writeSettings(); + runCheck(); + }, + .confirmText = tr::lng_proxy_check_ip_proceed(), + .title = tr::lng_proxy_check_ip_warning_title(), + })); + } return false; }); } diff --git a/Telegram/SourceFiles/core/core_settings_proxy.cpp b/Telegram/SourceFiles/core/core_settings_proxy.cpp index 1807aa2efe..6f338de6aa 100644 --- a/Telegram/SourceFiles/core/core_settings_proxy.cpp +++ b/Telegram/SourceFiles/core/core_settings_proxy.cpp @@ -107,7 +107,8 @@ QByteArray SettingsProxy::serialize() const { serializedList, 0, ranges::plus(), - &Serialize::bytearraySize); + &Serialize::bytearraySize) + + 1 * sizeof(qint32); // _checkIpWarningShown auto stream = Serialize::ByteArrayWriter(size); stream << qint32(_tryIPv6 ? 1 : 0) @@ -118,6 +119,7 @@ QByteArray SettingsProxy::serialize() const { for (const auto &i : serializedList) { stream << i; } + stream << qint32(_checkIpWarningShown ? 1 : 0); return std::move(stream).result(); } @@ -150,6 +152,11 @@ bool SettingsProxy::setFromSerialized(const QByteArray &serialized) { } } + auto checkIpWarningShown = qint32(0); + if (!stream.atEnd()) { + stream >> checkIpWarningShown; + } + if (!stream.ok()) { LOG(("App Error: " "Bad data for Core::SettingsProxy::setFromSerialized()")); @@ -158,6 +165,7 @@ bool SettingsProxy::setFromSerialized(const QByteArray &serialized) { _tryIPv6 = (tryIPv6 == 1); _useProxyForCalls = (useProxyForCalls == 1); + _checkIpWarningShown = (checkIpWarningShown == 1); _settings = IntToProxySettings(settings); _selected = DeserializeProxyData(selectedProxy); @@ -176,6 +184,14 @@ bool SettingsProxy::isDisabled() const { return _settings == MTP::ProxyData::Settings::Disabled; } +bool SettingsProxy::checkIpWarningShown() const { + return _checkIpWarningShown; +} + +void SettingsProxy::setCheckIpWarningShown(bool value) { + _checkIpWarningShown = value; +} + bool SettingsProxy::tryIPv6() const { return _tryIPv6; } diff --git a/Telegram/SourceFiles/core/core_settings_proxy.h b/Telegram/SourceFiles/core/core_settings_proxy.h index bd709c230a..340dd050d8 100644 --- a/Telegram/SourceFiles/core/core_settings_proxy.h +++ b/Telegram/SourceFiles/core/core_settings_proxy.h @@ -35,6 +35,9 @@ public: [[nodiscard]] MTP::ProxyData selected() const; void setSelected(MTP::ProxyData value); + [[nodiscard]] bool checkIpWarningShown() const; + void setCheckIpWarningShown(bool value); + [[nodiscard]] const std::vector &list() const; [[nodiscard]] std::vector &list(); @@ -44,6 +47,7 @@ public: private: bool _tryIPv6 = false; bool _useProxyForCalls = false; + bool _checkIpWarningShown = false; MTP::ProxyData::Settings _settings = MTP::ProxyData::Settings::System; MTP::ProxyData _selected; std::vector _list;